Java inner classes: What are different types of inner classes?

What are different types of inner classes?

Local classes - Local classes are like local variables, specific to a block of code. Their visibility is only within the block of their declaration

Member classes - Member inner classes are just like other member methods and member variables and access to the member class is restricted, just like methods and variables.

Anonymous classes - Anonymous classes have no name, you cannot even provide a constructor.

Explain the different types of inner classes.

A class within a class is called as inner class. Sometimes it is also known as nested class.

There are 4 types of inner classes.

1. Member Inner Class : A class that is a member ( like methods, attributes ) is called as a member inner class.

2. Local Inner Class: A class which is defined in a block( without name) is known as local inner class.

3. Static Inner Class: A class with static modifier in its definition is known as static inner class. Like other static members, a static inner class member is to be referred by its class name.

4. Anonymous Inner Class: A class that has no name and exactly implements only one interface or extends one abstract class is known as anonymous inner class. AWT and Swings uses inner classes to handle various events.
Java wrapper classes
What is wrapper classes in Java?, Why do we need wrapper classes in Java?, Features of the Java wrapper Classes...
Java error exception: What is the difference between error and an exception?
Java error exception - Errors are abnormal conditions that should never occur. Not to be confused with the compile time errors....
What is the difference between preemptive scheduling and time slicing?
Java pre-emptive scheduling and time slicing - Under time slicing, a task executes for a predefined slice of time and then reenters the pool of ready tasks...
Post your comment