Multiple choice technology programming languages

Given: 10. abstract class A { 11. abstract void al(); 12. void a2() { } 13. } 14. class B extends A { 15. void a1() { } 16. void a2() { } 17. } 18. class C extends B { void c1() { } } and: A x = new B(); C y = new C(); A z = new C(); Which four are valid examples of polymorphic method calls? (Choose four.)

  1. x.a2();

  2. z.a2();

  3. z.c1();

  4. z.a1();

  5. y.c1();

  6. x.a1();

Reveal answer Fill a bubble to check yourself
A,B,D,F Correct answer
Explanation

Polymorphic method calls work when the reference type has the method and the actual object's class overrides it. x.a2() and z.a2() are polymorphic - A declares a2(), B overrides it, and x/z reference B/C objects. x.a1() and z.a1() are polymorphic - A declares abstract a1(), B/C implement it. z.c1() and y.c1() are NOT polymorphic - reference type C has c1(), but reference z is type A (which doesn't have c1()), and y.c1() is just a normal call on C reference, not polymorphic.