

MCQOPTIONS
Saved Bookmarks
This section includes 1698 Mcqs, each offering curated multiple-choice questions to sharpen your General Awareness knowledge and support exam preparation. Choose a topic below to get started.
1101. |
What would be the output of given code snippet? public static void Main(string[] args) { try { int a, b, c = 5; b = 0; a = c / b; Console.WriteLine("A"); } catch (ArithmeticException e) { int c = 5; int i = 10; int z = 2 * c - i; Console.WriteLine("B"); Console.WriteLine(z); } Console.ReadLine(); } |
A. | Compile time error |
B. | Run time error |
C. | B 0 |
D. | B |
Answer» D. B | |
1102. |
What will be the output of the given code snippet? class program { public static void Main(string[] args) { try { int a = args.Length; int b = 1 / a; Console.WriteLine(a); } catch (ArithmeticException e) { Console.WriteLine("1"); } Console.ReadLine(); } } |
A. | 0 |
B. | 1 |
C. | Compile time error |
D. | Runtime error |
Answer» C. Compile time error | |
1103. |
What will be the output of given code snippet? class program { public static void Main(string[] args) { try { throw new NullReferenceException("C"); Console.WriteLine("A"); } catch (ArithmeticException e) { Console.WriteLine("B"); } Console.ReadLine(); } } |
A. | A |
B. | B |
C. | Compile time error |
D. | Runtime error |
Answer» E. | |
1104. |
What will be the output of the given code snippet? class Program { public static void Main(string[] args) { try { int a = 1; int b = 10 / a; try { if (a == 1) a = a / a - a; if (a == 2) { int[] c = { 1 }; c[8] = 9; } } finally { Console.WriteLine("A"); } } catch (IndexOutOfRangeException e) { Console.WriteLine("B"); } Console.ReadLine(); } } |
A. | A |
B. | B |
C. | AB |
D. | BA |
Answer» B. B | |
1105. |
What will be the output of the given code snippet? class Program { public static void Main(string[] args) { try { int a = args.Length; int b = 10 / a; Console.WriteLine(a); try { if (a == 1) a = a / a - a; if (a == 2) { int[] c = { 1 }; c[8] = 9; } } catch (IndexOutOfRangeException e) { Console.WriteLine("TypeA"); } } catch (ArithmeticException e) { Console.WriteLine("TypeB"); } Console.ReadLine(); } } |
A. | TypeA |
B. | TypeB |
C. | 0TypeA |
D. | Compile time error |
Answer» C. 0TypeA | |
1106. |
What would be the output of following code snippet? { try { int a, b; b = 0; a = 10 / b; Console.WriteLine("A"); } catch(ArithmeticException e) { Console.WriteLine("B"); } Console.ReadLine(); } |
A. | A |
B. | B |
C. | Compile time error |
D. | Run time error |
Answer» C. Compile time error | |
1107. |
What will be the output of the program? class Output { public static void main(String args[]) { try { int a = 10; int b = 5; int c = a / b - 5; Console.WriteLine("Hi"); } catch(Exception e) { Console.WriteLine("hello"); } } } |
A. | Hi |
B. | Hello |
C. | Hihello |
D. | Compile time error |
Answer» C. Hihello | |
1108. |
What is the output of this program? class Output { public static void main(String args[]) { try { int a = 5; int b = 10; int c = b / a - 5; Console.WriteLine("Csharp"); } } } |
A. | Csharp |
B. | Sharp |
C. | C |
D. | Compile time error |
Answer» E. | |
1109. |
What is the output of the given code snippet? class Output { public static void main(String args[]) { try { int a = 0; int b = 5; int c = a / b - 5; Console.WriteLine("C"); } finally { Console.WriteLine("sharp"); } } } |
A. | C |
B. | Sharp |
C. | Csharp |
D. | None of the mentioned |
Answer» D. None of the mentioned | |
1110. |
What will be the output of the code snippet? class Output { public static void main(String args[]) { try { int a = 10; int b = 5; int c = b - 5 / 5; Console.WriteLine("Hi"); } catch(Exception e) { Console.WriteLine("hello"); } } } |
A. | Hi |
B. | Hello |
C. | Hihello |
D. | Compile time error |
Answer» B. Hello | |
1111. |
Which of the following statements are correct about an enum used inC#.NET? 1. By default the first enumerator has the value equal to the number of elements present in the list. 2. The value of each successive enumerator is decreased by 1. 3. An enumerator contains white space in its name. 4. A variable cannot be assigned to an enum element. 5. Values of enum elements cannot be populated from a database. |
A. | 1, 2 |
B. | 3, 4 |
C. | 4, 5 |
D. | 1, 4 |
Answer» D. 1, 4 | |
1112. |
Which of the following statements is correct about the C#.NET code snippet given below? int a = 10; int b = 20; int c = 30; enum color: byte { red = a, green = b, blue = c } |
A. | Variables cannot be assigned to enum elements. |
B. | Variables can be assigned to any one of the enum elements. |
C. | Variables can be assigned only to the first enum element. |
D. | Values assigned to enum elements must always be successive values. |
Answer» B. Variables can be assigned to any one of the enum elements. | |
1113. |
Which of the following is the correct output for the C#.NET code snippet given below? enum color { red, green, blue } color c; c = color.red; Console.WriteLine(c); |
A. | 1 |
B. | -1 |
C. | Red |
D. | 0 |
Answer» D. 0 | |
1114. |
Which of the following will be the correct output for the C#.NET code snippet given below? enum color : int { red = -3, green, blue } Console.Write( (int) color.red + ", "); Console.Write( (int) color.green + ", "); Console.Write( (int) color.blue ); |
A. | -3, -2, -1 |
B. | -3, 0, 1 |
C. | 0, 1, 2 |
D. | Red, green, blue |
Answer» B. -3, 0, 1 | |
1115. |
Consider a class maths and we had a property called as sum.b is a reference to a maths object and we want the code below to work.Which is the correct solution to ensure this functionality? b.maths = 10; Console.WriteLine(b.maths); |
A. | Declare maths property with get and set accessors |
B. | Declare maths property with only get accessors |
C. | Declare maths property with only set accessors |
D. | Declare maths property with only get, set and normal accessors |
Answer» B. Declare maths property with only get accessors | |
1116. |
The correct way to implement a read only property add, in a math class is? class math { int ad; public int add { get { return ad; } } } b) class math { public int add { get { return ad; } } } c) class math { int ad; public int add { get { return ad; } set { ad = value; } } } |
A. | A |
B. | B |
C. | C |
D. | None of the mentioned |
Answer» B. B | |
1117. |
The correct way to implement a write only property add in a math class? a) class math { public int add { set { add = value; } } } b) class math { int ad; public int add { set { ad = value; } } } c) class math { int ad; public int add { get { return ad; } set { ad = value; } } } |
A. | A |
B. | B |
C. | C |
D. | None of the mentioned |
Answer» C. C | |
1118. |
What will be the output of following snippet of code? class number { private int num1; private int num2; public int anumber { get { return num1; } set { num1 = value; } } public int anumber1 { get { return num2; } set { num2 = value; } } } class Program { public static void Main(string[] args) { number p = new number(); p.anumber = 20; number k = new number(); k.anumber1 = 40; int m = p.anumber; int t = k.anumber1; int r = p.anumber + k.anumber1; Console.WriteLine("number = " +m); Console.WriteLine("number = " +t); Console.WriteLine("sum = " +r); Console.ReadLine(); } } |
A. | 0 |
B. | Compile time error |
C. | 60 |
D. | None of the mentioned |
Answer» D. None of the mentioned | |
1119. |
What will be the output of the following snippet of code? class number { private int num1 = 60; private int num2 = 20; public int anumber { get { return num1; } set { num1 = value; } } public int anumber1 { get { return num2; } set { num2 = value; } } } class Program { public static void Main(string[] args) { number p = new number(); number k = new number(); int m = p.anumber; int t = k.anumber1; int r = p.anumber * k.anumber1; Console.WriteLine("sum = " + r); Console.ReadLine(); } } |
A. | 0 |
B. | 120 |
C. | 1200 |
D. | Compile time error |
Answer» D. Compile time error | |
1120. |
What will be the output of the following snippet of code? class number { int length = 50; public int number1 { get { return length; } set { length = value; } } } class Program { public static void Main(string[] args) { number p = new number(); p.number1 = p.number1 + 40; int k = p.number1 * 3 / 9; Console.WriteLine(k); Console.ReadLine(); } } |
A. | 0 |
B. | 180 |
C. | 30 |
D. | Compile time error |
Answer» D. Compile time error | |
1121. |
What will be the output of the following snippet of code? class number { int length = 60; public int number1 { get { return length; } } } class Program { public static void Main(string[] args) { number p = new number(); int l; l = p.number1 + 40; int k = l * 3 / 4; Console.WriteLine(k); Console.ReadLine(); } } |
A. | 30 |
B. | 75 |
C. | 80 |
D. | 0 |
Answer» C. 80 | |
1122. |
What will be the output of the following snippet of code? class student { int []scores = new int[5] {23, 42, 54, 11, 65}; public int this[int index] { get { if (index < 5) return scores[index]; else { Console.WriteLine("invalid index"); return 0; } } set { if (index < 5) scores[index] = value; else Console.WriteLine("invalid index"); } } } class Program { public static void Main(string[] args) { student s = new student(); Console.WriteLine(s[4] + 8); Console.ReadLine(); } } |
A. | 73 |
B. | 37 |
C. | 0 |
D. | Run time error |
Answer» B. 37 | |
1123. |
The correct way to implement the property for which property reports the error invalid index if user attempts to cross bounds of the array for a student class with 5 intger arrays. a) class student { int []scores = new int[5] {23, 42, 54, 11, 65}; public int this[int index] { get { if (index < 5) return scores[index]; else { Console.WriteLine("invalid index"); return 0; } } set { if (index < 5) scores[index] = value; else Console.WriteLine("invalid index"); } } } b) class student { int []scores = new int[5] {23, 42, 54, 11, 65}; public int this[int index] { get { if (index < 5) return scores[index]; } } } c) class student { int []scores = new int[5]{23, 42, 54, 11, 65}; public int this[int index] { set { if (index < 5) return scores[index]; else { Console.WriteLine("invalid index"); return 0; } } } } |
A. | A |
B. | B |
C. | C |
D. | None of the mentioned |
Answer» B. B | |
1124. |
Which of the following statements is correct about the C#.NET code snippet given below? enum per { married, unmarried, divorced, spinster } per.married = 10; Console.WriteLine(per.unmarried); |
A. | The program will output a value 11. |
B. | The program will output a value 1. |
C. | The program will output a value 2. |
D. | The program will report an error since an enum element cannot be assigned a value outside the enum declaration. |
Answer» E. | |
1125. |
Which of the following is the correct output for the C#.NET code snippet given below? enum color: int { red, green, blue = 5, cyan, magenta = 10, yellow } Console.Write( (int) color.green + ", " ); Console.Write( (int) color.yellow ); |
A. | 2, 11 |
B. | 1, 11 |
C. | 2, 6 |
D. | 1, 5 |
Answer» C. 2, 6 | |
1126. |
Which of the following statements are correct about enum used in C#.NET? 1. Every enum is derived from an Object class. 2. Every enum is a value type. 3. There does not exist a way to print an element of an enum as a string. 4. Every enum is a reference type. 5. The default underlying datatype of an enum is int. |
A. | 1, 2, 5 |
B. | 1, 4 |
C. | 3, 5 |
D. | 2, 3, 4 |
Answer» B. 1, 4 | |
1127. |
Which of the following statements is correct about the C#.NET code snippet given below? enum color : byte { red = 500, green = 1000, blue = 1500 } |
A. | Byte values cannot be assigned to enum elements. |
B. | Enum elements should always take successive values. |
C. | Since 500, 1000, 1500 exceed the valid range of byte compiler will report an error. |
D. | Enum must always be of int type. |
Answer» D. Enum must always be of int type. | |
1128. |
Which of the following is the correct output for the C#.NET code snippet given below? enum color { red, green, blue } color c = color.red; Type t; t = c.GetType(); string[ ]str; str = Enum.GetNames(t); Console.WriteLine(str[ 0 ]); |
A. | Red |
B. | 0 |
C. | 1 |
D. | -1 |
Answer» B. 0 | |
1129. |
Which of the following statements are correct about the C#.NET code snippet given below? 1. To define a variable of type enum color in Main(), we should use the statement, color c; . 2. enum color being private it cannot be used in Main(). 3. We must declare enum color as public to be able to use it outside the class Sample. 4. To define a variable of type enum color in Main(), we should use the statement, Sample.color c; . 5. We must declare private enum color outside the class to be able to use it in Main(). namespace McqsMentorConsoleApplication ( class Sample { private enum color : int { red, green, blue } public void fun() { Console.WriteLine(color.red); } } class Program { static void Main(string[ ] args) { // Use enum color here } } } |
A. | 1, 2, 3 |
B. | 2, 3, 4 |
C. | 3, 4 |
D. | 4, 5 |
Answer» C. 3, 4 | |
1130. |
Which of the following statements are correct about an enum used in C#.NET? 1. An enum can be declared inside a class. 2. An enum can take Single, Double or Decimal values. 3. An enum can be declared outside a class. 4. An enum can be declared inside/outside a namespace. 5. An object can be assigned to an enum variable. |
A. | 1, 3, 4 |
B. | 2, 5 |
C. | 3, 4 |
D. | 2, 4, 5 |
Answer» B. 2, 5 | |
1131. |
An Account class has a property called accountNo and acc is a reference to a bank object and we want the C#.NET code snippet given below to work. Which of the following options will ensure this functionality? acc.accountNo = 10; Console.WriteLine(acc.accountNo); |
A. | Declare accountNo property with both get and set accessors. |
B. | Declare accountNo property with only get accessor. |
C. | Declare accountNo property with get, set and normal accessors. |
D. | Declare accountNo property with only set accessor. |
Answer» B. Declare accountNo property with only get accessor. | |
1132. |
Suppose a Student class has an indexed property. This property is used to set or retrieve values to/from an array of 5 integers called scores[]. We want the property to report Invalid Index message if the user attempts to exceed the bounds of the array. Which of the following is the correct way to implement this property? |
A. | class Student { int[] scores = new int[5] {3, 2, 4,1, 5}; public int this[ int index ] { set { if (index < 5) scores[index] = value; else Console.WriteLine("Invalid Index"); } } } |
B. | class Student { int[] scores = new int[5] {3, 2, 4, 1, 5}; public int this[ int index ] { get { if (index < 5) return scores[ index ]; else { Console.WriteLine("Invalid Index"); return 0; } } set { if (index < 5) scores[ index ] = value; else Console.WriteLine("Invalid Index"); } } } |
C. | class Student { int[] scores = new int[5] {3, 2, 4, 1, 5}; public int this[ int index ] { get { if (index < 5) return scores[ index ]; else { Console.WriteLine("Invalid Index"); return 0; } } } } |
D. | class Student { int[] scores = new int[5] {3, 2, 4, 1, 5}; public int this[ int index ] { get { if (index < 5) scores[ index ] = value; else { Console.WriteLine("Invalid Index"); } } set { if (index < 5) return scores[ index ]; else { Console.WriteLine("Invalid Index"); return 0; } } } } |
Answer» C. class Student { int[] scores = new int[5] {3, 2, 4, 1, 5}; public int this[ int index ] { get { if (index < 5) return scores[ index ]; else { Console.WriteLine("Invalid Index"); return 0; } } } } | |
1133. |
Which of the folowing does an indexer allow to index in the same way as an array? 1. A class 2. A property 3. A struct 4. A function 5. An interface |
A. | 1, 3, 5 |
B. | 2, 4 |
C. | 3, 5 |
D. | 3, 4, 5 |
Answer» B. 2, 4 | |
1134. |
Which of the following statements is correct about the C#.NET code snippet given below? interface IMyInterface { void fun1(); int fun2(); } class MyClass: IMyInterface { void fun1() { } int IMyInterface.fun2() { } } |
A. | A function cannot be declared inside an interface. |
B. | A subroutine cannot be declared inside an interface. |
C. | A Method Table will not be created for class MyClass. |
D. | The definition of fun1() in class MyClass should be void IMyInterface.fun1(). |
Answer» E. | |
1135. |
Which of the following can be declared in an interface? 1. Properties 2. Methods 3. Enumerations 4. Events 5. Structures |
A. | 1, 3 |
B. | 1, 2, 4 |
C. | 3, 5 |
D. | 4, 5 |
Answer» C. 3, 5 | |
1136. |
Which of the following statements are correct about an interface in C#.NET? 1. A class can implement multiple interfaces. 2. Structures cannot inherit a class but can implement an interface. 3. In C#.NET, : is used to signify that a class member implements a specific interface. 4. An interface can implement multiple classes. 5. The static attribute can be used with a method that implements an interface declaration. |
A. | 1, 2, 3 |
B. | 2, 4 |
C. | 3, 5 |
D. | None of the above. |
Answer» B. 2, 4 | |
1137. |
Which of the following is the correct implementation of the interface given below? interface IMyInterface { double MyFun(Single i); } |
A. | class MyClass { double MyFun(Single i) as IMyInterface.MyFun { // Some code } } |
B. | class MyClass { MyFun (Single i) As Double { // Some code } } |
C. | class MyClass: implements IMyInterface { double fun(Single si) implements IMyInterface.MyFun() { //Some code } } |
D. | class MyClass: IMyInterface { double IMyInterface.MyFun(Single i) { // Some code } } |
Answer» E. | |
1138. |
In which of the following areas are delegates commonly used? 1. Remoting 2. Serialization 3. File Input/Output 4. Multithreading 5. Event handling |
A. | 1 and 2 only |
B. | 1 and 5 only |
C. | 1, 2 and 3 only |
D. | 4 and 5 only |
Answer» E. | |
1139. |
Which of the following statements are correct about the delegate declaration given below? delegate void del(int i); 1. On declaring the delegate a class called del will get created. 2. The signature of del need not be same as the signature of the method that we intend to call using it. 3. The del class will be derived from the MulticastDelegate class. 4. The method that can be called using del should not be a static method. 5. The del class will contain a one-argument constructor and an lnvoke() method. |
A. | 1, 2 and 3 only |
B. | 1, 3 and 5 only |
C. | 2 and 4 only |
D. | 4 only |
Answer» C. 2 and 4 only | |
1140. |
Which of the following is the correct way to call the function MyFun() of the Sample class given below? class Sample { public int MyFun(int i) { Console.WriteLine("Welcome to Mcqsmentor.com !" ); return 0; } } |
A. | delegate void del(int i); Sample s = new Sample(); deld = new del(ref s.MyFun); d(10); |
B. | delegate int del(int i); Sample s = new Sample(.); del = new delegate(ref MyFun); del(10); |
C. | Sample s = new Sample(); delegate void del = new delegate(ref MyFun); del(10); |
D. | delegate int del(int i); del d; Sample s = new Sample(); d = new del(ref s.MyFun); d(10); |
Answer» E. | |
1141. |
Which of the following statements are correct about a delegate? 1. Inheritance is a prerequisite for using delegates. 2. Delegates are type-safe. 3. Delegates provide wrappers for function pointers. 4. The declaration of a delegate must match the signature of the method that we intend to call using it. 5. Functions called using delegates are always late-bound. |
A. | 1 and 2 only |
B. | 1, 2 and 3 only |
C. | 2, 3 and 4 only |
D. | All of the above |
Answer» D. All of the above | |
1142. |
Which of the following is the correct way to call subroutine MyFun() of the Sample class given below? class Sample { public void MyFun(int i, Single j) { Console.WriteLine("Welcome to McqsMentor!"); } } |
A. | delegate void del(int i); Sample s = new Sample(); del d = new del(ref s.MyFun); d(10, 1.1f); |
B. | delegate void del(int i, Single j); del d; Sample s = new Sample(); d = new del(ref s.MyFun); d(10, 1.1f); |
C. | Sample s = new Sample(); delegate void d = new del(ref MyFun); d(10, 1.1f); |
D. | delegate void del(int i, Single]); Sample s = new Sample(); del = new delegate(ref MyFun); del(10, 1.1f); |
Answer» C. Sample s = new Sample(); delegate void d = new del(ref MyFun); d(10, 1.1f); | |
1143. |
Which of the following statements are correct about delegates? 1. Delegates are not type-safe. 2. Delegate is a user-defined type. 3. Only one method can be bound with one delegate object. 4. Delegates can be used to implement callback notification. 5. Delegates permit execution of a method on a secondary thread in an asynchronous manner. |
A. | 1 and 2 only |
B. | 1, 2 and 3 only |
C. | 2, 4 and 5 only |
D. | 4 and 5 only |
Answer» D. 4 and 5 only | |
1144. |
Which of the following are the correct ways to declare a delegate for calling the function func() defined in the sample class given below? class Sample { public int func(int i, Single j) { /* Add code here. */ } } |
A. | Delegate d(int i, Single j), |
B. | Delegate void d(int, Single), |
C. | Delegate int d(int i, Single j), |
D. | Delegate void (int i, Single j), |
Answer» D. Delegate void (int i, Single j), | |
1145. |
Which of the following statements are correct about an interface used in C#.NET? 1. An interface can contain properties, methods and events. 2. The keyword must implement forces implementation of an interface. 3. Interfaces can be overloaded. 4. Interfaces can be implemented by a class or a struct. 5. Enhanced implementations of an interface can be developed without breaking existing code. |
A. | 1, 2 |
B. | 1, 4, 5 |
C. | 3, 4 |
D. | 3 only |
Answer» C. 3, 4 | |
1146. |
Choose the correct way to call subroutine fun() of the sample class? class a { public void x(int p, double k) { Console.WriteLine("k : csharp!"); } } |
A. | delegate void del(int i); x s = new x(); del d = new del(ref s.x); d(8, 2.2f); |
B. | delegate void del(int p, double k); del d; x s = new x(); d = new del(ref s.x); d(8, 2.2f); |
C. | x s = new x(); delegate void d = new del(ref x); d(8, 2.2f); |
D. | All of the mentioned |
Answer» C. x s = new x(); delegate void d = new del(ref x); d(8, 2.2f); | |
1147. |
Which of the following can implement an interface? 1. Data 2. Class 3. Enum 4. Structure 5. Namespace |
A. | 1, 3 |
B. | 2, 4 |
C. | 3, 5 |
D. | 4 only |
Answer» C. 3, 5 | |
1148. |
Which of the following is the correct way to call the function abc() of the given class csharp given below? class csharp { public int abc(int a) { Console.WriteLine("A:Just do it!"); return 0; } } |
A. | delegate void del(int a); csharp s = new csharp(); del d = new del(ref s.abc); d(10); |
B. | csharp s = new csharp(); delegate void d = new del(ref abc); d(10); |
C. | delegate int del(int a); del d; csharp s = new csharp(); d = new del(ref s.fun); d(10); |
D. | None of the mentioned |
Answer» D. None of the mentioned | |
1149. |
Which of the following is the correct way to call the subroutine function abc() of the given class csharp given below? class csharp { void abc() { console.writeline("A:Just do it!"); } } |
A. | csharp c = new csharp(); delegate void d = new del(ref abc); d(); |
B. | delegate void del(); del d; csharp s = new csharp(); d = new del(ref s.abc); d(); |
C. | csharp s = new csharp(); delegate void del = new delegate(ref abc); del(); |
D. | None of the mentioned |
Answer» C. csharp s = new csharp(); delegate void del = new delegate(ref abc); del(); | |
1150. |
What will be the output of the given code snippet below? { delegate void A(ref string str); class sample { public static void fun( ref string a) { a = a.Substring( 7, a.Length - 7); } } class Program { static void Main(string[] args) { A str1; string str = "Test Your C#.net skills"; str1 = sample.fun; str1(ref str); Console.WriteLine(str); } } } |
A. | Test Your |
B. | Ur C#.NET |
C. | Ur C#.NET Skills |
D. | None of the mentioned |
Answer» D. None of the mentioned | |