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
View Answer Discuss Work SpaceAnswer: 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
View Answer Discuss Work SpaceAnswer: option a
Explanation:
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
View Answer Discuss Work SpaceAnswer: option b
Explanation:
4. | Which keyword is used to implement method overriding in Java? |
---|
A. override
B. super
C. final
D. extends
View Answer Discuss Work SpaceAnswer: option a
Explanation:
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
View Answer Discuss Work SpaceAnswer: option a
Explanation: