Java - Inner classes

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Anonymous Inner Class

- An inner class declared without a class name - declare and instantiate them at the same time. -used whenever you need to override the method of a class or an interface.

Method-local Inner Class

- can be instantiated only within the method where the inner class is defined.

Static Nested Class

-is a nested class which is a static member of the outer class. -can be accessed without instantiating the outer class, using other static members. -does not have access to the instance variables and methods of the outer class.

Inner Class

-write a class within a class. -can be private and once you declare an inner class private, cannot be accessed from an object outside the class.

Nested classes are divided into two types

:Non-static nested classes − These are the non-static members of a class. :Static nested classes − These are the static members of a class.

nested class

a class within another

Nested Classes Syntax

class Outer_Demo { class Nested_Demo { } }

Inner Classes (Non-static Nested Classes): 3 types

depending on how and where you define them. -Inner Class -Method-local Inner Class -Anonymous Inner Class

outer class

the class that holds the inner class


Kaugnay na mga set ng pag-aaral

FBLA Entrepreneurship Study Guide

View Set

Chapter 50 - Principles of Electrical Systems.

View Set

322: Final practice, previous quizzes

View Set

A&P2 Chapter 26 - Digestive System

View Set