✔ JAVA CHAPTERS:-
1. Introduction to Java
2. Features of Java
3. Java Virtual Machine
4. D/F B/W JVM, JRE, JDK
5. Java Data Types
6. Java Programs
7. Setting Java Path
8. OOPs Concepts
9. Object & Class In Java
10. OOPs Continued
11. Encapsulation & Polymorphism
12. Method Overloading
13. Method Overriding
14. Dynamic Method Dispatch
15. Association In Java
16. Inheritance in Java
17. Aggregation in java
18. Command Line Argument
19. Execute Command Line
20. Read Input From Command Line
21. Abstract Class In Java
22. Interface in Java
23. Cutom Marker Interface
24. Constructor In Java
25. Package in Java
26. Acess Modifier In Java
27. Static Import In Java
28. Package Class In Java
29. This Keyword
30. Instance Intializer Block
31. Super Keyword
32. Static Keyword
33. Final Keyword
1. Introduction to Java
2. Features of Java
3. Java Virtual Machine
4. D/F B/W JVM, JRE, JDK
5. Java Data Types
6. Java Programs
7. Setting Java Path
8. OOPs Concepts
9. Object & Class In Java
10. OOPs Continued
11. Encapsulation & Polymorphism
12. Method Overloading
13. Method Overriding
14. Dynamic Method Dispatch
15. Association In Java
16. Inheritance in Java
17. Aggregation in java
18. Command Line Argument
19. Execute Command Line
20. Read Input From Command Line
21. Abstract Class In Java
22. Interface in Java
23. Cutom Marker Interface
24. Constructor In Java
25. Package in Java
26. Acess Modifier In Java
27. Static Import In Java
28. Package Class In Java
29. This Keyword
30. Instance Intializer Block
31. Super Keyword
32. Static Keyword
33. Final Keyword
Instance Initializer block in Java: Previous Next: Static Keyword in Java
Super Keyword In Java
super is a keyword in java which refers to the immediate super class object.
Use of super keyword in java:
- 1. super can be used to call immediate super class constructor (constructor chaining).
- 2. super can be used to call immediate super class method on a subclass object from a subclass method.
- 3. super can be used to access immediate super class instance variable.
1. super can be used to call immediate super class constructor (constructor chaining).
Example:
SuperExample1.java
Output:
If super is not used explicitly compiler will automatically add super as the first statement.
Example:
SuperExample2.java
Output:
2. super can be used to call immediate super class method on a subclass object from a subclass method.
If super class and subclass have same methods and that method is called from subclass method than subclass method is called.
Example:
SuperExample4.java
Output:
Above problem can be solved with super keyword.
Example:
SuperExample3.java
Output:
If super class and subclass not have same methods and method of super class is called from subclass method than super class method is called. There is no need of super keyword.
Example:
SuperExample5.java
Output:
3. super can be used to access immediate super class instance variable.
If super class and subclass have same instance variables and that variable is called from subclass than subclass instance variable will be referred.
Example:
SuperExample6.java
Output:
Above problem can be solved with super keyword.
Example:
SuperExample7.java
Output:
If sub class and super class instance variables are not same than there is no need of super keyword.
Example:
SuperExample8.java