Sie sind auf Seite 1von 14

1.. Which is the object oriented way to handle run time errors?

a) Error codes
b) HERRESULT
c) On Error
d) Exceptions
2. 10. Predict the output for following set of code :
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.

static void Main(string[] args)


{
int i;
for (i =-3; i <= 3; i++)
{
switch (i)
{
case 0:
Console.WriteLine("zero");
break;
}
if (i > 0)
Console.WriteLine("A");
else if (i < 0)
Console.WriteLine("B");
}
Console.ReadLine();
}

a) B B zero A A A
b) B zero A A A
c) B B B zero A A A
d) A A A zero B B B
3. 1. Select the output for following set of code :

1.
static void Main(string[] args)
2.
{
3.
int i, j;
4.
for (i = 1; i <= 3; i++)
5.
{
6.
j = 1;
7.
while (i % j == 2)
8.
{
9.
j++;
10.
}
11.
Console.WriteLine(i + " " + j);
12.
}
13.
Console.ReadLine();
14.
}
a) 11 21 31
b) 1 12 13 1
c) 11 21 31
d) 1 1 2 1 3 1

4. 3. Select the output for following set of Code:


1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.

static void Main(string[] args)


{
int i;
i = 0;
while (i++ < 5)
{
Console.WriteLine(i);
}
Console.WriteLine("\n");
i = 0;
while ( ++i < 5)
{

13.
14.
15.
16.

Console.WriteLine(i);
}
Console.ReadLine();
}

a) 1 2 3 4
12345
b) 1 2 3
1234
c) 1 2 3 4 5
1234
d) 1 2 3 4 5
12345
5. Select the output for following set of Code:
1.
static void Main(string[] args)
2.
{
3.
int x = 0;
4.
while (x < 20)
5.
{
6.
while (x < 10)
7.
{
8.
if (x % 2 == 0)
9.
{
10.
Console.WriteLine(x);
11.
}
12.
x++;
13.
}
14.
}
15.
Console.ReadLine();
16.
}
a) 1 2 3 4 5 6 7 8 9 10
11 12 13 14 15 16 17 18 19 20
b) 0 2 4 6 8 10 12 14 16 18 20

c) 0 2 4 6 8
d) 0 2 4 6 8 10
6. Predict the output for following set of code :
1.
static void Main(string[] args)
2.
{
3.
int x;
4.
x = Convert.ToInt32(Console.ReadLine());
5.
int c = 1;
6.
while (c <= x)
7.
{
8.
if (c % 2 == 0)
9.
{
10.
Console.WriteLine("Execute While " + c + "\t" +
"time");
11.
}
12.
c++;
13.
}
14.
Console.ReadLine();
15.
}
16.
for x = 8.
a) Execute while 1 time
Execute while 3 time
Execute while 5 time
Execute while 7 time
b) Execute while 2 time
Execute while 4 time
Execute while 6 time
Execute while 8 time
c) Execute while 1 time
Execute while 2 time
Execute while 3 time
Execute while 4 time

Execute while 5 time


Execute while 6 time
Execute while 7 time
d) Execute while 2 time
Execute while 3 time
Execute while 4 time
Execute while 5 time

7. Select the output for following set of code :


1.
static void Main(string[] args)
2.
{
3.
int i = 0;
4.
while (i <= 50)
5.
{
6.
if (i % 10 == 0)
7.
continue;
8.
else
9.
break;
10.
i += 10;
11.
Console.WriteLine(i % 10);
12.
}
13.
}
a) code prints output as 0 0 0 0 0
b) code prints output as 10 20 30 40 50
c) infinite loop but donot print anything
d) Code generate error

8.

Which of the following is the correct way to create an object of


the class Sample?
1. Sample s = new Sample();
2. Sample s;
3. Sample s; s = new Sample();
4. s = new Sample();
A.

1, 3

B.

2, 4

C.

1, 2, 3

D.

4, 5

E.

None of these

9.
Which of the following statements are correct?
1. Data members ofa class are by default public.
2. Data members of a class are by default private.
3. Member functions of a class are by default public.
4. A private function of a class can access a public function within the
same class.
5. Member function of a class are by default private.

A.

1, 3, 5

B.

1, 4

C.

2, 4, 5

D.

1, 2, 3

E.

None of these

10.
Which of the following statements is correct about the C#.NET code
snippet given below?
namespace ConsoleApplication
{
class Sample
{
public int index;
public int[] arr = new int[10];
public void fun(int i, int val)
{
arr[i] = val;
}
}
class MyProgram
{
static void Main(string[] args)
{
Sample s = new Sample();
s.index = 20;
Sample.fun(1, 5);

s.fun(1, 5);
}
}
}
A.

s.index = 20 will report an error since index is public.

B.

The call s.fun(1, 5) will work correctly.

C.

Sample.fun(1, 5) will set a value 5 in arr[ 1 ].

D.

The call Sample.fun(1, 5) cannot work since fun() is not a shared


function.

E.

arr being a data member, we cannot declare it as public.

11.
Which one of the following statements is correct?
A.

Array elements can be of integer type only.

B.

The rank of an Array is the total number of elements it can


contain.

C.

The length of an Array is the number of dimensions in the Array.

D.

The default value of numeric array elements is zero.

E.

The Array elements are guaranteed to be sorted

12. Which of the following statements is correct about the C#.NET code
snippet given below?
int i;
int j = new int();
i = 10;
j = 20;
String str;
str = i.ToString();
str = j.ToString();
A.

This is a perfectly workable code snippet.

B.

Since int is a primitive, we cannot use new with it.

C.

Since an int is a primitive, we cannot call the


method ToString() using it.

D.

i will get created on stack, whereas j will get created on heap.

E.

Both i and j will get created on heap.

13.
Which of the following statements are correct about arrays used in
C#.NET?
1. Arrays can be rectangular or jagged.
2. Rectangular arrays have similar rows stored in adjacent memory

locations.
3. Jagged arrays do not have an access to the methods
of System.Array Class.
4. Rectangular arrays do not have an access to the methods
of System.ArrayClass.
5. Jagged arrays have dissimilar rows stored in non-adjacent memory
locations.
A.

1, 2

B.

1, 3, 5

C.

3, 4

D.

1, 2, 5

E.

4, 5

14.
What does the following C#.NET code snippet will print?
int i = 0, j = 0;
label:
i++;
j+=i;
if (i < 10)
{

Console.Write(i +" ");


goto label;
}
A.

Prints 1 to 9

B.

Prints 0 to 8

C.

Prints 2 to 8

D.

Prints 2 to 9

E.

Compile error at label:.

15.
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

16.
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;
}
A.

Prime

B.

Fibonacci

C.

Palindrome

D.

Odd

E.

Even

17. Which of the class provides the operation of reading from and
writing to the console in C#.NET?
a) System.Array
b) System. Output

c) System.ReadLine
d) System.Console
18. Which of the given stream method provides the access to the output
console by default in C#.NET?
a) Console.In
b) Console.Out
c) Console.Error
d) All of the mentioned
19. What namespace does the Web page belong in the .NET Framework
class hierarchy?
a) System.Web.UI.Page
b)System.web.UI.Page.Controls.
c)System.Data.Configuration.
d)System.Data.Sqlclient.
20.The number of input methods defined by the stream method
Console.In in C#.NET is?
a) 4
b) 3
c) 2
d) 1
21.Select the correct methods provided by Console.In?
a) Read(), ReadLine()
b) ReadKey(), ReadLine()
c) Read(), ReadLine(), ReadKey()
d) ReadKey(), ReadLine()
22. Can you store multiple data types in System.Array?

a) Yes
b) No

23. Choose the output returned when error condition generates while
read() reads from the console.
a) False
b) 0
c) -1
d) All of the mentioned

Das könnte Ihnen auch gefallen