QUESTION 4 Given the switch statement, which of the following would be the first
ID: 3741470 • Letter: Q
Question
QUESTION 4
Given the switch statement, which of the following would be the first if statement to replace the first test in the switch?
switch (control)
{
case 11 :
WriteLine("eleven");
break;
case 12 :
WriteLine("twelve");
break;
case 16 :
WriteLine("sixteen");
break;
}
if (case = 11)
if (case == 11)
if (control == 11)
if (switch == 11)
none of the above
QUESTION 5
If you were to write switch statements to perform the following evaluation, what selector would be placed inside the parenthesis for each of the following scenarios?
switch ( ? )
a. Testing string stateName for FL, GA, or MS. Storing 1 in cnt for FL, 2 for GA, 3 for MS
b. Testing cnt for 1, 5 or 7. Storing 100 in value1 when cnt is 1, storing 10 in value1 when cnt is 5 and storing 1 in value1 when cnt is 7
c. When middleInitial is equal to the character z, a message should be displayed stating “You’re one in a thousand”; otherwise, check to see if it is equal to the character ‘a’. When it is equal to the character a, display the message “You have the most common initial”. If it’s not equal to ‘a’ or ‘z’ the message should read “Just another initial”.
QUESTION 6
What is the result of the following conditional expression when aValue = 100 and bValue = 7 ?
result = aValue > bvalue + 100 ? 1000 : 2000;
0
1000
2000
7
none of the above
if (case = 11)
if (case == 11)
if (control == 11)
if (switch == 11)
none of the above
QUESTION 5
If you were to write switch statements to perform the following evaluation, what selector would be placed inside the parenthesis for each of the following scenarios?
switch ( ? )
a. Testing string stateName for FL, GA, or MS. Storing 1 in cnt for FL, 2 for GA, 3 for MS
b. Testing cnt for 1, 5 or 7. Storing 100 in value1 when cnt is 1, storing 10 in value1 when cnt is 5 and storing 1 in value1 when cnt is 7
c. When middleInitial is equal to the character z, a message should be displayed stating “You’re one in a thousand”; otherwise, check to see if it is equal to the character ‘a’. When it is equal to the character a, display the message “You have the most common initial”. If it’s not equal to ‘a’ or ‘z’ the message should read “Just another initial”.
QUESTION 6
What is the result of the following conditional expression when aValue = 100 and bValue = 7 ?
result = aValue > bvalue + 100 ? 1000 : 2000;
0
1000
2000
7
none of the above
Explanation / Answer
here are the answers..
===============================================================
Ans:4
if (control == 11)
================================================================
Ans:5
Option A is correct.
===============================================================
Ans:6
result = aValue > bvalue + 100 ? 1000 : 2000;
result = 100 > 7+100 ? 1000: 2000
+ has higher precedence hence
result = 100 > 700 (that is false)
hence
result = 2000
Option C is correct.
=============================================================
KIndly Check and Verify Thanks..!!!