The ability of an object to take on many forms.
Polymorphism
What is the most common use of polymorphism in OOP?
When a parent class reference is used to refer to a child class object.
What Java object is considered to be polymorphic?
Any Java object that can pass more than one IS-A test
In Java, are all Java Objects polymorphic? If so, why?
Yes, since any object will pass the IS-A test for their own type and for the class Object.
If a class has multiple methods having same name but different in parameters
Method Overloading
What increases the readability of the program if we have to perform only one operation?
Having same name of the methods
What are the two ways to overload a method in Java?
- By changing number of arguments
- By changing the data type
If subclass (child class) has the same method as declared in the parent class, it is known as what?
Method Overriding
Method overriding is used for runtime - ?
Polymorphism
Method overriding is used to provide the specific implementation of a method which is already provided by its - ?
Superclass
Rules for Method Overriding:
The method must have the same name as in the - ?
Parent Class
Rules for Method Overriding:
The method must have the same - as in the parent class.
Parameter
Rules for Method Overriding:
There must be a - Relationship (Inheritance)
IS-A
Can a static method be overridden?
No, a static method cannot be overridden. It can be proved by runtime polymorphism