Professional Documents
Culture Documents
5/7/2021
Dept of COMPUTER APPLICATIONS
Session Number
35
Advantages of Nested Class
1. Nested classes can access all the members (data members
and methods) of outer class including private.
2. Nested classes are used to develop more readable and
maintainable code because it logically group classes and
interfaces in one place only.
3. Code Optimization: It requires less code to write.
Dept of COMPUTER APPLICATIONS
5/7/2021 45
Session Number
1. Final Variable
Dept of COMPUTER APPLICATIONS
5/7/2021 54
Session Number
Abstract Method
A method which is declared as abstract and does not have
implementation is known as an abstract method.
Example :
abstract void printStatus(); //no method body and abstract
Dept of COMPUTER APPLICATIONS
5/7/2021 57
Session Number
Dynamic Method Dispatch
• A superclass reference variable can refer to a subclass
object. This is also known as upcasting.
• Child c = new Child(): The use of this initialization is to
access all the members present in both parent and child
classes, as we are inheriting the properties.
• Parent p = new Child(): This type of initialization is used to
access only the members present in the parent class and
the methods which are overridden in the child class.
Dept of COMPUTER APPLICATIONS
5/7/2021
Session Number
58
Dynamic Method Dispatch