Sail E0 Webinar
Question


What is the output of this program?


class increment {
public static void main(String args[])
{
int g = 3;
System.out.print(++g * 8);
}
}
Options:
A .  25
B .  24
C .  32
D .  33
Answer: Option C

Operator ++ has more preference than *, thus g becomes 4 and when multiplied by 8 gives 32.
output:
$ javac increment.java
$ java increment
32



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers