C# MCQ
C# MCQ
2. C# runs on the .
A. .NET Framework
B. Java Virtual Machine
C. Both A. and B.
D. None of the above
1|P a g e
Department of Computer Science and Engineering
8. CLR stands for .
A. Common Type System
B. Common Language Specification
C. Common Language Runtime
D. Java Virtual Machine
11. Which symbols are used to mark the beginning and end of a code block?
A. Square brackets []
B. Curly braces {}
C. Round brackets ()
D. Double-quotes ""
2|P a g e
Department of Computer Science and Engineering
17. Which is the correct order for implicit type conversion to convert a smaller to a larger type in C#?
A. char ->int -> long -> float -> double
B. bool -> char ->int -> long -> float -> double
C. char ->int -> float -> long -> double
D. bool -> char ->int -> long -> double -> float
18. Which is the correct order for explicit type conversion to convert a larger to a smaller type in C#?
A. double -> float -> long ->int -> char -> bool
B. double -> float -> long ->int -> char
C. float -> double -> long ->int -> char
D. float -> double -> long ->int -> char -> bool
usingSystem;
namespaceMyApplication {
classProgram {
staticvoidMain(string[] args) {
bool x = true;
Console.Write(Convert.ToString(x));
}
}
}
A. True
B. true
C. False
D. false
usingSystem;
namespaceMyApplication {
classProgram {
staticvoidMain(string[] args) {
double x = 10.25;
Console.Write(Convert.ToInt32(x));
}
}
}
A. 10.30
B. 10.25
C. 10
D. Error
22. What will be the output of the following C# code, if the input is 123?
3|P a g e
Department of Computer Science and Engineering
usingSystem;
namespaceMyApplication {
classProgram {
staticvoidMain(string[] args) {
Console.WriteLine("Enter a number:");
intnum = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Given number is: " + num);
}
}
}
23. Which is/are the correct method(s) to input a float value in C#?
A. Parse(Console.ReadLine())
B. ToSingle(Console.ReadLine())
C. ToFloat(Console.ReadLine());
D. Both A and B
E. Both A and C
usingSystem;
namespaceMyApplication {
classProgram {
staticvoidMain(string[] args) {
int a = 10, b = 20;
Console.WriteLine("{0},{0}", a, b);
}
}
}
A. 10,10
B. 10,20
C. 20,20
D. Error
usingSystem;
classProgram {
staticvoidMain(string[] args) {
inti = 2;
int j = 10 / 4;
if (i == j) {
Console.WriteLine("True");
} else {
Console.WriteLine("False");
}
}
}
A. True
4|P a g e
Department of Computer Science and Engineering
B. False
C. Error
D. None
usingSystem;
classProgram {
staticvoidMain(string[] args) {
Console.WriteLine(true ^ true);
}
}
A. True
B. False
C. Error
D. None
27. What will be the output of the following C# code?
usingSystem;
classProgram {
static void Main(string[] args)
{
int i = 100;
do {
Console.Write(i + " ");
++i;
} while (i<= 50);
}
A. Error
B. 100 101 102 ... Infinite
C. 101
D. 100
usingSystem;
classProgram {
publicstaticvoidMain() {
inti = 10;
Console.WriteLine(i++);
}
}
A. 10
B. 11
C. 12
D. Error
5|P a g e
Department of Computer Science and Engineering
A. to return from the calling functions to called function
B. to throw an exception manually during the execution of the program
C. to return from the switch statement
D. None of the above
usingSystem;
classProgram {
staticvoidMain(string[] args) {
String s1 = "Hello";
String s2 = "IncludeHelp";
String s3 = s1;
Console.WriteLine(s1.Equals(s3) + " " + s2.CompareTo(s1));
}
}
A. Error
B. True True
C. True False
D. True 1
classProgram {
staticvoidMain(string[] args) {
String str = "Hello";
Console.WriteLine(str.Length);
}
}
A. 5
B. 6
C. 7
D. 4
usingSystem;
classProgram {
staticvoidMain(string[] args) {
String str = "Hello";
Console.WriteLine(str.IndexOf('h'));
}
}
A. 0
B. 1
C. -1
D. Error
usingSystem;
namespaceMyApplication {
classProgram {
staticvoidMain(string[] args) {
string[] mobiles = { "iPhone", "Samsung", "Vivo"};
Console.WriteLine(mobiles);
}
}
}
7|P a g e
Department of Computer Science and Engineering
usingSystem;
namespaceMyApplication {
classProgram {
staticvoidMain(string[] args) {
string[] mobiles = {"iPhone", "Samsung", "Vivo"};
Console.WriteLine(mobiles[-1]);
}
}
}
A. None
B. Warning
C. Exception
D. System.String[]
41. Which array property is used to get the total number of elements in C#?
A. Len
B. Length
C. Elements
D. MaxLen
42. Which array method is used to sort an array alphabetically or in an ascending order in C#?
A. sort()
B. sorting()
C. Sort()
D. Sorting()
usingSystem;
namespaceMyApplication {
classProgram {
staticvoidMain(string[] args) {
int[,] ARR = {{1,2},{3,4}};
Console.WriteLine(ARR.GetLength(0)+","+ARR.GetLength(1));
}
}
}
A. 4,4
B. 2,2
C. Compilation Error
D. Runtime Error
44. Which is the correct way to declare an object of the class in C#?
8|P a g e
Department of Computer Science and Engineering
B. Dot Operator (.)
C. Greater Than (>)
D. Dot and Greater Than (.>)
A. Static Constructor
B. Private Constructor
C. Body Constructor
D. Parameterized Constructor
47. How many types of access modifiers in C#?
A. 2
B. 3
C. 4
D. 5
49. Which C# concept has the capability of an object to take number of different forms and hence
display behaviour as accordingly?
A. Polymorphism
B. Encapsulation
C. Abstraction
D. None of the above
1. staticvoid Main(string[]args)
2. {
3. int a =5;
4. int s =0, c =0;
5. Mul(a, ref s, ref c);
6. Console.WriteLine(s +"t "+c);
7. Console.ReadLine();
8. }
9. staticvoidMul(int x, refintss, refint cc)
10. {
11. ss= x * x;
12. cc = x * x * x;
13. }
a) 125 25
b) 25 125
c) Compile time error
d) 0 0
9|P a g e
Department of Computer Science and Engineering
51. Which of the following statements are correct about functions?
a) C# allows a function to have arguments with default values
b) Redefining a method parameter in the method’s body causes an exception
c) C# allows function to have arguments with default values
d) Omitting the return type in method definition results into exception
52. What will be the output of the following C# code?
staticvoid Main(string[]args)
{
Mul();
m();
Console.ReadLine();
}
. staticvoidMul()
{
Console.WriteLine("4");
}
staticvoid m()
{
Console.WriteLine("3");
Mul();
}
a) 4 3 3
b) 4 4 3
c) 4 3 4
d) 3 4 4
1. staticvoid Main(string[]args)
2. {
3. m();
4. Console.ReadLine();
5. }
6. staticvoid m()
7. {
8. Console.WriteLine("HI");
9. m();
10. }
a) HI HIHI
b) HI
c) Stack overflow exception
d) Compile time error
10 | P a g e
Department of Computer Science and Engineering
55. What will be the output of the following C# code?
1. staticvoid Main(string[]args)
2. {
3. int y =3;
4. y++;
5. if(y <=5)
6. {
7. Console.WriteLine("hi");
8. Main(args);
9. }
10. Console.ReadLine();
11. }
a) hihi
b) hi
c) Stack overflow exception
d) None of the mentioned
59. Correct way to define object of sample class in which C# 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);
11 | P a g e
Department of Computer Science and Engineering
60. 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
62. Which method has the same name as that of its class?
a) delete
b) class
c) constructor
d) none of the mentioned
63. Which operator among the following signifies the destructor operator?
a) ::
b) :
c) ~
d) &
64. Name a method which has the same name as that of class and which is used to destroy objects
also called automatically when application is finally on process of being getting terminated.
a) Constructor
b) Finalize()
c) Destructor
d) End
12 | P a g e
Department of Computer Science and Engineering
68. What will be the output of the following C# code?
class box{
publicint volume;
int width;
int height;
int length;
public box (int w, int h, int l)
{
this.width= w;
this.height= h;
this.length= l;
}
. ~ box()
{
volume =this.width*this.length*this.height;
console.writeline(volume);
}
}
class Program
{
public static void Main(string[]args)
{
box b =new box(4, 5, 9);
Console.ReadLine();
}
}
a) 0
b) Code executes successfully but prints nothing
c) Compile time error
d) 180
70. Choose the operator/operators which is/are not used to access the [] operator in indexers?
a) get
b) set
c) access
d) all of the mentioned
13 | P a g e
Department of Computer Science and Engineering
72. Which among the following are the advantages of using indexers?
a) To use collection of items at a large scale we make use of indexers as they utilize objects of class that
represent the collection as an array
b) Indexers are also convenient as they can also make use of different types of indexers like int, string etc
c) An indexer allows an object to be indexed such as an array
d) All of the mentioned
73. Choose the correct option among the following indexers which correctly allows to index in same
way as an array?
a) A class
b) An interface
c) A function
d) A property
76. Consider a class maths and we had a property called a sum.b is a reference to a maths object and
we want the statement b.sum = 10 to fail. Which of the following is the correct solution to ensure
this functionality?
a) Declare sum property with both get and set accessors
b) Declare sum property with only get accessor
c) Declare sum property with get, set and normal accessors
d) None of the mentioned
77. Consider a class maths and we had a property called as sum.b which is the reference to a maths
object and we want the statement Console.WriteLine(b.sum)to fail. Which among the following is
the correct solution to ensure this functionality?
a) Declares sum property with only get accessor
b) Declares sum property with only set accessor
c) Declares sum property with both set and get accessor
d) Declares sum property with both set, get and normal accessor
14 | P a g e
Department of Computer Science and Engineering
80. Select the correct statement about an Exception?
a) It occurs during loading of program
b) It occurs during Just-In-Time compilation
c) It occurs at run time
d) All of the mentioned
a) csharp
b) java
c) run time error
d) csharp 0
85. Which of the following is the wrong statement about exception handling in C#.NET?
a) finally clause is used to perform cleanup operations of closing network and database connections
b) a program can contain multiple finally clauses
c) the statement in final clause will get executed no matter whether an exception occurs or not
d) all of the mentioned
15 | P a g e
Department of Computer Science and Engineering
86. What will be the output of the following C# code?
1. class Program
2. {
3. staticvoid Main(string[]args)
4. {
5. try
6. {
7. Console.WriteLine("csharp"+" "+1/0);
8. }
9. finally
10. {
11. Console.WriteLine("Java");
12. }
13. Console.ReadLine();
14. }
15. }
a) csharp 0
b) Run time Exception generation
c) Compile time error
d) Java
1. {
2. try
3. {
4. int[]a ={1, 2, 3, 4, 5};
5. for(inti=0;i<5;++i)
6. Console.WriteLine(a[i]);
7. int x =(1/ Convert.ToInt32(0));
8. }
9. catch(IndexOutOfRangeException e)
10. {
11. Console.WriteLine("A");
12. }
13. catch(ArithmeticException e)
14. {
15. Console.WriteLine("B");
16. }
17. Console.ReadLine();
18. }
a) 1234
b) 12345
c) Run time error
d) 12345B
16 | P a g e
Department of Computer Science and Engineering
88. What will be the output of the following C# code?
1. {
2. try
3. {
4. int[]a ={1, 2, 3, 4, 5};
5. for(inti=0;i<7;++i)
6. Console.WriteLine(a[i]);
7. }
8. catch(IndexOutOfRangeException e)
9. {
10. Console.WriteLine("0");
11. }
12. Console.ReadLine();
13. }
a) 12345
b) 123450
c) 1234500
d) Compile time error
1. {
2. try
3. {
4. int a, b;
5. b =0;
6. a =10/ b;
7. Console.WriteLine("A");
8. }
9. catch(ArithmeticException e)
10. {
11. Console.WriteLine("B");
12. }
13. Console.ReadLine();
14. }
a) A
b) B
c) Compile time error
d) Run time error
1. {
2. try
3. {
4. inti, sum;
5. sum =10;
17 | P a g e
Department of Computer Science and Engineering
6. for(i=-1;i<3;++i)
7. {
8. sum =(sum /i);
9. Console.WriteLine(i);
10. }
11. }
12. catch(ArithmeticException e)
13. {
14. Console.WriteLine("0");
15. }
16. Console.ReadLine();
17. }
a) -1
b) 0
c) -1 0
d) -1 0 -1
1. {
2. try
3. {
4. int a, b;
5. b =0;
6. a =5/ b;
7. Console.WriteLine("A");
8. }
9. catch(ArithmeticException e)
10. {
11. Console.WriteLine("B");
12. }
13. finally
14. {
15. Console.WriteLine("C");
16. }
17. Console.ReadLine();
18. }
a) A
b) B
c) B C
d) Run time error
92. When is no exception thrown at runtime then who will catch it?
a) CLR
b) Operating System
c) Loader
d) Compiler
18 | P a g e
Department of Computer Science and Engineering
93. What will be the output of the following C# code?
1. publicstaticvoid Main(string[]args)
2. {
3. try
4. {
5. int a, b, c =5;
6. b =0;
7. a = c / b;
8. Console.WriteLine("A");
9. }
10. catch(ArithmeticException e)
11. {
12. int c =5;
13. inti=10;
14. int z =2* c -i;
15. Console.WriteLine("B");
16. Console.WriteLine(z);
17. }
18. Console.ReadLine();
19. }
a) Compile time error
b) Run time error
c) B 0
d) B
94. Choose the correct statement which makes exception handling work in C#.NET?
a) .Net runtime makes search for the exception handler where exception occurs
b) If no exception is matched, exception handler goes up the stack and hence finds the match there
c) If no match is found at the highest level of stack call, then unhandledException is generated and hence
termination of program occurs
d) All of the mentioned
95. Which of these clauses will be executed even if no exceptions are found?
a) throws
b) finally
c) throw
d) catch
19 | P a g e
Department of Computer Science and Engineering
97. What will be the output of the following C# code snippet?
1. class program
2. {
3. publicstaticvoid Main(string[]args)
4. {
5. try
6. {
7. thrownewNullReferenceException("C");
8. Console.WriteLine("A");
9. }
10. catch(ArithmeticException e)
11. {
12. Console.WriteLine("B");
13. }
14. Console.ReadLine();
15. }
16. }
a) A
b) B
c) Compile time error
d) Runtime error
1. class Program
2. {
3. publicstaticvoid Main(string[]args)
4. {
5. try
6. {
7. int a =1;
8. int b =10/ a;
9. try
10. {
11. if(a ==1)
12. a = a / a - a;
13. if(a ==2)
14. {
15. int[] c ={1};
16. c[8]=9;
17. }
18. }
19. finally
20. {
21. Console.WriteLine("A");
22. }
23. }
24. catch(IndexOutOfRangeException e)
25. {
26. Console.WriteLine("B");
20 | P a g e
Department of Computer Science and Engineering
27. }
28. Console.ReadLine();
29. }
30. }
a) A
b) B
c) AB
d) BA
1. class Program
2. {
3. publicstaticvoid Main(string[]args)
4. {
5. try
6. {
7. int a =args.Length;
8. int b =10/ a;
9. Console.WriteLine(a);
10. try
11. {
12. if(a ==1)
13. a = a / a - a;
14. if(a ==2)
15. {
16. int[] c ={1};
17. c[8]=9;
18. }
19. }
20. catch(IndexOutOfRangeException e)
21. {
22. Console.WriteLine("TypeA");
23. }
24. }
25. catch(ArithmeticException e)
26. {
27. Console.WriteLine("TypeB");
28. }
29. Console.ReadLine();
30. }
31. }
a) TypeA
b) TypeB
c) 0TypeA
d) Compile time error
21 | P a g e
Department of Computer Science and Engineering
100. Which of the following keywords is used by the calling function to guard against the exception
that is thrown by called function?
a) try
b) throw
c) throws
d) catch
101. Which of these classes is related to all the exceptions that are explicitly thrown?
a) Error
b) Exception
c) Throwable
d) Throw
102. Which of the classes provide 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
103. Which of the given stream methods provide access to the input console in C#.NET?
a) Console.Out
b) Console.Error
c) Console.In
d) All of the mentioned
104. The number of input methods defined by the stream method Console.In in C#.NET is?
a) 4
b) 3
c) 2
d) 1
106. Choose the output returned when read() reads the character from the console?
a) String
b) Char
c) Integer
d) Boolean
107. Choose the output returned when an error condition is generated while read() reads from the
console.
a) False
b) 0
c) -1
d) All of the mentioned
22 | P a g e
Department of Computer Science and Engineering
108. What will be the output of the following C# code?
1. staticvoid Main(string[]args)
2. {
3. Console.WriteLine("This is a Console Application:");
4. Console.Write("Please enter your lucky number:");
5. string val1 =Console.ReadLine();
6. int val2 =System.Convert.ToInt32(val1, 10);
7. val2 = val2 * val2;
8. Console.WriteLine("square of number is:"+val2);
9. Console.Read();
10. }
a) Compile time error
b) Runs successfully does not print anything
c) Runs successfully, ask for input and hence displays the result
d) Syntax Error
109. Select the objects of the class TextWriter which is/are not used to perform the write operations
to the console?
a) Write()
b) WriteLine()
c) WriteError()
d) All of the mentioned
1. staticvoid Main(string[]args)
2. {
3. StringBuildersb=newStringBuilder("hello world");
4. sb.Insert(6, "good");
5. Console.WriteLine(sb);
6. Console.ReadLine();
7. }
a) hello 6world
b) hello good world
c) hello goodworld
d) hello good world
23 | P a g e
Department of Computer Science and Engineering
112. What will be the output of the following C# code snippet?
1. staticvoid Main(string[]args)
2. {
3. StringBuildersb=newStringBuilder("hello world");
4. sb.Insert(6, "good");
5. Console.WriteLine(sb);
6. Console.ReadLine();
7. }
a) hello 6world
b) hello good world
c) hello goodworld
d) hello good world
113. Which of these classes is used to create an object whose character sequence is mutable?
a) String()
b) StringBuilder()
c) String() &StringBuilder()
d) None of the mentioned
115. The ‘ref’ keyword can be used with which among the following?
a) Static function/subroutine
b) Static data
c) Instance function/subroutine
d) All of the mentioned
116. Suppose a Generic class called as SortObjects is to be made capable of sorting objects of any
type(integer, single, byte etc). Then, which of the following programming constructs is able to
implement the comparison function?
a) interface
b) encapsulation
c) delegate
d) attribute
117. To generate a simple notification for an object in runtime, the programming construct to be
used for implementing this idea?
a) namespace
b) interface
c) delegate
d) attribute
24 | P a g e
Department of Computer Science and Engineering
118. Which among the following is the correct statement about delegate declaration?
119. Which among the following differentiates a delegate in C#.NET from a conventional function
pointer in other languages?
a) delegates in C#.NET represent a new type in the Common Type System
b) delegates allows static as well as instance methods to be invoked
c) delegates are type safe and secure
d) none of the mentioned
1. {
2. delegatevoid A(refstringstr);
3. class sample
4. {
5. publicstaticvoid fun(refstring a)
6. {
7. a =a.Substring(7, a.Length-7);
8. }
9. }
10. class Program
11. {
12. staticvoid Main(string[]args)
13. {
14. A str1;
15. stringstr="Test Your C#.net skills";
16. str1 = sample.fun;
17. str1(refstr);
18. Console.WriteLine(str);
19. }
20. }
21. }
a) Test Your
b) ur C#.NET
c) ur C#.NET Skills
d) None of the mentioned
25 | P a g e
Department of Computer Science and Engineering
122. What will be the output of the following C# code snippet?
1. {
2. delegatestring F(stringstr);
3. class sample4. {
5. publicstaticstring fun(string a)6. {
7. returna.Replace(',''-');8. }
9. }
10. class Program
11. {
12. staticvoid Main(string[]args)
13. {
14. F str1 =new F(sample.fun);
15. stringstr= str1("Test Your c#.NET skills");
16. Console.WriteLine(str);
17. }
18. }
19. }
a) Test Your
b) Test-Your-C#.NET-Skills
c) ur C#.NET Skills
d) None of the mentioned
123. Which of the following are the correct statements about delegates?
a) Delegates can be used to implement callback notification
b) Delegates permit execution of a method on a secondary thread in an asynchronous manner
c) Delegate is a user defined type
d) All of the mentioned
125. Select the modifiers which control the accessibility of the delegate?
a) new
b) protected
c) public
d) all of the mentioned
126. The process of defining two or more methods within the same class that have same name but
different parameters list?
a) Method overloading
b) Method overriding
c) Encapsulation
d) None of the mentioned
26 | P a g e
Department of Computer Science and Engineering
127. Which of these can be overloaded?
a) Constructors
b) Methods
c) Both Constructors & Methods
d) None of the mentioned
1. class maths
2. {
3. publicint x;
4. publicdouble y;
5. publicintadd(int a, int b)
6. {
7. x = a + b;
8. return x;
9. }
10. publicintadd(double c, double d)
11. {
12. y = c + d;
13. return(int)y;
14. }
15. public maths()
16. {
17. this.x=0;
18. this.y=0;
19. }
20. }
21. class Program
22. {
23. staticvoid Main(string[]args)
24. {
25. maths obj=new maths();
26. int a =4;
27. double b =3.5;
28. obj.add(a, a);
29. obj.add(b, b);
30. Console.WriteLine(obj.x+" "+obj.y);
31. Console.ReadLine();
32. }
33. }
a) 4, 3.5
b) 8, 0
c) 7.5, 8
d) 8, 7
129. What is the process of defining a method in terms of itself, that is a method that calls itself?
a) Polymorphism
b) Abstraction
c) Encapsulation
d) Recursion
27 | P a g e
Department of Computer Science and Engineering
130. What will be the output of the following C# code?
1. class maths
2. {
3. publicint fun(int k, int y)
4. {
5. return k + y;
6. }
7. publicint fun1(int t, float z)
8. {
9. return(t+(int)z);
10. }
11. }
12. class Program
13. {
14. staticvoid Main(string[]args)
15. {
16. maths obj=new maths();
17. inti;
18. int b =90;
19. int c =100;
20. int d =12;
21. float l = 14.78f;
22. i=obj.fun(b, c);
23. Console.WriteLine(i);
24. int j =(obj.fun1(d, l));
25. Console.WriteLine(j);
26. Console.ReadLine();
27. }
28. }
a) 190, 26.78f
b) 0, 26.78f
c) 190, 26
d) 190, 0
131. 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
28 | P a g e
Department of Computer Science and Engineering
133. In an inheritance chain through which of the following, the base class and its components are
accessible to the derived class?
a) Scope resolution operator(:)
b) Class visibility modifiers (public,private etc.)
c) Dot operator (.)
d) All of the mentioned
134. In Inheritance concept, which of the following members of base class are accessible to derived
class members?
a) static
b) protected
c) private
d) shared
136. Which is the correct way to create an object of the given class abc?
a) Declaring existing class as sealed
b) Declaring existing class as override
c) Declaring existing class as overloads
d) Declaring existing class as shadows
138. If no access modifier for a class is specified, then class accessibility is defined as?
a) public
b) protected
c) private
d) internal
29 | P a g e
Department of Computer Science and Engineering
139. What will be size of the object created depicted by C# code snippet?
1. classbaseclass
2. {
3. privateint a;
4. protectedint b;
5. publicint c;
6. }
7. class derived :baseclass
8. {
9. privateint x;
10. protectedint y;
11. publicint z;
12. }
13. class Program
14. {
15. staticVoid Main(string[]args)
16. {
17. derived a =new derived();
18. }
19. }
a) 20 bytes
b) 12 bytes
c) 16 bytes
d) 24 bytes
1. class sample
2. {
3. public sample()
4. {
5. Console.WriteLine("THIS IS BASE CLASS constructor");
6. }
7. }
8. publicclass sample1 : sample
9. {
10.
11. }
12. class Program
13. {
14. staticvoid Main(string[]args)
15. {
16. sample1 obj=new sample1();
17. Console.ReadLine();
18. }
19. }
a) Code executes successfully prints nothing
b) This is base class constructor
c) Compile time error
d) None of the mentioned
30 | P a g e
Department of Computer Science and Engineering
141. Select the statement which should be added to the current C# code to get the output as 10 20?
1. classbaseclass
2. {
3. protectedint a =20;
4. }
5. class derived :baseclass
6. {
7. int a =10;
8. publicvoid math()
9. {
10. /* add code here */
11. }
12. }
a) Console.writeline( a + ” ” + this.a);
b) Console.Writeline( mybase.a + ” ” + a);
c) console.writeline(a + ” ” + base.a);
d) console.writeline(base.a + ” ” + a);
143. A class consists of two interfaces with each interface consisting of three methods. The class had
no instance data. Which of the following indicates the correct size of object created from this class?
a) 12 bytes
b) 16 bytes
c) 0 bytes
d) 24 bytes
144. Which of the following statements correctly define about the implementation of interface?
a) The calls to implementation of interface methods are routed through a method table
b) A class which implements an interface can explicitly implement members of that interface
c) One interface can be implemented in another interface
d) None of the mentioned
31 | P a g e
Department of Computer Science and Engineering
146. Which of the following is the correct way of implementing an interface addition by class
maths?
a) class maths : addition {}
b) class maths implements addition {}
c) class maths imports addition {}
d) none of the mentioned