public class Test { public static void main(String [] args) { int A = 10; System.out.println(A); A = A + 1; } } |
public class Test { public static void main(String [] args) { int A = 10; A = A + 1; System.out.println(A); } } |
After you run the above program,
10 will be on the screen. 11 is in memory box A, which you could not see. |
After you run the above program,
11 is in memory box A, which you could not see. 11 will be on the screen. |
The following statements take the same actions.
public class Test { public static void main(String [] args) { int A = 10; A = A + 1; System.out.println(A); } } |
public class Test { public static void main(String [] args) { int A = 10; A++; System.out.println(A); } } |
public class Test { public static void main(String [] args) { int A = 10; ++A; System.out.println(A); } } |
However, the short cut of two statements perform differently.
public class Test { public static void main(String [] args) { int A = 10; System.out.println(A++); } } //combine two statements |
public class Test { public static void main(String [] args) { int A = 10; System.out.println(++A); } } //combine two statements |
public class Test { public static void main(String [] args) { int A = 10; System.out.println(A); A = A + 1; } } |
public class Test { public static void main(String [] args) { int A = 10; A = A + 1; System.out.println(A); } } |
What are output of the following two sets of programs?
public class Test { public static void main(String [] args) { int A = 10; int B = 5; System.out.println(A++-B); } } |
public class
Test { public static void main(String [] args) { int A = 10; int B = 5; System.out.println(++A-B); } } |