Search Tutorials


Java Polymorphism MCQ Questions And Answers | JavaInUse

Java Polymorphism MCQ Questions And Answers

Q. What is polymorphism in Java?

A. The ability of a subclass to inherit from multiple superclasses
B. The ability of a subclass to override a superclass method
C. The ability of an object to take on multiple forms
D. The ability of an object to create multiple instances

Q. Which type of polymorphism is achieved through method overriding in Java?

A. Compile-time polymorphism
B. Run-time polymorphism
C. Static polymorphism
D. Dynamic polymorphism

Q. What is method overloading in Java?

A. Creating multiple methods with the same name in a class
B. Creating methods with different names in a class
C. Creating methods with the same name but different parameter lists in a class
D. Creating methods with the same name and same parameter lists in a class

Q. What is the superclass reference variable behavior in polymorphism?

A. It only refers to methods and fields of the superclass
B. It can refer to methods and fields of both the superclass and the subclass
C. It can only refer to methods and fields of the subclass
D. It can only refer to static methods and fields

Q. Can an overridden method in Java have a different return type than the original method?

A. Yes, as long as the return type is a subclass of the original return type
B. Yes, as long as the return type is a superclass of the original return type
C. No, the return type must be the same as the original method
D. No, the return type is irrelevant in method overriding

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

A. final
B. abstract
C. override
D. super

Q. Which of the following is an example of compile-time polymorphism in Java?

A. Method overriding
B. Method overloading
C. Dynamic method binding
D. Virtual function

Q. Can constructors be overloaded in Java?

A. Yes, constructors can be overloaded
B. No, constructors cannot be overloaded
C. Constructors are automatically overloaded
D. Overloading applies only to methods, not constructors

Q. What is runtime polymorphism in Java?

A. The ability of a subclass to inherit from multiple superclasses
B. The ability of a subclass to override a superclass method
C. The ability of an object to take on multiple forms
D. The ability of an object to create multiple instances

Q. Which example demonstrates method overloading in Java?

A. Having multiple methods with the same name in a class
B. Having methods with different names in a class
C. Having methods with the same name but different parameter lists in a class
D. Having methods with the same name and same parameter lists in a class





Q. What is true about Java Polymorphism?

A. Polymorphism allows methods to do different things based on the object executing the method.
B. Polymorphism is only applicable to fields in Java.
C. Polymorphism can only be achieved through method overloading.
D. Polymorphism can only be achieved through method overriding.

Q. What is the output of the following code snippet?

public class Animal {
    public void makeSound() {
        System.out.println("Some sound");
    }
}

public class Dog extends Animal {
    public void makeSound() {
        System.out.println("Bark");
    }
}

public class Main {
    public static void main(String[] args) {
        Animal myDog = new Dog();
        myDog.makeSound();
    }
}
A. Some sound
B. Bark
C. Compilation error
D. Runtime error

Q. What is the correct way to achieve method overloading in Java?

A. Having two methods with the same name and parameters in the same class.
B. Having two methods with the same name but different parameters in the same class.
C. Having two methods with different names in the same class.
D. Having different return types for the same method in the same class.

Q. Which of the following is an example of compile-time polymorphism in Java?

A. Method Overriding
B. Method Overloading
C. Inheritance
D. Interface

Q. What happens when a subclass overrides a method from its superclass in Java?

A. The subclass method cannot have a different name from the superclass method.
B. The subclass method must have a different return type from the superclass method.
C. The subclass method completely replaces the superclass method when called on an instance of the subclass.
D. The superclass method is called when the method is called on an instance of the subclass.