Single Choice Moderate

QWhat 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);
	}

}

ID: #20253 Assignment Operators Java 113 views
Question Info
#20253Q ID
ModerateDifficulty
Assignment Operators JavaTopic

Choose the Best Option

Click any option to instantly check if you're correct.

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

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

Challenge a friend or share with your study group.