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
(A)
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.