MCQ Practice Single Best Answer Topic: Assignment Operators

Q What will be the output of this code

class PostAndPre
{
	public static void main( String args[])
	{
		int a = 2;
		int b = a++ - a++;
		System.out.println(b);
		System.out.println(a);
	}

}

Question ID
#20252
Subchapter
Assignment Operators
Action
Choose one option below

Choose Your Answer

Click an option to check whether your answer is correct.

  • A 1
    2
  • B -1
    4
  • C 0
    4
  • D 1
    3
Correct Answer: B

Explanation



class PostAndPre
{
	public static void main( String args[])
	{
		int a = 2;
		int b = a++ - a++;
		System.out.println(b);
		System.out.println(a);
	}

}

Share This Question

Share this MCQ with your friends or study group.