Home Tutorial Java Scjp Part5 SCJP Module-5 Question-5

 
 

Share on Google+Share on Google+
SCJP Module-5 Question-5
Posted on: July 12, 2010 at 12:00 AM
Advertisement
The program given below will test your understanding of do while loop and basic flow of Java program.

Given a sample code:

1    public class Test {
2    public static void main(String args[]) {
3    int j;
4    do {
5    j++;
6       }
7    while(j < 0);
8    System.out.println(j);
}}

What will be the result of above code ?

(1) The program compilation fails because of line number 3.
(2) 1
(3) 3
(4) The program compilation fails because of line number 5.

Answer:

(4)

Explanation:

This program will have compile time error that variable j might not have been initialized.

Advertisement

Related Tags for SCJP Module-5 Question-5:


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 12, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com