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

 
 

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

Given a sample code:

1    public class Sample{
2    public static void main(String args[]) {
3    int i = 1, j = 2;
4    i++;
5    j--;
6    if (i / j > 1)
7    i++;
8    System.out.println(i + j);
}}

What will be the result of above code ?

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

Answer:

(3)

Advertisement

Related Tags for SCJP Module-5 Question-2:


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