186k views
4 votes
A ______ statement selects for execution a statement list having an associated label that corresponds to the value of an expression.

a. Switch
b. If-Else
c. And/or
d. None of the above

User Jameo
by
5.4k points

1 Answer

7 votes

Answer:

A) Switch

Step-by-step explanation:

In Java and most programming Languages, A Switch Statement provides a multi branch statements which provides a more flexible way for transfer of execution to the branch that fulfills the condition of the expressed value. This is a better way of handling if...elseif....else statements. In this way, a variable is tested for equality against some values. Variables used in switch expressions can only be primitives (int, byte, char), enums and strings. A switch statement has

1. A default statement (optional), appears at the end of the switch and acts as the else condition.

2. A break statement which terminates the switch when reached.

The syntax of a switch statement is given below:

switch(expression) {

case x:

// code block

break;

case y:

// code block

break;

default:

// code block

}

User Joej
by
5.9k points