Exam 4: Control Structures I: Selection
Exam 1: An Overview of Computers and Programming Languages50 Questions
Exam 2: Basic Elements of Java50 Questions
Exam 3: Introduction to Objects and Input/output50 Questions
Exam 4: Control Structures I: Selection50 Questions
Exam 5: Control Structures II: Repetition50 Questions
Exam 6: Graphical User Interface GUI and Object-Oriented Design OOD50 Questions
Exam 7: User-Defined Methods50 Questions
Exam 8: User-Defined Classes50 Questions
Exam 9: Arrays46 Questions
Exam 10: Inheritance and Polymorphism50 Questions
Exam 11: Handling Exceptions and Events50 Questions
Exam 12: Advanced Guis and Graphics48 Questions
Exam 13: Recursion50 Questions
Exam 14: Applications of Arrays Searching and Sorting and Strings50 Questions
Select questions type
Which of the following is a relational operator?
Free
(Multiple Choice)
4.8/5
(36)
Correct Answer:
B
Suppose that x is an int variable. Which of the following expressions always evaluates to false?
Free
(Multiple Choice)
4.9/5
(40)
Correct Answer:
C
Suppose P and Q are logical expressions. The expression P || Q is true if both P and Q are true.
Free
(True/False)
4.8/5
(32)
Correct Answer:
True
The execution of a break statement in a switch statement terminates the switch statement.
(True/False)
4.9/5
(35)
In a ____ control structure, the computer executes particular statements depending on some condition(s).
(Multiple Choice)
4.8/5
(39)
Which of the following is NOT a relational operator in Java?
(Multiple Choice)
4.8/5
(34)
Suppose that you have the following statements.String str1 = "cat";
String str2 = "cats";The statement str1.equals(str2); is true.
(True/False)
4.7/5
(42)
int x, y;if (x 4)
{
If (x > 7)
Y = 4;
Else
Y = 6;
}
Else
Y = 8;Based on the code above, what is the value of y if x = 5?
(Multiple Choice)
4.8/5
(34)
A computer program will recognize both = and == as the equality operator.
(True/False)
4.9/5
(37)
Suppose that the input is 6 and console is a Scanner object initialized to the standard input device. Consider the following code.int alpha = 7;
int beta = console.nextInt();switch (beta)
{
case 5:
alpha = alpha + 1;
case 6:
alpha = alpha + 2;
case 7:
alpha = alpha + 3;
default:
alpha = alpha + 5;
}System.out.print(alpha);The output of this code is 9.
(True/False)
4.8/5
(46)
Suppose x = 10 and y = 20. The value of the expression ((x >= 10) && (y is true.
(True/False)
4.8/5
(36)
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 = 'E'?
(Multiple Choice)
4.9/5
(36)
Showing 1 - 20 of 50
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)