About Java Inner Classes Training
Objectives of the Course
Pre Requisites
In this chapter, You will learn
- Definition of inner class
- Syntax to define inner class
- Types of inner classes
- Static (Nested)
- Non-static (Member)
- Method Local
- Anonymous
- Inner class name change after compilation
- Need of inner class
- Allowed modifiers
- Type of members allowed in inner class
- Executing inner class using java command
- Instantiating inner class
- Executing inner class members
- Accessing inner class members from outer class and outside of outer class.
- Accessing outer class members from inner class
- Syntax to differentiate outer class members from inner class members if both have same name.
- Sample projects to understand need of Inner classes using AWT, Applet, Swing
By the end of this chapter- you will identify the correct usage and appropriate situation to use all types of inner classes.
Interview Questions
By the end of this chapter you answer all below interview questions
[list style=”style2″]
[li]What is an Inner Class?[/li]
[li]What is the need of Inner Classes?[/li]
[li]What are the advantages of Inner Classes?[/li]
[li]What are disadvantages of using Inner Classes?[/li]
[li]What are the different types of Inner Classes?[/li]
[li]If you compile a file containing Inner Class how many .class files are created and what are all of them accessible in usual way?[/li]
[li]Can we create inner class name with outerclass name or package name?[/li]
[li]What is static member class?[/li]
[li]What are Inner Classes?[/li]
[li]Which modifiers can be applied to the Inner Class?[/li]
[li]Does a static nested class have access to the enclosing class’ non-static methods or instance variables?[/li]
[li]How to access the inner class from code within the outer class?[/li]
[li]How to create an inner class instance from outside the outer class instance code?[/li]
[li]How to refer to the outer this i.e. outer class’s current instance from inside the inner class?[/li]
[li]Can the method local inner class object access method’s local variables?[/li]
[li]Can a method local inner class access the local final variables? Why?[/li]
[li]Which modifiers can be applied to the method local inner class?[/li]
[li]Can a local class declared inside a static method have access to the instance members of the outer class?[/li]
[li]Can a method which is not in the definition of the super class of an anonymous class be invoked on that anonymous class reference?[/li]
[li]What are different types of anonymous classes?[/li]
[li]Can an anonymous class define method of its own?[/li]
[li]Can an anonymous class implement multiple interfaces directly?[/li]
[li]Can an anonymous class implement an interface and also extend a class at the same time?[/li]
[li]How can we access local class or anonymous inner class specific members from outer class?[/li]
[li]Is it allowed to create inner class in interface?[/li]
[li]Is it allowed to create inner interface in class?[/li]
[li]Is it allowed to extend inner class from other class or interfaces?[/li]
[/list]
