Solved

Consider the Following Code Snippet

Question 23

Multiple Choice

Consider the following code snippet. What is the potential problem with the if statement?
Double average;
Average = (g1 + g2 + g3 + g4) / 4.0;
If (average == 90.0)
{
System.out.println("You earned an A in the class!") ;
}


A) Using == to test the double variable average for equality is error-prone.
B) The conditional will not evaluate to a Boolean value.
C) The assignment operator should not be used within an if-statement conditional.
D) Literals should never be used in if statement conditionals.

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents