1-Select the output for the following set of code:
static void Main(string[] args)
{ int i, s = 0;
for (i = 1; i <= 10; s = s + i, i++);
{ Console.WriteLine(s); }
Console.ReadLine(); }
A. Code report error B. Code runs in infinite loop condition
C. Code gives output as 0 1 3 6 10 15 21 28 36 45 D. Code give output as 55
2-Which of these is used as a default specifier for a member of the class if no access
specifier is used for it?
A. private B. public C. public, within its own class D. protected
3-Which of these base classes are accessible to the derived class members?
A. static B. protected C. private D. shared
4-_________ is an access modifier
A. Private B. Params C. Override D. Out
5-Which of the following is the correct way to create an object of the class Sample?
Sample s = new Sample();
Sample s;
Sample s; s = new Sample();
s = new Sample();
A. 1, 3 B. 2, 4 C. 1, 2, 3 D. 1, 4
6-How many objects can be declared of a specific class in a single program?
A. 32768 B. 127 C. 1 D. As many as you want
7-Which is correct syntax?
A. classname objectname= new() classname;
B. classname objectname= new classname);
C. classname objectname= new classname();
D. classname objectname= new() classname();
8-Objects can be used _____________________
A. To access any member of a class
B. To access only public members of a class
C. To access only protected members of a class
D. To access only private members of a class
9-A ---- consists of a sequence of instructions that can access the data of an object.
A. Methods B. Variables C. Attributes D. Objects
10-What will be the output of the following C# code?
static void Main(string[] args) {
int i = 2;
int j = 10 / 4;
if (i = = j) {
Console.WriteLine("True");
} else {
Console.WriteLine("False");
}
}
A. True B. False
11-Arrays in C# are ______ objects.
A. Reference B. Logical C. Value D. Arithmetic
12-___________ is the right way of declaring an array.
A. int intArray [ ] = new int[5]; B. int[] intArray = new int[ ];
C. int[5] intArray = new int[ ]; D. int[] intArray = new int[5];
13-How many values does a method return?
A. 0 B. 2 C. 1 D. any number of values
14-The Method use to remove white space from a string?
A. Split() B. Substring() C. Trim() D. TrimStart()
15- What is the access modifier for a class member that can only be accessed within the
same class?
a-public b-private c-protected d-internal
16-What is the correct syntax for declaring a method in C#?
a-Function MyMethod() { } b-MyMethod void() {}
c-method MyMethod() { } d-void MyMethod() {}
17- What is the output of the following code?
int x = 10;
int y = x++;
Console.WriteLine(y);
a-11 b-9 c-10 d-none of these
18-class Program
{static void Main(string[] args)
{ ChildClass c = new ChildClass();
c.print(); } }
class ParentClass
{ int id = 1;
public void print()
{Console.WriteLine(id);
} }
class ChildClass : ParentClass
{int id = 2; }
A. 0 B. 1 C. 2 D. Nothing
19-What will be the output of the following C# code?
static void Main(string[] args) {
int i = 2;
int j = 10 / 4;
if (i == j) {
Console.WriteLine("True");
} else {
Console.WriteLine("False");
}}
A. True B. False
20- What is the output for the following set of code :
static void Main(string[] args)
{
int i = 10;
double d = 35.78;
fun(i);
fun(d);
Console.ReadLine(); }
static void fun(double d)
{ Console.WriteLine(d); }
A. 35.78 10 B. 10 35.00 C. 10 35.78 D. None of the mentioned