Question
class increment {
public static void main(String args[])
{
int g = 3;
System.out.print(++g * 8);
}
}
What is the output of this program?
class increment {
public static void main(String args[])
{
int g = 3;
System.out.print(++g * 8);
}
}
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 ?
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 ?
More Questions on This Topic :
Question 8.
Which of these statements are incorrect?
....
Question 9.
Which of these statements are incorrect?
....
Submit Solution