What are four valid examples of polymorphic method calls? (Choose four.)

Given:

abstract class A {
abstract void a1();

void a2() {
}
}

class B extends A {
void a1() {
}

void a2() {
}
}

class C extends B {
void c1() {
}
}

And:

A x = new B();
C y = new C();
A z = new C();

What are four valid examples of polymorphic method calls? (Choose four.)

Given:

abstract class A {
abstract void a1();

void a2() {
}
}

class B extends A {
void a1() {
}

void a2() {
}
}

class C extends B {
void c1() {
}
}

And:

A x = new B();
C y = new C();
A z = new C();

What are four valid examples of polymorphic method calls? (Choose four.)

A.
x.a2();

B.
z.a2();

C.
z.c1();

D.
z.a1();

E.
y.c1();

F.
x.a1();

Explanation:
A: x.a2(); // Method is overriden.
B: z.a2(); // Method is inherited.
C: z.c1(); // Won’t compile. Method isn’t defined in A.
D: z.a1(); // Method is implemented.
E: y.c1(); // Not polymorphic. Method is defined in declared class C.
F: x.a1(); // Method is implemented.



Leave a Reply 1

Your email address will not be published. Required fields are marked *