Single Choice Moderate

QWhat will be the output of this code

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

	}

}

ID: #20254 Assignment Operators Java 110 views
Question Info
#20254Q ID
ModerateDifficulty
Assignment Operators JavaTopic

Choose the Best Option

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

  • A -1 Now a = 3
  • B -1 Now a = 4
  • C 1 Now a = 4
  • D -1 Now a = 5
Correct Answer

Explanation


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

	}

}

-1 Now a = 4

Share This Question

Challenge a friend or share with your study group.