A

Admin • 828.03K Points
Coach

Q. Determine output:

Code:
public class Test{
static int i = 5;
public static void main(String... args){
System.out.println(i++);
System.out.println(i);
System.out.println(++i);
System.out.println(++i+i++);
}
}
  • (A) 6 6 6 16
  • (B) 6 7 6 16
  • (C) 5 6 7 16
  • (D) 5 6 7 16D.5 6 6 16
  • Correct Answer - Option(C)
  • Views: 14
  • Filed under category Java
  • Hashtags:

Explanation by: Admin
i++ : print value then increment (postfix - increment happens after the value of the variable is used) ++i : increment the print (prefix - increment happens before the value of the variable is used).

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.