Multiple Choice
For the two code segments below:
Segment A
Int q = 5;
Switch(q)
{
Case 1:
System.out.println(1) ;
Case 2:
System.out.println(2) ;
Case 3:
System.out.println(3) ;
Case 4:
System.out.println(4) ;
Case 5:
System.out.println(5) ;
Default:
System.out.println("default") ;
}
Segment B
Q = 4;
Switch(q)
{
Case 1:
System.out.println(1) ;
Case 2:
System.out.println(2) ;
Case 3:
System.out.println(3) ;
Case 4:
System.out.println(4) ;
Case 5:
System.out.println(5) ;
Default:
System.out.println("default") ;
}
Which of the following statements is true?
A) The output for Segment A is:
Default
B) The output for Segment B is:
4
C) The output for Segment B is:
45default
D) The output for Segment A is:
5
Default
Correct Answer:

Verified
Correct Answer:
Verified
Q3: Consider the following two Java code segments:
Q5: Suppose variable gender contains MALE and age
Q6: Which statement prints the floating-point value 123.456
Q14: Which formatting flag indicates that the floating-point
Q15: Which of the following statements is true?<br>A)
Q17: Which expression is equivalent to if (!(grade
Q25: Boolean values can be displayed as the
Q25: For the code segment below:<br>Switch(q)<br>{<br>Case 1:<br>System.out.println("apple");<br>Break;<br>Case 2:<br>System.out.println("orange");<br>Break;<br>Case
Q26: Consider the code segment below.<br>If (gender ==
Q27: Counter-controlled repetition requires<br>A)A control variable and initial