menu

Polymorphism in Java


1. Which of the following is an example of run-time polymorphism?

Method Overloading

Method Overriding

Both A and B

None of the above


2. Which of the following is an example of method overloading?

void print(int a, int b)

int print(int a, int b)

void print(String s)

None of the above


3. Which of the following is not a type of polymorphism?

Compile-time Polymorphism

Run-time Polymorphism

Inheritance Polymorphism

None of the above


4. Which keyword is used to implement method overriding in Java?

override

super

final

extends


5. Which of the following is a benefit of polymorphism in Java?

Code reusability

Improved performance

Strong typing

None of the above


6. Which of the following is an example of method overriding?

void print(int a, int b)

int print(int a, int b)

void print(String s)

void print()


7. Which of the following is an example of dynamic method dispatch?

Animal animal = new Animal();

Animal animal = new Dog();

Dog dog = new Animal();

None of the above


8. Which of the following is true about the instanceof operator?

It is used to check if an object is an instance of a specific class or interface

It can be used with primitive data types

It can be used to compare two objects for equality

None of the above


9. Which of the following is an example of run-time polymorphism?

Method overloading

Method overriding

Operator overloading

None of the above


10. Which keyword is used to implement method overriding in Java?

super

this

override

None of the above