Welcome Guest | Sign in | Register
Assertions - Discussion Page For Q.2535 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Assertions > Questions and Answers

Q:
What happens when the following code is compiled and run. Select the one correct answer.
for(int i = 1; i < 3; i++)
for(int j = 3; j > i; j--)
assert i!=j {System.out.println(i); }



A. The class compiles and runs, but does not print anything.
B. The number 1 gets printed with AssertionError
C. The number 2 gets printed with AssertionError
D. The number 3 gets printed with AssertionError
E. The program generates a compilation error. 
A. A B. B
C. C D. D
E. E

Answer and Explanation

Answer:E

Explanation:
The condition in assert statement must be followed by a semi-colon.

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.