SCJP Module-1 Question-28


 

SCJP Module-1 Question-28

The Sample program given below will test your understanding about the Java program logic.

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)

Ads