Menu
Question Index
...

What will be the output of the following program?

public class ClassA {
    public static void main(String[] args) {
        ClassA.methodFour(3 * 3);
        ClassB.methodFour(1 + 5);
    }
    public void methodOne(int i) {
        methodTwo(1 * 2);
        System.out.print(i + ", ");
    }
    public void methodTwo(int i) {
        methodThree(i + i);
        System.out.print(i + ", ");
    }
    public void methodThree(int i) {    System.out.print(i + ", ");    }
    public static void methodFour(int i) {
        ClassB.methodFour(i * 02);
        System.out.print(i + ", ");
    }
}
class ClassB extends ClassA {
    public void methodOne(int i) {
        super.methodFour(0);
        System.out.print(i + ", ");
    }
    public void methodTwo(int i) {    System.out.print(i + ", ");    }
    public void methodThree(int i) {    System.out.print(i + ", ");    }
    public static void methodFour(int i) {    System.out.print(i + ", ");    }
}


18, 9, 6,
18, 18, 6, 4, 2, 0, 0, 0, 0  
18, 18, 6, 4, 4, 4, 0, 0, 0
Some other output
Goes into infinite loop
Compilation Error or Runtime Error

Doubts

Problems

Topic: Unknown

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App