Menu
Topics Index
...
`

Assert


If you need explanation Read this topic

If you need Answer Take test on this topic

Assert
What will be the output of the following program?
public class ProjectWork {
    public static void main(String[] args) {
        Project();
        Work();
    }
    protected static void Project() {
        assert false;
        assert false;
    }
    private static void Work() {
        assert true;
        int i = 0;
        while(assert){
            assert false;
            i++;
        }
        System.out.print("i = " + i);
        assert false;
    }
}

A. i = 0
B. i = 1
C. i = 2
D. Some other output
E. Compilation Error or Runtime Error
Topic: Other Advanced Topics In Java

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.

ans is: E, because assert is keyword, and it may not be used as an identifier in while loop..

Posted by Mallikarjuna Rao    2013-12-30 04:44:51


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

Posted by Merit Campus    2013-12-31 03:46:20


© meritcampus 2019

All Rights Reserved.

Open In App