What is output by the following Java code segment?
int temp = 180;
If (temp > 90) {
System.out.println("This porridge is too hot.") ;
// cool down
Temp = temp - (temp > 150 ? 100 : 20) ;
}
Else {
If (temp < 70) {
System.out.println("This porridge is too cold.") ;
// warm up
Temp = temp + (temp < 50 ? 30 : 20) ;
}
}
If (temp == 80) {
System.out.println("This porridge is just right!") ;
}
A) This porridge is too hot.
B) This porridge is too cold. This porridge is just right!
C) This porridge is just right!
D) None of the above.
Correct Answer:
Verified
Q14: Which of the following is the shape
Q15: Which of the following is not a
Q16: A decision symbol in an activity diagram
Q17: Which of the following is true?
A) Pseudocode
Q18: Which of the following is not a
Q20: Which of the following is a double-selection
Q21: Sentinel-controlled iteration is also known as:
A) Definite
Q22: Which of the following statements is true?
A)
Q23: How many times is the body of
Q24: What does the expression x %= 10
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