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

 
 

SCJP Module-1 Question-28
Posted on: July 21, 2010 at 12:00 AM
Advertisement
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)

Advertisement

Related Tags for SCJP Module-1 Question-28:


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

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com