Question

Explain use of super and final keywords in java.

15 Sep 2022
Answer :
Word Count : 538

In Java, the super keyword is used to refer to the immediate parent class of the class in which it is used. It is typically used to access methods or fields of the parent class that have been overridden in the child class.

For example, consider the following class hierarchy:

Copy code
class A {
    public int x = 5;
}

class B extends A {
    public int x = 10;
}
In this example, class B extends class A, and has a field x that overrides the field of the same name in class A. If we have an instance of class B, we can use the x field to access the value defined in class B, but if we want to access the value defined in class A, we can use the super keyword, like so:

Copy code
B b = new B();
System.out.println(b.x); // prints 10
System.out.println(b.super.x); // prints 5
In addition to referring to the parent class, the super keyword can also be used to invoke methods of the parent

____ ____ _____ ______ ______ ___ ______.
___ ________ ______ ___ ___ ________ ____ _______ ___ ___ ____ _______.
__________ _______ ___ __________ ___ _______ ________ _______ __________ _______ _______ ______.
__________ _________ _________ ______ ____ ____ ___ ________ _____.
__________ _________ __________ _______ ___ _______ ____ _______ ___ ____ _________ __________.
___ _____ _______ ____ ______ _______ ____ _______ ___.
_____ _________ ___ ________ ______ _______ ______.
_____ ________ ________ _____ ________ ________ ___.
_________ _________ __________ ____ __________ _______ ____ __________ ____ ______ _______.
____ ___ _________ ____ _____ __________ ____ ______.
____ ___ ______ ________ ____ _____.
_________ ___ ____ _________ ________ _________ ___.
_________ ______ ________ _________ _______ ___.
__________ ______ ___ ____ __________ _______ _____ ___ _____ _______ ____ _____.
______ _____ _________ ______ ______ ______ ________ _____ _______ __________ _________.
_________ ______ _____ ______ _____ ___.
_______ _________ _____ ____ ___ __________.
_________ _______ ______ ______ ________.
_____ ______ ____ ___ ____ _________ _______ _______ _______ _______ ____ ___.
___ ________ ________ ___ __________ ________ _______ __________ ________ _____ ___.
___ ______ ___ ______ ____.
______ _____ ___ ______ ____.
________ _______ _______ ________ ____ _________ _____ ____ ________ ___ ______.
___ ______ _____ _____ ____ _____ ___ _______ ________ __________ ____.
___ ___ ___ ______ _______ ____ _________ ______ ___ _______.
________ _____ ________ ___ _________ _________.
___ ___ __________ __________ __________ ____ _______.
_________ _______ ____ _______ ______ _______ ____.
________ __________ ______ ____ ________ _____ ____ _______ ____ ______ ___ _____.
______ _______ ____ __________ _____ _________ ______ ________ ________ __________ ______.
___ ____ ________ _________ _____ ______ _________ ________ _____.
____ ______ ________ _________ _________ ________ ________ _________ _________ ___ _________ _____.
_______ __________ ______ ______ ______ _____ ______ _________ ____ ________ _________.
______ _______ _________ _______ _________.
______ _______ ________ ____ _________ __________ ______ _________ ___ __________ _________.
_____ ___ _____ _______ ___ _________ _________.
______ __________ _____ ____ __________ _____ ____ ________ _________ _______.
__________ ____ ____ ______ ____.
___ ___ ____ _____ __________ _____ ____ _______ _____ _________ __________.
_______ _____ _____ ________ __________.
___ _________ ________.
IGNOU ACADEMY
Your IGNOU journey, made easier.
  • Solved Assignments
  • Study Notes
  • Guess Papers
  • Question Papers
Skip in 10
Top
📞
Call Support Instant phone assistance IGNOU MCS 24 2022 2023 - Explain use of super and final keywords in java. | IGNOU Academy
→
🟢
WhatsApp Chat Fast live messaging
→
Email Us Business enquiries & support
→