Sail E0 Webinar
Question


What is the output of this program?


class operators {
public static void main(String args[])
{
int x = 8;
System.out.println(++x * 3 + " " + x);
}
}
Options:
A .  24 8
B .  24 9
C .  27 8
D .  27 9
Answer: Option D

Operator ++ has higher precedence than multiplication operator, *, x is incremented to 9 than

multiplied with 3 giving 27.
output:
$ javac operators.java
$ java operators
27 9



Was this answer helpful ?
Next Question

Submit Solution

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

Latest Videos

Latest Test Papers