Question: Given the following Java classes, which method m will be executed -x-x-x public interface ITest { public void m(); } -x-x-x- public class Client {
Given the following Java classes, which method m will be executed -x-x-x public interface ITest { public void m(); } -x-x-x- public class Client { public void testM(ITest i){ i.m(); } public static void main(String[] args){ A a = new B(); Client c = new Client(); c.testM(a); } } -x-x-x-x-x class A implements ITest { public void m() {...}; } -x-x-x- class B extends A implements ITest{ public void m() {...}; } -x-x-x-
a. Since B is a sub-class A, method m belonging to class B will be executed after method m belong to class A is executed. Super class methods are always executed first.
b. All other answers are wrong
c. Method m belonging to class B will be executed
. d. Since B is a sub-class A, method m belonging to class A will be executed after method m belong to class B is executed.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
