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

 
 

SCJP Module-1 Question-28
Posted on: July 21, 2010 at 12:00 AM
The Sample program given below will test your understanding about the Java program logic.

Given a sample code:

class Test1 {
public static void main(String[] args) {
int x = 1;
Test1 p = new Test1();
p.plusX(x);
System.out.print(" main x = " + ++x);
}

void plusX(int x) {
System.out.print(" plusX x = " + x++);
}
}

What will be the result? Choose the correct option?

(A) plusX x = 1 main x = 2
(B) plusX x = 2 main x = 2
(C) plusX x = 2 main x = 1
(D) plusX x = 1 main x = 1

Answer:

(A)

Related Tags for SCJP Module-1 Question-28:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.