0 votes
106 views
in JAVA by (98.9k points)
edited by

What will be the output of the following Java code?

 

  1. class increment {
  2.         public static void main(String args[]) 
  3.         {        
  4.              int g = 3;
  5.              System.out.print(++g * 8);
  6.         } 
  7.     }

a) 32
b) 33
c) 24
d) 25

1 Answer

0 votes
by (98.9k points)
edited
Answer: a
Explanation: Operator ++ has more preference than *, thus g becomes 4 and when multiplied by 8 gives 32.

Related questions

0 votes
1 answer 160 views
asked Jul 20, 2022 in JAVA by Doubtly (98.9k points)
0 votes
1 answer 166 views
asked Jul 20, 2022 in JAVA by Doubtly (98.9k points)
0 votes
0 answers 118 views
asked Aug 9, 2022 in JAVA by Doubtly (98.9k points)
0 votes
1 answer 291 views

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

561 users

...