Java Polymorphism MCQ - Multiple Choice Questions And Answers
Q. What is polymorphism in Java?
A. The ability of a method to do different things based on the object it is acting uponB. The process of creating multiple instances of a class
C. The ability to inherit properties from multiple classes
D. The process of converting primitive data types into objects
Q. Which type of polymorphism is achieved through method overriding in Java?
A. Compile-time polymorphismB. Runtime polymorphism
C. Static polymorphism
D. Dynamic polymorphism
Q. Can objects of different classes within the same inheritance hierarchy be used interchangeably in Java?
A. Yes, alwaysB. No, never
C. Only if they have a common superclass
D. Only if they have a common subclass
Q. What is method overloading in Java?
A. The process of creating multiple methods with the same name but different parametersB. The process of creating multiple instances of a class
C. The ability to inherit properties from multiple classes
D. The process of converting primitive data types into objects
Q. Which keyword is used to achieve method overriding in Java?
A. extendB. super
C. this
D. @Override
Q. What is the purpose of the super keyword in Java?
A. To call methods in the superclassB. To restrict access to certain methods
C. To define a new class
D. To create an instance of a class
Q. Can a subclass reference be used to access superclass-specific members in Java?
A. Yes, alwaysB. No, never
C. Only if the members are static
D. Only if the subclass overrides the members
Q. Which type of polymorphism is achieved through method overloading in Java?
A. Compile-time polymorphismB. Runtime polymorphism
C. Static polymorphism
D. Dynamic polymorphism
Q. What is the purpose of the Predicate functional interface in Java 8?
A. To produce resultsB. To consume values
C. To filter elements based on a condition
D. To transform values
Q. What is method hiding in Java?
A. The process of making a method private in a subclassB. The process of changing the return type of a method in a subclass
C. The process of overriding a static method in a superclass
D. The process of overriding a non-static method in a superclass
Q. Can a subclass override a private method of its superclass in Java?
A. Yes, alwaysB. No, never
C. Only if the superclass is abstract
D. Only if the subclasses are in the same package as the superclass
Q. Which keyword is used to prevent a class from being subclassed in Java?
A. finalB. abstract
C. static
D. private