menu

Polymorphism in Java

Polymorphism in Java - Important Points


1.

What is polymorphism in Java?

A. It is the ability of an object to take on many forms

B. It is the ability to define multiple methods with the same name but different signatures

C. It is the ability of an object to hide its implementation details

D. None of the above

Discuss Work Space

Answer: option a

Explanation:

Polymorphism in Java refers to the ability of an object to take on many forms. This allows objects to be treated as if they are of a more general type, which makes it possible to write more flexible and reusable code.


2. Which of the following is an example of compile-time polymorphism?

A. Method Overloading

B. Method Overriding

C. Both A and B

D. None of the above

Discuss Work Space

Answer: option a

Explanation:

Compile-time polymorphism is achieved through method overloading, where multiple methods with the same name but different parameter types or numbers are defined in a class.

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

A. Method Overloading

B. Method Overriding

C. Both A and B

D. None of the above

Discuss Work Space

Answer: option b

Explanation:

Run-time polymorphism is achieved through method overriding, where a subclass provides its own implementation of a method that is already provided by its parent class.

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

A. override

B. super

C. final

D. extends

Discuss Work Space

Answer: option a

Explanation:

The keyword "override" is used to indicate that a method in a subclass is intended to override a method with the same name and parameters in its parent class.

5. Which of the following is an example of upcasting?

A. Animal animal = new Dog();

B. Dog dog = new Animal();

C. Animal animal = new Animal();

D. None of the above

Discuss Work Space

Answer: option a

Explanation:

Upcasting is the process of converting an object of a subclass to its parent class. In this example, a Dog object is upcasted to an Animal object.


Subscribe for Latest Career Trends
Subscribe Now
Use AI and ChatGPT for Career Guidance

Unlock Your Future

Join Now
Worried for Placements in 2024?

Join FAST TRACK Course

Join Now
Supercharge Your SUCCESS

Join All in One Placement Mock Tests-2024

Join Now