Vidyalelo
Java Programming · Q70

Data Types and Variables

Programming · Java Programming · question 70

Q70

What will be the output of the following Java code? class increment public static void main(String args[]) int g = 3; System.out.print(++g * 8);

A.
25
B.
24
C.
32
Answer
D.
33

Answer: Option C

Solution

Answer: Option C
Solution:
The given Java code initializes a variable g with the value 3. It then uses the pre-increment operator (++) on g before multiplying it by 8 and printing the result using System.out.print.

The expression ++g * 8 is evaluated as follows:

++g increments the value of g to 4.
4 * 8 is equal to 32.
Therefore, the output of the code will be 32.