Exam 4: Control Structures I: Selection

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

switch (lastInitial) { Case 'A': System.out.println("section 1"); Break; Case 'B': System.out.println("section 2"); Break; Case 'C': System.out.println("section 3"); Break; Case 'D': System.out.println("section 4"); Break; Default: System.out.println("section 5"); }Based on the code above, what is the output if lastInitial = 'C'?

(Multiple Choice)
4.9/5
(39)

After the execution of the following code, what will be the value of num if the input values are 0 3? (Assume that console is a Scanner object initialized to the standard input device.)int num = console.nextInt();if (num > 0) Num = num + 13; Else If (num >= 3) Num = num + 15;

(Multiple Choice)
4.8/5
(35)

Suppose that you have the following code.int num = 10;if (num > 10) System.out.println(num); else System.out.println(num + 5);The output of this code is 5.

(True/False)
4.9/5
(36)

The output of the Java code:int alpha = 5; int beta = 4;switch (beta) { case 2: alpha = alpha + 2; case 4: alpha = alpha + 4; break; case 6: alpha = alpha + 6; default: alpha = alpha + 10; } System.out.print(alpha);is: 9

(True/False)
4.8/5
(33)

Suppose str1 and str2 are String variables. The expression (str1 == str2) determines whether str1 and str2 point to the same String object.

(True/False)
4.9/5
(39)

What is the output of the following Java code?int x = 57; Int y = 3;switch (x % 9) { Case 0: Case 1: Y++; Case 2: Y = y - 2; Break; Case 3: Y = y + 2; Case 4: Break; Case 5: Case 6: Y = y + 3; }System.out.println(y);

(Multiple Choice)
4.8/5
(29)

When one control statement is located within another, it is said to be a controlled statement.

(True/False)
4.7/5
(40)

Suppose that you have the following code:int sum = 0; Int num = 8;if (num 5) Sum = num + 15;After this code executes, what is the value of sum?

(Multiple Choice)
5.0/5
(32)

In Java, case and switch are reserved words, but break is not a reserved word.

(True/False)
4.9/5
(40)

Suppose that you have the following statements.int score; String grade;if (score >= 65) grade = "pass"; else grade = "fail";If score is equal to 75, the value of grade is pass.

(True/False)
4.9/5
(44)
Showing 41 - 50 of 50
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)