Java Control Statements
Java Control Statements - Important Points
6. | Which control flow statement is used to execute a set of statements at least once? |
---|
A. while loop
B. do-while loop
C. for loop
D. if statement
View Answer Discuss Work SpaceAnswer: option b
Explanation:
7. | Which of the following is not a valid relational operator in Java? |
---|
A. ==
B. !=
C. <=
D. ><
View Answer Discuss Work SpaceAnswer: option d
Explanation:
8. | What is the difference between a switch statement and a series of if-else statements in Java? |
---|
A. A switch statement can only test for equality, while if-else statements can test for any condition.
B. A switch statement can test for any condition, while if-else statements can only test for equality.
C. A switch statement is more efficient than a series of if-else statements for testing a single variable against multiple values.
D. There is no difference between a switch statement and a series of if-else statements.
View Answer Discuss Work SpaceAnswer: option c
Explanation:
9. | Which control flow statement is used to jump to a specific label in the code? |
---|
A. continue
B. break
C. return
D. goto
View Answer Discuss Work SpaceAnswer: option d
Explanation:
10. | What is the purpose of the labeled statement in Java? |
---|
A. To define a new variable in the code.
B. To provide a descriptive name for a loop or if statement.
C. To mark a specific point in the code that can be jumped to using the goto statement.
D. To create a custom exception class.
View Answer Discuss Work SpaceAnswer: option c
Explanation: