Menu
Topics Index
...
`

Interface


If you need explanation Read this topic

If you need Answer Take test on this topic

Interface
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 + " ");
        }
    }
}

A. 0 1 2
B. 1 2 3
C. 0 1 2 3
D. 1 2 3 4
E. Compilation Error or Runtime Error
Topic: Creating Interface In Java With Example Program

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

E all methods declared in an interface are by default public and all variables are public static final
u cannot change value of final variable counter

Posted by Tushar Ghude    2014-07-28 14:43:42


ur ans is correct but ur explanation is not so good!@##

Posted by Shubham Bansal    2014-07-28 19:17:27


Congratulations Tushar Ghude. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-07-29 04:35:43


© meritcampus 2019

All Rights Reserved.

Open In App