Govt Exams
Polymorphism allows objects to be treated as instances of their parent class and to call methods that are overridden in child classes. It includes method overloading and method overriding.
'this' is a reference to the current object instance, while 'super' is a reference to the parent class object. They are used to access members of current and parent classes respectively.
Constructor overloading is allowed in Java. A class can have multiple constructors with different parameter lists. Constructors don't have return types and can have any access modifier.
The 'instanceof' operator is used to test if an object is an instance of a specified class, subclass, or interface. It returns a boolean value.
Encapsulation is the bundling of data and methods into a single unit (class) while hiding internal implementation details using access modifiers.
Method overriding occurs when a child class provides a specific implementation of a method already defined in the parent class with the same signature. The @Override annotation is optional but recommended.
'super' is used to refer to parent class methods, constructors, and variables. It helps in accessing hidden or overridden members of the parent class.
Java supports single inheritance for classes but a class can implement multiple interfaces. An interface can extend multiple interfaces through multiple inheritance.
The 'final' keyword when applied to a reference variable makes it immutable, meaning it cannot be reassigned to point to another object.
The 'private' access modifier restricts access to only within the same class. It provides the highest level of encapsulation.