control instruction questions

6.

What will be the output of the C#.NET code snippet given below?

int val;
for (val = -5; val <= 5; val++)
{
switch (val)
{
case 0:
Console.Write (“India”);
break;
}

if (val > 0)
Console.Write (“B”);
else if (val < 0)
Console.Write (“X”);
}

A.     XXXXXIndia    B.     IndiaBBBBB
C.     XXXXXIndiaBBBBB    D.     BBBBBIndiaXXXXX
E.     Zero
Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.
View Answer Workspace Report Discuss in Forum
7.

What will be the output of the C#.NET code snippet given below?

char ch = Convert.ToChar (‘a’ | ‘b’ | ‘c’);
switch (ch)
{
case ‘A’:
case ‘a’:
Console.WriteLine (“case A | case a”);
break;

case ‘B’:
case ‘b’:
Console.WriteLine (“case B | case b”);
break;

case ‘C’:
case ‘c’:
case ‘D’:
case ‘d’:
Console.WriteLine (“case D | case d”);
break;
}

A.     case A | case a
B.     case B | case b
C.     case D | case d
D.     Compile Error
E.     No output
Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.
View Answer Workspace Report Discuss in Forum
8.

Which of the following is the incorrect form of Decision Control instruction?
A.

if (Condition1)
{// Some statement}

B.

if (Condition1) {// Some statement}
else {// Some statement}

C.

if (Condition1) {// Some statement}
else {// Some statement}
else if ( Condition2){//Some statement}

D.

if ( Condition1 ) {// Some statement}
else if ( Condition2 ) {// Some statement}
else {// Some statement}

E.

if ( Condition1 ) {// Some statement}
else if ( Condition2 ) {// Some statement}
else if ( Condition3 ) {// Some statement}
else {// Some statement}

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.
View Answer Workspace Report Discuss in Forum
9.

Which of the following code snippets are the correct way to determine whether a is Odd or Even?

int a;
String res;
if (a % 2 == 0)
res = “Even”;
else
res = “Odd”;

int a;
String res;
if (a Mod 2 == 0)
res = “Even”;
else
res = “Odd”;

int a;
Console.WriteLine(a Mod 2 == 0 ? “Even”: “Odd”);

int a;
String res;
a % 2 == 0 ? res = “Even” : res = “Odd”;
Console.WriteLine(res);

A.     1, 3
B.     1 Only
C.     2, 3
D.     4 Only
E.     None of these
Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.
View Answer Workspace Report Discuss in Forum
10.

Which of the following can be used to terminate a while loop and transfer control outside the loop?

exit while
continue
exit statement
break
goto

A.     1, 3
B.     2, 4
C.     3, 5
D.     4, 5
E.     None of these
Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question.

Leave a Reply0

Your email address will not be published.