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

Home > Java Programming > Variables and Loops > Questions and Answers

Q: What happens when the following code is compiled and run.

Select the one correct answer.
for(int i = 2; i < 4; i++)
for(int j = 2; j < 4; j++)
assert i!=j : i;
A. The class compiles and runs, but does not print anything. B. The number 2 gets printed with AssertionError
C. compile error D. The number 3 gets printed with AssertionError

Answer and Explanation

Answer:The number 2 gets printed with AssertionError

Explanation:
When i and j are both 2, assert condition is false, and AssertionError gets generated. .

Comment on this Question

Name:

Loading...




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