

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.
1201. |
What will be the output for the given set of code? class A { public virtual void display() { Console.WriteLine("A"); } } class B: A { public override void display() { Console.WriteLine(" B "); } } class Program { static void Main(string[] args) { A obj1 = new A(); B obj2 = new B(); A r; r = obj1; r.display(); r = obj2; r.display(); Console.ReadLine(); } } |
A. | A, A |
B. | B, B |
C. | Compile time error |
D. | A, B |
Answer» E. | |
1202. |
The modifier used to hide the base class methods is ? |
A. | Virtual |
B. | New |
C. | Override |
D. | Sealed |
Answer» C. Override | |
1203. |
To override a method in subclass, baseclass method should be defined as? |
A. | Virtual |
B. | Abstract |
C. | Override |
D. | All of the mentioned |
Answer» E. | |
1204. |
What will be the output for the given set of code? class a { public void fun() { Console.WriteLine("base method"); } } class b: a { public new void fun() { Console.WriteLine(" derived method "); } } class Program { static void Main(string[] args) { b k = new b(); k.fun(); Console.ReadLine(); } } |
A. | Base method |
B. | Derived method |
C. | Code runs successfully prints nothing |
D. | Compile time error |
Answer» C. Code runs successfully prints nothing | |
1205. |
What will be the output of the given set of code? class maths { public int length; public int breadth; public maths(int x, int y) { length = x; breadth = y; Console.WriteLine(x + y); } public maths(double x, int y) { length = (int)x; breadth = y; Console.WriteLine(x * y); } } class Program { static void Main(string[] args) { maths m = new maths(20, 40); maths k = new maths(12.0, 12); Console.ReadLine(); } } |
A. | 60, 24 |
B. | 60, 0 |
C. | 60, 144 |
D. | 60, 144.0 |
Answer» D. 60, 144.0 | |
1206. |
What will be the output of the given set of code? class maths { public int length; public int breadth; public maths(int x) { length = x + 1; } public maths(int x, int y) { length = x + 2; } } class Program { static void Main(string[] args) { maths m = new maths(6); maths k = new maths(6, 2); Console.WriteLine(m.length); Console.WriteLine(k.length); Console.ReadLine(); } } |
A. | 8, 8 |
B. | 0, 2 |
C. | 8, 10 |
D. | 7, 8 |
Answer» E. | |
1207. |
What will be the output of the given set of code? class maths { int i; public maths(int x) { i = x; Console.WriteLine(" hello: "); } } class maths1 : maths { public maths1(int x) :base(x) { Console.WriteLine("bye"); } } class Program { static void Main(string[] args) { maths1 k = new maths1(12); Console.ReadLine(); } } |
A. | Hello bye |
B. | 12 hello |
C. | Bye 12 |
D. | Compile time error |
Answer» B. 12 hello | |
1208. |
What will be the output of the given set of code? class maths { int i; public maths(int ii) { ii = 12; int j = 12; int r = ii * j; Console.WriteLine(r); } } class maths1 : maths { public maths1(int u) :base(u) { u = 13; int h = 13; Console.WriteLine(u + h); } } class maths2 : maths1 { public maths2(int k) :base(k) { k = 24; int o = 6 ; Console.WriteLine(k /o); } } class Program { static void Main(string[] args) { maths2 t = new maths2(10); Console.ReadLine(); } } |
A. | 4, 26, 144 |
B. | 26, 4, 144 |
C. | 144, 26, 4 |
D. | 0, 0, 0 |
Answer» D. 0, 0, 0 | |
1209. |
What will be the output of the given set of code? class maths { static maths() { int s = 8; Console.WriteLine(s); } public maths(int f) { int h = 10; Console.WriteLine(h); } } class Program { static void Main(string[] args) { maths p = new maths(0); Console.ReadLine(); } } |
A. | 10, 10 |
B. | 0, 10 |
C. | 8, 10 |
D. | 8, 8 |
Answer» D. 8, 8 | |
1210. |
What will be the output for the given set of code? namespace ConsoleApplication4 { abstract class A { int i; public abstract void display(); } class B: A { public int j; public override void display() { Console.WriteLine(j); } } class Program { static void Main(string[] args) { B obj = new B(); obj.j = 2; obj.display(); Console.ReadLine(); } } } |
A. | 0 |
B. | 2 |
C. | Compile time error |
D. | 1 |
Answer» C. Compile time error | |
1211. |
What will be the output for the given set of code? namespace ConsoleApplication4 { abstract class A { public int i ; public int j ; public abstract void display(); } class B: A { public int j = 5; public override void display() { this.j = 3; Console.WriteLine(i + " " + j); } } class Program { static void Main(string[] args) { B obj = new B(); obj.i = 1; obj.display(); Console.ReadLine(); } } } |
A. | 1, 5 |
B. | 0, 5 |
C. | 1, 0 |
D. | 1, 3 |
Answer» E. | |
1212. |
What will be the output for the given set of code? namespace ConsoleApplication4 { public abstract class A { public int i = 7; public abstract void display(); } class B: A { public int j; public override void display() { Console.WriteLine(i); Console.WriteLine(j); } } class Program { static void Main(string[] args) { B obj = new B(); A obj1 = new B(); obj.j = 1; obj1.i = 8; obj.display(); Console.ReadLine(); } } } |
A. | 0, 8 |
B. | 1, 8 |
C. | 1, 7 |
D. | 7, 1 |
Answer» E. | |
1213. |
What will be the output for the given set of code? namespace ConsoleApplication4 { class A { public int i; public void display() { Console.WriteLine(i); } } class B: A { public int j; public void display() { Console.WriteLine(j); } } class Program { static void Main(string[] args) { B obj = new B(); obj.j = 1; obj.i = 8; obj.display(); Console.ReadLine(); } } } |
A. | 8, 1 |
B. | 8 |
C. | 1 |
D. | 1, 8 |
Answer» D. 1, 8 | |
1214. |
What would be output for the set of code? class maths { public int x; public double y; public int add(int a, int b) { x = a + b; return x; } public int add(double c, double d) { y = c + d; return (int)y; } public maths() { this.x = 0; this.y = 0; } } class Program { static void Main(string[] args) { maths obj = new maths(); int a = 4; double b = 3.5; obj.add(a, a); obj.add(b, b); Console.WriteLine(obj.x + " " + obj.y); Console.ReadLine(); } } |
A. | 4, 3.5 |
B. | 8, 0 |
C. | 7.5, 8 |
D. | 8, 7 |
Answer» E. | |
1215. |
What will be the output for the given set of code? class maths { public int fun(int k, int y) { return k + y; } public int fun1(int t, float z) { return (t+(int)z); } } class Program { static void Main(string[] args) { maths obj = new maths(); int i; int b = 90; int c = 100; int d = 12; float l = 14.78f; i = obj.fun(b, c); Console.WriteLine(i); int j = (obj.fun1(d, l)); Console.WriteLine(j); Console.ReadLine(); } } |
A. | 190, 26.78f |
B. | 0, 26.78f |
C. | 190, 26 |
D. | 190, 0 |
Answer» D. 190, 0 | |
1216. |
What will be the output for the given set of code? class maths { public int fun(int ii) { return(ii > 0 ? ii :ii * -1); } public long fun(long ll) { return(ll > 0 ? ll :ll * -1); } public double fun( double dd) { return(dd > 0 ? dd :dd * -1); } } class Program { static void Main(string[] args) { maths obj = new maths(); int i = -25; int j ; long l = -100000l ; long m; double d = -12.34; double e; j = obj.fun(i); m = obj.fun(l); e = obj.fun(d); Console.WriteLine(j + " " + m + " " + e); Console.ReadLine(); } } |
A. | 1 1 1 |
B. | 0 0 0 |
C. | 25 100000 12.34 |
D. | -25 -100000 -12.34 |
Answer» D. -25 -100000 -12.34 | |
1217. |
Which keyword is used to declare a base class method while performing overidding of base class methods? |
A. | This |
B. | Virtual |
C. | Override |
D. | Extend |
Answer» C. Override | |
1218. |
What would be output of the following set of code? class sample { public sample() { Console.WriteLine("THIS IS BASE CLASS constructor"); } } public class sample1 : sample { } class Program { static void Main(string[] args) { sample1 obj = new sample1(); Console.ReadLine(); } } |
A. | Code executes successfully prints nothing |
B. | This is base class constructor |
C. | Compile time error |
D. | None of the mentioned |
Answer» D. None of the mentioned | |
1219. |
Select the statement which should be added to the current set of code to get the output as 10 20 ? class baseclass { protected int a = 20; } class derived : baseclass { int a = 10; public void math() { /* add code here */ } } |
A. | console.writeline(base.a + + a); |
B. | Console.Writeline( mybase.a + + a); |
C. | console.writeline(a + + base.a); |
D. | console.writeline(base.a + + a); |
Answer» D. console.writeline(base.a + + a); | |
1220. |
Which statement should be added in function a() of class y to get output i love csharp ? class x { public void a() { console.write("bye"); } } class y : x { public void a() { /* add statement here */ console.writeline(" i love csharp "); } } class program { static void main(string[] args) { y obj = new obj(); obj.a(); } } |
A. | X.a(); |
B. | A(); |
C. | Base.a(); |
D. | X::a(); |
Answer» D. X::a(); | |
1221. |
Select the output for the following set of code? class A { public int i; protected int j; } class B : A { public int j; public void display() { base.j = 3; Console.WriteLine(i + " " + j); } } class Program { static void Main(string[] args) { B obj = new B(); obj.i = 1; obj.j = 2; obj.display(); Console.ReadLine(); } } |
A. | 2 1 |
B. | 1 0 |
C. | 0 2 |
D. | 1 2 |
Answer» E. | |
1222. |
Select the output of the following set of code? class A { public int i; private int j; } class B :A { void display() { base.j = base.i + 1; Console.WriteLine(base.i + " " + base.j); } } class Program { static void Main(string[] args) { B obj = new B(); obj.i = 1; obj.j = 2; obj.display(); Console.ReadLine(); } } |
A. | 1, 3 |
B. | 2, 3 |
C. | 1, 2 |
D. | Compile time error |
Answer» E. | |
1223. |
Correct output for the C#.NET code given below is? enum colors { red, black, pink } colors s = colors.black; type t; t = c.GetType(); string[] str; str = Enum.GetNames(t); Console.WriteLine(str[0]); |
A. | 0 |
B. | Black |
C. | Red |
D. | 1 |
Answer» D. 1 | |
1224. |
What does the following code signify? class a { } class b : a { variable declaration; method declaration; } |
A. | Declaration of a base class |
B. | Declaration of a sub class |
C. | Declaration of base class & sub class and how subclass inherits the base class |
D. | None of the mentioned |
Answer» D. None of the mentioned | |
1225. |
If base class consist of two private integers,one static integer and derived class consist of two static integers and one private integer.What would be the size of derived class object? |
A. | Size of object depends on sizes of its non static data members |
B. | Size of a derived class object is sum of sizes of non static data members of base class and derived class |
C. | Size of object is calculated using sizeof() method |
D. | None of the mentioned |
Answer» B. Size of a derived class object is sum of sizes of non static data members of base class and derived class | |
1226. |
Which of the following will be the correct output for the program given below? { struct abc { int i; } class Program { static void Main(string[] args) { abc x = new abc(); abc z; x.i = 10; z = x; z.i = 15; console.Writeline(x.i + " " + y.i) } } } |
A. | 10 10 |
B. | 10 15 |
C. | 15 10 |
D. | 15 15 |
Answer» C. 15 10 | |
1227. |
Choose the correct output for the C#.NET code given below? enum days:int { sunday = -3, monday, tuesday } Console.WriteLine((int)days.sunday); Console.WriteLine((int)days.monday); Console.WriteLine((int)days.tuesday); |
A. | -3 0 1 |
B. | 0 1 2 |
C. | -3 -2 -1 |
D. | Sunday monday tuesday |
Answer» D. Sunday monday tuesday | |
1228. |
Choose the correct statement about the C#.NET code given below? enum color:byte { yellow = 500, green = 1000, pink = 1300 } |
A. | Byte value cannot be assigned to enum elements |
B. | Enum elements should always take successive values |
C. | Enum must always be of int type |
D. | When the valid range of byte exceeds, the compiler will report an error |
Answer» E. | |
1229. |
Choose the correct output for given set of code? enum per { a, b, c, d, } per.a = 10; Console.writeline(per.b); |
A. | 11 |
B. | 1 |
C. | 2 |
D. | Compile time error |
Answer» E. | |
1230. |
Choose the correct output for given set of code? enum color:int { red, green, blue = 5, cyan, pink = 10, brown } console.writeline((int)color.green); console.writeline((int)color.brown); |
A. | 2 10 |
B. | 2 11 |
C. | 1 11 |
D. | 1 5 |
Answer» D. 1 5 | |
1231. |
Correct the output for the C#.NET code given below? enum letters { a, b, c } letters l; l = letters.a; Console.writeline(l); |
A. | -1 |
B. | 0 |
C. | A |
D. | Letters.a |
Answer» D. Letters.a | |
1232. |
Which of the following is correct about the C#.NET snippet given below? namespace McqsMentorConsoleApplication { class Baseclass { public void fun() { Console.WriteLine("Hi" + " "); } public void fun(int i) { Console.Write("Hello" + " "); } } class Derived: Baseclass { public void fun() { Console.Write("Bye" + " "); } } class MyProgram { static void Main(string[ ] args) { Derived d; d = new Derived(); d.fun(); d.fun(77); } } } |
A. | The program gives the output as: Hi Hello Bye |
B. | The program gives the output as: Bye Hello |
C. | The program gives the output as: Hi Bye Hello |
D. | Error in the program |
Answer» C. The program gives the output as: Hi Bye Hello | |
1233. |
What will be the output of the C#.NET code snippet given below? namespace McqsMentorConsoleApplication { class Baseclass { public void fun() { Console.Write("Base class" + " "); } } class Derived1: Baseclass { new void fun() { Console.Write("Derived1 class" + " "); } } class Derived2: Derived1 { new void fun() { Console.Write("Derived2 class" + " "); } } class Program { public static void Main(string[ ] args) { Derived2 d = new Derived2(); d.fun(); } } } |
A. | Base class |
B. | Derived1 class |
C. | Derived2 class |
D. | Base class Derived1 class |
Answer» B. Derived1 class | |
1234. |
In an inheritance chain which of the following members of base class are accessible to the derived class members? 1. static 2. protected 3. private 4. shared 5. public |
A. | 1, 3 |
B. | 2, 5 |
C. | 3, 4 |
D. | 4, 5 |
Answer» C. 3, 4 | |
1235. |
Which of the following are reuse mechanisms available in C#.NET? 1. Inheritance 2. Encapsulation 3. Templates 4. Containership 5. Polymorphism |
A. | 1, 4 |
B. | 1, 3 |
C. | 2, 4 |
D. | 3, 5 |
Answer» B. 1, 3 | |
1236. |
Which of the following statements are correct about Inheritance in C#.NET? 1. A derived class object contains all the base class data. 2. Inheritance cannot suppress the base class functionality. 3. A derived class may not be able to access all the base class data. 4. Inheritance cannot extend the base class functionality. 5. In inheritance chain construction of object happens from base towards derived. |
A. | 1, 2, 4 |
B. | 2, 4, 5 |
C. | 1, 3, 5 |
D. | 2, 4 |
Answer» D. 2, 4 | |
1237. |
Which of the following statements is correct about the C#.NET program given below? namespace McqsMentorConsoleApplication { class Baseclass { int i; public Baseclass(int ii) { i = ii; Console.Write("Base "); } } class Derived : Baseclass { public Derived(int ii) : base(ii) { Console.Write("Derived "); } } class MyProgram { static void Main(string[ ] args) { Derived d = new Derived(10); } } } |
A. | The program will work correctly only if we implement zero-argument constructors in Baseclass as well as Derived class. |
B. | The program will output: Derived Base |
C. | The program will report an error in the statement base(ii). |
D. | The program will output: Base Derived |
Answer» E. | |
1238. |
Which of the following unary operators can be overloaded? 1. true 2. false 3. + 4. new 5. is |
A. | 1, 2, 3 |
B. | 3, 4, 5 |
C. | 3 only |
D. | 5 only |
Answer» B. 3, 4, 5 | |
1239. |
Which among the following is the correct statement about delegate declaration ? delegate void del(int i); |
A. | On declaring the delegate, a class called del is created |
B. | The del class is derived from the MulticastDelegate class |
C. | The del class will contain a one argument constructor and an invoke() method |
D. | All of the mentioned |
Answer» E. | |
1240. |
Which of the following statements is correct about the C#.NET code snippet given below? interface IMyInterface { void fun1(); void fun2(); } class MyClass: IMyInterface { private int i; void IMyInterface.fun1() { // Some code } } |
A. | Class MyClass is an abstract class. |
B. | Class MyClass cannot contain instance data. |
C. | Class MyClass fully implements the interface IMyInterface. |
D. | The compiler will report an error since the interface IMyInterface is only partially implemented. |
Answer» E. | |
1241. |
Which of the following statements is correct about the C#.NET code snippet given below? interface IPerson { String FirstName { get; set; } String LastName { get; set; } void Print(); void Stock(); int Fun(); } |
A. | Properties cannot be declared inside an interface. |
B. | This is a perfectly workable interface. |
C. | The properties in the interface must have a body. |
D. | Subroutine in the interface must have a body. |
Answer» C. The properties in the interface must have a body. | |
1242. |
Which of the following is the correct way to implement the interface given below? interface IPerson { String FirstName { get; set; } } |
A. | class Employee : IPerson { private String str; public String FirstName { get { return str; } set { str = value; } } } |
B. | class Employee { private String str; public String IPerson.FirstName { get { return str; } set { str = value; } } } |
C. | class Employee : implements IPerson { private String str; public String FirstName { get { return str; } set { str = value; } } } |
D. | None of the above |
Answer» B. class Employee { private String str; public String IPerson.FirstName { get { return str; } set { str = value; } } } | |
1243. |
With which of the following can the ref keyword be used? 1. Static data 2. Instance data 3. Static function/subroutine 4. Instance function/subroutine |
A. | 1, 2 |
B. | 3, 4 |
C. | 1, 3 |
D. | 2, 4 |
Answer» C. 1, 3 | |
1244. |
Which one of the following classes are present System.Collections.Generic namespace? 1. Stack 2. Tree 3. SortedDictionary 4. SortedArray |
A. | 1 and 2 only |
B. | 2 and 4 only |
C. | 1 and 3 only |
D. | All of the above |
Answer» D. All of the above | |
1245. |
Which of the following will be the correct output for the C#.NET program given below? namespace McqsMentorConsoleApplication { class SampleProgram { static void Main(string[] args) { int num = 1; funcv(num); Console.Write(num + ", "); funcr(ref num); Console.Write(num + ", "); } static void funcv(int num) { num = num + 10; Console.Write(num + ", "); } static void funcr (ref int num) { num = num + 10; Console.Write(num + ", "); } } } |
A. | 1, 1, 1, 1, |
B. | 11, 1, 11, 11, |
C. | 11, 11, 11, 11, |
D. | 11, 11, 21, 11, |
Answer» C. 11, 11, 11, 11, | |
1246. |
What will be the output of the C#.NET code snippet given below? namespace McqsMentorConsoleApplication { class SampleProgram { static void Main(string[] args) { int[]arr = newint[]{ 1, 2, 3, 4, 5 }; fun(ref arr); } static void fun(ref int[] a) { for (int i = 0; i < a.Length; i++) { a[i] = a[i] * 5; Console.Write(a[ i ] + " "); } } } } |
A. | 1 2 3 4 5 |
B. | 6 7 8 9 10 |
C. | 5 10 15 20 25 |
D. | 5 25 125 625 3125 |
Answer» D. 5 25 125 625 3125 | |
1247. |
Which of the following statements are correct? 1. An argument passed to a ref parameter need not be initialized first. 2. Variables passed as out arguments need to be initialized prior to being passed. 3. Argument that uses params keyword must be the last argument of variable argument list of a method. 4. Pass by reference eliminates the overhead of copying large data items. 5. To use a ref parameter only the calling method must explicitly use the ref keyword. |
A. | 1, 2 |
B. | 2, 3 |
C. | 3, 4 |
D. | 4, 5 |
Answer» D. 4, 5 | |
1248. |
Which of the following statements are correct about functions and subroutines used in C#.NET? 1. A function cannot be called from a subroutine.2. The ref keyword causes arguments to be passed by reference.3. While using ref keyword any changes made to the parameter in the method will be reflected in that variable when control passes back to the calling method.4. A subroutine cannot be called from a function.5. Functions and subroutines can be called recursively. |
A. | 1, 2, 4 |
B. | 2, 3, 5 |
C. | 3, 5 |
D. | 4, 5 |
Answer» C. 3, 5 | |
1249. |
Which of the following will be the correct output for the C#.NET program given below? namespace McqsMentorConsoleApplication { class SampleProgram { static void Main(string[] args) { int a = 5; int s = 0, c = 0; Proc(a, ref s, ref c); Console.WriteLine(s + " " + c); } static void Proc(int x, ref int ss, ref int cc) { ss = x * x; cc = x * x * x; } } } |
A. | 0 0 |
B. | 25 25 |
C. | 125 125 |
D. | 25 125 |
Answer» E. | |
1250. |
What will be the output of the C#.NET code snippet given below? namespace McqsMentorConsoleApplication { class SampleProgram { static void Main(string[ ] args) { int i = 10; double d = 34.340; fun(i); fun(d); } static void fun(double d) { Console.WriteLine(d + " "); } } } |
A. | 10.000000 34.340000 |
B. | 10 34 |
C. | 10 34.340 |
D. | 10 34.34 |
Answer» E. | |