0 of 12 questions completed
Questions:
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
0 of 12
Time has elapsed
0 of 0 point(s), (0)
0 of 0, (0)
Essay(s) Pending: 0 (Possible Point(s): 0)
Determine the output created by the following code segment:
int age = 81;
if(age >= 18) {
System.out.println("You can vote");
}
Determine the output of the following if else code block:
int age = 16;
if(age < 18) {
System.out.println("You cannot vote");
} else {
System.out.println("You can vote");
}
Determine the output produced by the following code block:
String season = "fall"; switch (season) { case "winter": System.out.println("It is cold"); break; case "spring": System.out.println("It is rainy"); break; case "summer": System.out.println("It is hot"); break; default: System.out.println("It is windy"); }
The conditional expression in an if
statement must resolve to which data type?
Which of the following examples are valid if
statements?
Select one or more:
Which of the following is a valid way to chain if-else statements together?
Select one:
What is the correct syntax for writing an if-else statement?
Examine the following code.
int age = 7; int hunger = 5; if (age < 9) { System.out.println("I am young enough for shenanigans."); if (hunger > 5) { System.out.println("Let's get some food!"); } else { System.out.println("I'm not really hungry though."); } } else { System.out.println("I am too old for shenanigans."); }
What will the output of this code be?
Examine the switch
statement below.
int value = 2; int result = ""; switch(value) { case 1: result += "S"; case 2: result += "O"; case 3: result += "U"; case 4: result += "R"; default: break; }
What is the value of result
after this statement finishes execution.
Which of the following is NOT a valid switch
statement?
Select one or more:
Examine the switch
statement below:
String letter = "X";
String result = "";
switch(letter) {
case "A":
result += "a";
break;
case "B":
result += "b";
break;
case "C":
result += "c";
break;
default:
result += "d";
break;
}
What is the value of result
after this statement executes?
switch
statements?Select one or more: