40.1k views
5 votes
Which of the following is a correct statement in java?

A. apes = monkeys + gorillas
B. tigers + = 3 + tigers;
C. lions + tigers = cats;
D. zebras *= 5

1 Answer

5 votes

Final answer:

The correct Java statement is D. zebras *= 5, as it properly uses a compound assignment operator that multiplies the variable 'zebras' by 5 and reassigns the result to 'zebras'.

Step-by-step explanation:

In Java, the correct statement among the options provided is D. zebras *= 5. This is because it is the only option that uses a valid compound assignment operator correctly. The compound assignment '*=' multiplies the variable on the left by the value on the right and then assigns the result back to the variable on the left.

It is a shorthand for zebras = zebras * 5. The other options contain syntax errors or are not valid in the context of Java programming.

The correct statement in Java is option D: zebras *= 5. The * operator is used for multiplication in Java, so the statement zebras *= 5 means multiply the value of zebras by 5. This is a valid and correct statement in the Java programming language.

The correct Java statement is D. zebras *= 5, as it properly uses a compound assignment operator that multiplies the variable 'zebras' by 5 and reassigns the result to 'zebras'.

User Scottshepard
by
8.5k points