ODNYX.
Tutorials
Java
CSS
Database
DevOps
Spring
Design Patterns
References
Subscribe
Java
CSS
Database
DevOps
Spring
Design Patterns
Runtime Polymorphism — Quick Check
1. What allows runtime polymorphism to work in Java?
Method overloading
Method overriding
Using the same variable name twice
Declaring a variable as final
2. In `Animal myPet = new Dog(); myPet.makeSound();`, which version of makeSound() runs?
Animal's version, because myPet is declared as Animal
Dog's version, because that's the actual object type at runtime
Neither — this causes a compile error
Both versions run, one after another
Check answers
❮ Home
Next: Object-Oriented Programming Interview Questions ❯