1.

What is the output of this program?interface Calculation { int var = 0; void calculate(int num); } class display implements Calculation { int p; public void calculate(int num) { if (num<2) { p = var; } else { p = num * num; } } } public class interfaces_Example { public static void main(String args[]) { display[] array = new display[4]; for(int k=0; k<4; k++) array[k] = new display(); array[0].calculate(0); array[1].calculate(2); array[2].calculate(4); System.out.print(array[0].p+" " + array[1].p + " " + array[2].p); } }

A. 0 4 16
B. 4 0 16
C. 16 0 4
D. Compilation Error
E. Runtime Error
Answer» B. 4 0 16


Discussion

No Comment Found

Related MCQs