What is output by the following Java code segment? int temp = 180;
While ( temp != 80 )
{
If ( temp > 90 )
{
System.out.print( "This porridge is too hot! " ) ;
// cool down
Temp = temp - ( temp > 150 ? 100 : 20 ) ;
} // end if
Else
{
If ( temp < 70 )
{
System.out.print(
"This porridge is too cold! ") ;
// warm up
Temp = temp + (temp < 50 ? 30 : 20) ;
} // end if
} // end else
} // end while
If ( temp == 80 )
System.out.println( "This porridge is just right!" ) ;
A) This porridge is too cold! This porridge is just right!
B) This porridge is too hot! This porridge is just right!
C) This porridge is just right!
D) None of the above.
Correct Answer:
Verified
Q12: Which of the following is not an
Q14: Which statement is false?
A)Both syntax errors and
Q16: Which of the following is not a
Q17: What is output by the following Java
Q17: The empty statement is denoted by what
Q18: Which of the following is not a
Q21: What is the result value of c
Q25: In an expression containing values of the
Q30: Sentinel-controlled repetition is also known as:
A)Definite repetition.
B)Indefinite
Q30: Which primitive type can hold the largest
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents