Polymorphism in Java
Polymorphism in Java - Important Points
6. | Which of the following is an example of downcasting? |
---|
A. Animal animal = new Dog();
B. Dog dog = new Animal();
C. Animal animal = new Animal();
D. Dog dog = (Dog) animal;
View Answer Discuss Work SpaceAnswer: option d
Explanation:
7. | Which of the following is true about method overloading? |
---|
A. The method name must be the same but the parameter list must be different.
B. The method name and parameter list must be the same but the return type can be different.
C. The method name and parameter list must be the same but the access modifiers can be different.
D. None of the above
View Answer Discuss Work SpaceAnswer: option a
Explanation:
8. | Which of the following is true about method overriding? |
---|
A. The method name must be the same but the parameter list must be different.
B. The method name and parameter list must be the same but the return type can be different.
C. The method name and parameter list must be the same but the access modifiers can be different.
D. None of the above
View Answer Discuss Work SpaceAnswer: option b
Explanation:
9. | Which of the following is an example of dynamic method dispatch? |
---|
A. Animal animal = new Animal();
B. Animal animal = new Dog();
C. Dog dog = new Animal();
D. None of the above
View Answer Discuss Work SpaceAnswer: option b
Explanation:
10. | Which of the following is not a type of polymorphism? |
---|
A. Compile-time Polymorphism
B. Run-time Polymorphism
C. Inheritance Polymorphism
D. None of the above
View Answer Discuss Work SpaceAnswer: option c
Explanation: