You are on page 1of 10

1. Number of constructors a class can define is ?

a) 1
b) 2
c) Any number
d) None of the mentioned

2. Correct way to define object of sample class in which code will work correctly is:

class abc

int i;

float k;

public abc(int ii, float kk)

i = ii;

k = kk;

a) abc s1 = new abc(1);


b) abc s1 = new abc();
c) abc s2 = new abc(1.4f);
d) abc s2 = new abc(1, 1.4f);

3. Correct statement about constructors in C#.NET is ?


a) Constructors can be overloaded
b) Constructors are never called explicitly
c) Constructors have same name as name of the class
d) All of the mentioned

4. Which among the following is the correct statement :


Constructors are used to
a) initialize the objects
b) construct the data members
c) initialize the objects & construct the data members
d) None of the mentioned

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

6. Which of these is used to access members of class before the object of that class is
created?
a) public
b) private
c) static
d) protected

7. Select output for the following set of code.

static void Main(string[] args)

int a = 5;

int b = 10;

int c;

Console.WriteLine(c = ++ a + b ++);

Console.WriteLine(b);

Console.ReadLine();

}
a) 11, 10
b) 16, 10
c) 16, 11
d) 15, 11

8. What will be output of the following conversion ?

static void Main(string[] args)

char a = 'A';

string b = "a";

Console.WriteLine(Convert.ToInt32(a));

Console.WriteLine(Convert.ToInt32(Convert.Tochar(b)));

Console.ReadLine();

a) 1, 97
b) 65, 97
c) 65, 97
d) 97, 1

9. Select output of the given set of Code :

static void Main(string[] args)

String name = "Dr.Gupta";

Console.WriteLine("Good Morning" + name);

a) Dr.Gupta
b) Good Morning
c) Good Morning Dr.Gupta
d) Good Morning name
10. Select output for the following set of code .

static void Main(string[] args)

const int a = 5;

const int b = 6;

for (int i = 1; i <= 5; i++)

a = a * i;

b = b * i;

Console.WriteLine(a);

Console.WriteLine(b);

Console.ReadLine();

a) 600, 720
b) Compile time error.
c) 25, 30
d) 5, 6

11. What is output of the code?

static void Main(string[] args)

Mul();

m();

Console.ReadLine();

static void Mul()


{

Console.WriteLine("4");

static void m()

Console.WriteLine("3");

Mul();

a) 4 3 3
b) 4 4 3
c) 4 3 4
d) 3 4 4

12. What is the output of the code ?

static void Main(string[] args)

m();

Console.ReadLine();

static void m()

Console.WriteLine("HI");

m();

a) HI HI HI
b) HI
c) Stack overflow exception
d) Compile time error

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

14. Select the output for the given set of code?

public class sample

public static int x = 100;


public static int y = 150;

public class newspaper :sample

new public static int x = 1000;

static void Main(string[] args)

console.writeline(sample.x + " " + sample.y + " " + x);

a) 100 150 1000


b) 1000 150 1000
c) 100 150 1000
d) 100 150 100

15. Which procedure among the following should be used to implement a ‘Has a’ or a ‘Kind
of’ relationship between two entities?

a) Polymorphism
b) Inheritance
c) Templates
d) All of the mentioned

16. The number of levels of inheritance are?


a) 5
b) 4
c) 3
d) 2

17. Wrong statement about inheritance in C# .NET?


a) In inheritance chain, object construction begins from base class towards derived class
b) Inheritance cannot extend base class functionality
c) A derived class object contains all base class data
d) All of the mentioned
18. A class member declared protected becomes member of subclass of which type?
a) public member
b) private member
c) protected member
d) static member

19. Which of the following functionality is facilitated by inheritance mechanism?


a) Use the existing functionality of base class
b) Override the existing functionality of base class
c) Implements new functionality in derived class
d) All of the mentioned

20 Which statements among following are correct?


a) We can derive a class from a base class even if source code of base class not available
b) Multiple inheritance is different from multiple levels of inheritance
c) It is legal to make objects of one class as members of another class
d) All of the mentioned

21. Which form of inheritance is not supported directly by C# .NET?


a) Multiple inheritance
b) Multilevel inheritance
c) Single inheritance
d) Hierarchical inheritance

22. If no access modifier for a class is specified,then class accessibility is defined as?
a) public
b) protected
c) private
d) internal

23. Choose the correct statement about the WriteLine()?


a) Can display one or more value to the screen
b) Adds a newline character at the end of the each new output
c) Allows to output data in as many different formats
d) All of the mentioned
24. How many Bytes are stored by ‘Long’ Datatype in C# .net?
a) 8
b) 4
c) 2
d) 1

25. What is the output of the following set of code ?

static void Main(string[] args)

int i, j;

int[, ] arr = new int[ 3, 3];

for (i = 0; i < 3; ++i)

for (j = 0; j < 3; ++j)

arr[i, j] = i * 2 + i * 2;

Console.WriteLine(arr[i, j]);

Console.ReadLine();

a) 0,0,0 4,4,4 8,8,8


b) 4,4,4 8,8,8 12,12,12
c) 8,8,8 12,12,12 16,16,16
d) 0,0,0 1,1,1, 2,2,2

You might also like