There is no error in this switch case statement.. The switch statement is a control statement that handles multiple selections and enumerations by passing control to one of the case stat
Trang 1B 2, 4
C 3, 5
D. 4, 5
E None of these
10 The C#.NET code snippet given below generates numbers series as output?
int i = 1, j = 1, val;
while (i < 25)
{
Console.Write(j + " ");
val = i + j;
j = i;
i = val;
}
E Even
11 Which of the following statements are correct about the C#.NET code snippet given below?
if (age > 18 && no < 11)
a = 25;
1 The condition no < 11 will be evaluated only if age > 18 evaluates toTrue
2 The statement a = 25 will get executed if any one condition is True
3 The condition no < 11 will be evaluated only if age > 18 evaluates toFalse
4 The statement a = 25 will get executed if both the conditions are True
5 && is known as a short circuiting logical operator
A 1, 3
B 2, 5
C. 1, 4, 5
D 3, 4, 5
E None of these
12 Which of the following statements are correct?
1 A switch statement can act on numerical as well as Boolean types
2 A switch statement can act on characters, strings and enumerationstypes
Trang 23 We cannot declare variables within a case statement if it is not enclosed by{ }
4 The foreach statement is used to iterate through the collection to get the desired information and should be used to change the contents of the collection to avoid unpredictable side
effects
5 All of the expressions of the for statement are not optional
A 1, 2
B 2, 3
C 3, 5
D 4, 5
E None of these
13 What will be the output of the C#.NET code snippet given below?
int i = 2, j = i;
if (Convert.ToBoolean((i | j & 5) & (j - 25 * 1)))
Console.WriteLine(1);
else
Console.WriteLine(0);
A 0
B 1
C Compile Error
D Run time Error
14 Which of the following statements is correct about the C#.NET code snippet given
below?
switch (id)
{
case 6:
grp = "Grp B";
break;
case 13:
grp = "Grp D";
break;
case 1:
grp = "Grp A";
break;
Trang 3
case ls > 20:
grp = "Grp E";
break ;
case Else:
grp = "Grp F";
break;
}
A. Compiler will report an error in case ls > 20 as well as in case Else
B There is no error in this switch case statement
C Compiler will report an error only in case Else
D Compiler will report an error as there is no default case
E The order of the first three cases should be case 1, case 6, case 13(ascending)
15 Which of the following is another way to rewrite the code snippet given below?
int a = 1, b = 2, c = 0;
if (a < b) c = a;
A. intc = a < b ? a : 0; a = 1, b = 2, c = 0;
B inta < b ? c = a : c = 0; a = 1, b = 2, c = 0;
C int a = 1, b = 2, c = 0;
a < b ? c = a : c = 0 ? 0 : 0;
D int a = 1, b = 2, c = 0;
a < b ? return (c): return (0);
E intc = a < b : a ? 0; a = 1, b = 2,c = 0;
16 Which of the following statements are correct?
1 The switch statement is a control statement that handles multiple selections and
enumerations by passing control to one of the case statements within its body
Trang 42 The goto statement passes control to the next iteration of the enclosing iteration statement in which it appears
3 Branching is performed using jump statements which cause an immediate transfer of the program control
4 A common use of continue is to transfer control to a specific switch-caselabel or
5 The do statement executes a statement or a block of statements enclosed in{} repeatedly until a specified expression evaluates to false
A 1, 2, 4
B. 1, 3, 5
C 2, 3, 4
D 3, 4, 5
E None of these
17 Which of the following statements are correct about the C#.NET code snippet given below?
if (age > 18 || no < 11)
a = 25;
1 The condition no < 11 will get evaluated only if age > 18 evaluates toFalse
2 The condition no < 11 will get evaluated if age > 18 evaluates to True
3 The statement a = 25 will get evaluated if any one one of the two conditions is True
4 || is known as a short circuiting logical operator
5 The statement a = 25 will get evaluated only if both the conditions areTrue
A 1, 4, 5
B 2, 4
C. 1, 3, 4
D 2, 3, 5
E None of these
18 What will be the output of the code snippet given below?
int i;
for(i = 0; i<=10; i++)
{
if(i == 4)
{
Console.Write(i + " "); continue;
}
Trang 5else if (i != 4)
Console.Write(i + " "); else
break;
}
A 1 2 3 4 5 6 7 8 9 10
B 1 2 3 4
C. 0 1 2 3 4 5 6 7 8 9 10
D 4 5 6 7 8 9 10
E 4
19 Which of the following loop correctly prints the elements of the array?
char[ ] arr = new chart[ ] {'k', 'i','C', 'i','t'} ;
A
do
{
Console.WriteLine((char) i);
}
while (int i = 0; i < arr; i++);
B.
foreach (int i in arr)
{
Console.WriteLine((char) i);
}
C
for (int i = 0; i < arr; i++)
{
Console.WriteLine((char) i);
}
D
while (int i = 0; i < arr; i++)
{
Console.WriteLine((char) i);
}
E do{
Console.WriteLine((char) i);
Trang 6}
until (int i = 0; i < arr; i++);
20 Which of the following statements is correct about the C#.NET code snippet given
below?
int i, j, id = 0; switch (id)
{
case i:
Console.WriteLine("I am in Case i");
break;
case j:
Console.WriteLine("I am in Case j");
break;
}
A. The compiler will report case i and case j as errors since variables cannot be used in
cases
B Compiler will report an error since there is no case statement default case in the switch
C The code snippet prints the result as "I am in Case i""
D The code snippet prints the result as "I am in Case j"
E There is no error in the code snippet
Câu hỏi namespaces
1 Which of the followings are NOT a NET namespace?
A 1, 3
B. 2, 4, 5
C 3, 5
Trang 7D 1, 2, 3
2 Which of the following statements is correct about namespaces in C#.NET?
A Namespaces can be nested only up to level 5
B A namespace cannot be nested
C. There is no limit on the number of levels while nesting namespaces
D If namespaces are nested, then it is necessary to use using statement while using the
elements of the inner namespace
E Nesting of namespaces is permitted, provided all the inner namespaces are declared in the same file
3 Which of the following is correct way to rewrite the C#.NET code snippet given below?
using Microsoft.VisualBasic;
using System.Windows.Forms;
MessageBox.Show("Wait for a" + ControlChars.CrLf + "miracle");
A
using System.Windows.Forms;
using CtrlChars = Microsoft.VisualBasic.ControlChars;
MessageBox.Show("Wait for a" + CrLf + "miracle");
B
using Microsoft.VisualBasic;
using System.Windows.Forms;
CtrlChars = ControlChars;
MessageBox.Show("Wait for a" + CtrlChars.CrLf + "miracle");
C
using Microsoft.VisualBasic;
using System.Windows.Forms;
CtrlChars = ControlChars;
MessageBox.Show ("Wait for a" + CrLf + "miracle");
D.
using System.Windows.Forms;
using CtrlChars = Microsoft.VisualBasic.ControlChars;
MessageBox.Show("Wait for a" + CtrlChars.CrLf + "miracle");
4 Which of the following statements is correct about the using statement used in C#.NET?
B It is permitted to define a member at namespace level as a using alias
Trang 8C. A C#.NET source code file can contain any number of using statement
D By using using statement it is possible to create an alias for the namespace but not for the namespace element
E By using using statement it is possible to create an alias for the namespace element but not for the namespace
5 Which of the following statements are correct about a namespace used in C#.NET?
1 Classes must belong to a namespace, whereas structures need not
2 Every class, struct, enum, delegate and interlace has to belong to some or the other
namespace
3 All elements of the namespace have to belong to one file
4 If not mentioned, a namespace takes the name of the current project
5 The namespace should be imported to be able to use the elements in it
A 1, 3
B. 2, 4, 5
C 3, 5
D 4 only
6 Which of the following CANNOT belong to a C#.NET Namespace?
E interface
7 Which of the following statements is correct about a namespace used in C#.NET?
A Nested namespaces are not allowed
B Importing outer namespace imports inner namespace
C. Nested namespaces are allowed
D If nested, the namespaces cannot be split across files
8 Which of the following C#.NET code snippets will correctly print "Hello C#.NET"?
A import System;
Trang 9namespace IndiabixConsoleApplication
{
class MyProgram
{
static void Main(string[] args)
{
Console.WriteLine("Hello C#.NET");
}
}
}
B
using System;
namespace IndiabixConsoleApplication
{
class MyProgram
{
static void Main(string[ ] args)
{
WriteLine("Hello C#.NET");
}
}
}
C
using System.Console;
namespace IndiabixConsoleApplication
{
class MyProgram
{
static void Main (string[ ] args)
{
WriteLine("Hello C#.NET");
}
}
}
D.
using System;
namespace IndiabixConsoleApplication
{
class MyProgram
{
static void Main(string[] args)
{
Console.WriteLine("Hello C#.NET");
}
}
Trang 10}
9 If ListBox is class present in System.Windows.Forms namespace, then which of the following statements are the correct way to create an object of ListBox Class?
1 using System.Windows.Forms;
2 ListBox lb = new ListBox();
3 using LBControl = System.Windows.Forms;
4 LBControl lb = new LBControl();
5 System.Windows.Forms.ListBox lb = new System.Windows.Forms.ListBox();
6 using LBControl lb = new System.Windows.Forms.ListBox;
7 using LBControl = System.Windows.Forms.ListBox;
8 LBControl lb = new LBControl();
A 1, 3
B 2, 4, 5
C. 1, 3, 5
D 5 only