php mcq questions with answers
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.XXXXXIndiaB.IndiaBBBBBC.XXXXXIndiaBBBBBD.BBBBBIndiaXXXXXE.Zero
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 aB.case B | case bC.case D | case dD.Compile ErrorE.No output
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}
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, 3B.1 OnlyC.2, 3D.4 OnlyE.None of these
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, 3B.2, 4C.3, 5D.4, 5E.None of these