You are not logged in.

#1 2016-11-09 06:18:01

Muhammad
User RankUser RankUser RankUser RankUser RankUser Rank
بِسمِ اللَّهِ الرَّحمٰنِ الرَّحيمِ
From: Sahiwal Division
Registered: 2012-03-22
Posts: 22,197
Website

Sun Certified Java Programmer (SCJP) Quiz Question.

Java Quizzes Sun Certified Java Programmer (SCJP)

Question:
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;

Options are

Option A):
compile error
Option B):
The number 3 gets printed with AssertionError
Option C):
The class compiles and runs, but does not print anything.
Option D):
The number 2 gets printed with AssertionError

Correct Answer is Option D):
The number 2 gets printed with AssertionError

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


Online Web Tutorials And Interview Questions With Answers Forum:
https://globalguideline.com/forum/

2016-11-09 06:18:01

Advertisement
Ads By Google

Re: Sun Certified Java Programmer (SCJP) Quiz Question.



\n

Board footer