Core Java Interview Questions-Polymorphism

This Core Java Interview Questions-Polymorphism page provides all the interview questions about polymorphism in java including method overloading, method overriding, main method overloading, constructor overloading, constructor overriding, compile-time binding, run-time binding, object casting, object up casting an object downcasting in java.


What is Polymorphism?
Defining an object(class) that shows different behavior(methods) with the same name.


What is method overloading?
Defining a method more than one time with the same name but with different signature inside same
class.


Can we overload constructor?
Yes, we can overload the constructor.
for example constructor chaining.


Can we overload the main method?
yes, we can overload the main method with the different signature. But JVM invokes standard main() only.


Can we implement method overloading in a single class?
Method overloading belongs to one object hence we can implement in single class.


What is compile-time binding?
The compiler can connect the desired method to execute depends on the method call.


What is Dynamic binding?
The compiler cannot understand the exact method to bind up in the hierarchy. Hence it binds up with the top class
in the hierarchy.


What is method overriding?
Defining a method in the child class with the same name and same signature of its parent class
method.


Can we override static method?
No static method is coming under common functionality. Only non-static methods can be overridden.


When we override the method?
To update the existing object functionality in the child class if it is not sufficient to child class object.


What is Object Up casting?
Storing child class object address into Parent type variables is called object up casting.
Upcasting is implicit in java.


What is the advantage of Dynamic binding?
Accessing child object functionality using its Parent reference.


Can we implement Run time polymorphism in a single class?
No, runtime binding can be implemented only in IS-A relation.


Can we achieve run time binding using abstract classes and interfaces?
Yes, we can connect classes(refer objects) using specifications(abstract methods) also. Hence it is
possible ti achieves runtime binding using abstract classes and interfaces.


What is Object Down casting?
Trying to store Parent type reference variable into Child type is called down casting.
Down casting is explicit in java application.


>Core Java Interview Questions-Exception Handling<

Share this