Home Tutorial Java Scjp Part2 SCJP Module-2 Question-13

 
 

Share on Google+Share on Google+
SCJP Module-2 Question-13
Posted on: July 8, 2010 at 12:00 AM
Advertisement
The Program given below checks and helps the understanding of while loops in Java programming.
What would be the output after executing following code :

public class Example13 {
public static void main(String[] args) throws Exception {
int a = 30;
while (a) {
System.out.print("value:" + a--);
}
}
}

What would be the output after executing given above code :

1. Compile error

2.  30 29,.....untill 1

3.  1 2 3.....untill 30

4.  no output

Answer :

(1)

Explanation :

'While' statement should contain a 'Boolean' value ,'condition' or 'expression' , whose outcome must be of  type Boolean.

Advertisement

Related Tags for SCJP Module-2 Question-13:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 8, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com