Menu
Question Index
...

What will be the output of the following program?

interface Count {
    short counter = 0;
    void countUp();
}
public class History implements Count {
    public static void main(String[] args) {
        History t = new History();
        t.countUp();
    }
    public void countUp() {
        for (int x = 6; x > counter; x--, ++counter) {
            System.out.print(counter + " ");
        }
    }
}


0 1 2
1 2 3
0 1 2 3
1 2 3 4
Compilation Error or Runtime Error

Doubts

Problems

Topic: Creating Interface In Java With Example Program

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App