Home Tutorial Java Scjp Part1 SCJP Module-1 Question-2

 
 

Share on Google+Share on Google+
SCJP Module-1 Question-2
Posted on: July 5, 2010 at 12:00 AM
Advertisement
This program will trace your knowledge of Java, and helps in preparation for SCJP examination.

What is the output of the following code when compiled and run?

1. public class Question2 {
2. public static void main(String[] args){
3. int x,y,z;
4. y=1;
5. x=z=1;
6. System.out.println(y+","+x+","+z);
}
}

Select correct answers

(1) Prints 1,1,1
(2) Error during compilation at line 3
(3) Prints 0,0,1
(4) Error during compilation at line 5
(5) Error during compilation at line 6

Answer-2

(1)

Explanation:

It will print 1,1,1. Writing operator + to the suffix of variable wont generate any error and also not increment the value of variables.

Advertisement

Related Tags for SCJP Module-1 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 5, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com