Polymorphism Online Quiz (Multiple Choice Questions and Answers)

In this post, I will be sharing Polymorphism online quiz - multiple choice questions and answers. Please make sure to go through what is Polymorphism, real-life examples, and different types of Polymorphism article before attempting to answer the below set of questions.

Read Also: OOPs Interview Questions and Answers

Polymorphism Online Quiz - Multiple Choice Questions and Answers (MCQ)

1. How Polymorphism is achieved in Java

a. Overloading

b. Overriding

c. Static Function

d. Final Class

The correct answers are A and B.


2. Which statements are true

a. Overriding can be achieved with static methods

b. Final marked methods can be overridden

c. Overloading is runtime.

d. Return type can change in case of Overloading.

The correct answer is D.



3. Which statements are true

a. Parent class method method1 return type is Class A and child class of Parent class overrides the method method1 and can change the return type from Class A to Class B (B is the subclass of A)

b. Child class can use covariant return types in case of method overriding.

c. Covariant return types can be used in case of method overloading

d. Method parameters sequence can change in overriding.

The correct answers are A, B, and C.



4. Output of this program is :
 public class PolymorphismDemoClass {
    void add(int x, int y){
        System.out.println("1. Addition is: " +(x+y));
    }
    void add(int y, int x){
        System.out.println("2. Addition is: " +(x+y));
    }
    public static void main(String[] args){
        PolymorphismDemoClass obj = new PolymorphismDemoClass();
        obj.add(20, 30);
    }
}

a. Prints 2. Addition of two numbers: 50

b. Prints 1. Addition of two numbers: 50

c. Compile time error

d. Runtime error

The correct answer is C.



5. Output of this program is :
 public class PolymorphismDemoClass2 {
    void m1(String x){
        System.out.println("One");
    }
    protected void m1(String x, String y){
        System.out.println("Two");
    }
    public static void main(String[] args){
        PolymorphismDemoClass2 obj = new PolymorphismDemoClass2();
        obj.m1("ABC");
        obj.m1("PQR", "XYZ");
    }
}

a. Two One

b. One Two

c. Compile time error

d. Runtime error

The correct answer is B.


6. Which statements are true

a. In case of overloading, binding of objects with methods happens at runtime.

b. In the case of Dynamic polymorphism, method behavior is decided at runtime.

c. In the case of Overriding, the creation of objects happen at compile time and these objects are used for calling objects at runtime.

d. In the case of Overriding, it is the responsibility of the compiler to bind the method calls with the method body.

The correct answer is B.



7. Which statements are true

a. Overriding can only be achieved when there is a has-a relationship

b. Data members can be used in Polymorphism

c. In case of overloading, it's the responsibility of the compiler to bind the method calls with the method body based on method signatures.

d. Constructor overloading is static Polymorphism

The correct answers are C and D.


8. Output of this program is :
 class PolymorphismDemoClass {
    void m1(String x) {
        System.out.println("One");
    }
}
class PolymorphismDemoClassChild extends PolymorphismDemoClass {
    public void m1(String x) {
        System.out.println("Two");
        super.m1(null);
    }
}
public class Test {
    public static void main(String[] args){
        PolymorphismDemoClass obj = new PolymorphismDemoClassChild();
        obj.m1(null);
    }
}

a. Output is : Two, One

a. Output is : One, Two

c. Compile time error

d Runtime error

The correct answer is A.



9. Which statements are true

a. There are 3 types of binding in java early(Overloading), intermediate(methods which are neither overloaded nor overridden), late(Overriding)

b. Performance of early binding is better compared to late binding

c. Private methods always fall in the early binding category.

d. Static method falls in the dynamic binding category

The correct answers are B and C.



10. Which statements are true

a. Parent p = new Child();//upcasting declaration

b. Child c = new Parent();// downcasting declaration

c. List<Parent> list = new ArrayList<>(); list.add(new Child());

d. List<Child> list = new ArrayList<>(); list.add(new Parent());

The correct answers are A and C.



11. Which statements are true

a. We can override Constructors

b. We can override static methods

c. We can overload abstract methods

d. We can overload final methods

The correct answers are C and D.


12. Which statements are true

a. Same method names and same method signature is called Overriding

b. Same method names and same method signature just changing the return type is called Overloading

c. Method signature includes return type, number of arguments, arguments type, and arguments sequence only and nothing else

d. Unchecked exceptions are part of the method signature

The correct answer is A.


That's all for today. Please mention in the comments if you have faced any other Polymorphism online quiz MCQ question that needs to be added to the above list.

About The Author

Subham Mittal has worked in Oracle for 3 years.
Enjoyed this post? Never miss out on future posts by subscribing JavaHungry