

MCQOPTIONS
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.
1451. |
Correct way of defining constructor of the given class as and when objects of classes are created is:
maths s1 = new maths(); maths s2 = new maths(5, 5.4f); a) public maths(int pp, single tt) { p = pp; t = tt; } b) sample s; c) public sample() { p = 0; t = 0.0f; } public sample(int pp, single tt) { p = pp; t = tt; } d) s = new sample(); |
A. | A |
B. | B |
C. | C |
D. | D |
Answer» B. B | |
1452. |
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); |
Answer» E. | |
1453. |
Which among the following is the correct statement :
|
A. | Initialize the objects |
B. | Construct the data members |
C. | Initialize the objects & construct the data members |
D. | None of the mentioned |
Answer» B. Construct the data members | |
1454. |
Output from following set of code ?
class sample { int i; double k; public sample (int ii, double kk) { i = ii; k = kk; double j = (i) + (k); Console.WriteLine(j); } ~sample() { double j = i - k; Console.WriteLine(j); } } class Program { static void Main(string[] args) { sample s = new sample(8, 2.5); Console.ReadLine(); } } |
A. | 0 0 |
B. | 10.5 0 |
C. | Compile time error |
D. | 10.5 5.5 |
Answer» E. | |
1455. |
What is output for the following set of Code ?
class box { public int volume; int width; int height; int length; public box ( int w, int h, int l) { width = w; height = h; length = l; } public ~box() { volume = width * length * height; } } class Program { static void Main(string[] args) { box b = new box(4, 5, 9); Console.WriteLine(b.volume); Console.ReadLine(); } } |
A. | 0 |
B. | 180 |
C. | Compile time error |
D. | None of the mentioned |
Answer» D. None of the mentioned | |
1456. |
Output from selective set of code is :
class box { public int 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 |
Answer» E. | |
1457. |
What will be the output of the given code snippet?
class access { public int x; private int y; public void cal(int a, int b) { x = a + 1; y = b; } } class Program { static void Main(string[] args) { access obj = new access(); obj.cal(2, 3); Console.WriteLine(obj.x + " " + obj.y); } } |
A. | 3 3 |
B. | 2 3 |
C. | Run time error |
D. | Compile time error |
Answer» E. | |
1458. |
What will be the output of the given code snippet?
class access { public int x; private int y; public void cal(int a, int b) { x = a + 1; y = b; } public void print() { Console.WriteLine(" " + y); } } class Program { static void Main(string[] args) { access obj = new access(); obj.cal(2, 3); Console.WriteLine(obj.x); obj.print(); Console.ReadLine(); } } |
A. | 2 3 |
B. | 3 3 |
C. | Run time error |
D. | Compile time error |
Answer» C. Run time error | |
1459. |
What will be the output of the following set of code?
class sum { public int x; public int y; public int add (int a, int b) { x = a + b; y = x + b; return 0; } } class Program { static void Main(string[] args) { sum obj1 = new sum(); sum obj2 = new sum(); int a = 2; obj1.add(a, a + 1); obj2.add(5, a); Console.WriteLine(obj1.x + " " + obj2.y); Console.ReadLine(); } } |
A. | 6, 9 |
B. | 5, 9 |
C. | 9, 10 |
D. | 3, 2 |
Answer» C. 9, 10 | |
1460. |
Which of the following statements is correct about the C#.NET code snippet given below?
namespace McqsMentorConsoleApplication { 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. |
Answer» C. Sample.fun(1, 5) will set a value 5 in arr[ 1 ]. | |
1461. |
Which of the following statements are correct about the C#.NET code snippet given below? sample c; c = new sample(); 1. It will create an object called sample. |
A. | 1, 3 |
B. | 2, 4 |
C. | 3, 5 |
D. | 4, 5 |
Answer» C. 3, 5 | |
1462. |
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. |
Answer» B. Since int is a primitive, we cannot use new with it. | |
1463. |
Which of the following statements are correct about the this reference?1. this reference can be modified in the instance member function of a class. |
A. | 1, 4 |
B. | 2, 3, 5 |
C. | 3, 4 |
D. | 2, 5 |
Answer» C. 3, 4 | |
1464. |
Which of the following will be the correct output for the C#.NET program given below?
namespace McqsMentorConsoleApplication { class Sample { int i; Single j; public void SetData(int i, Single j) { this.i = i; this.j = j; } public void Display() { Console.WriteLine(i + " " + j); } } class MyProgram { static void Main(string[ ] args) { Sample s1 = new Sample(); s1.SetData(36, 5.4f); s1.Display(); } } } |
A. | 0 0.0 |
B. | 36 5.4 |
C. | 36 5.400000 |
D. | 36 5 |
Answer» C. 36 5.400000 | |
1465. |
Which of the following statements are correct about objects of a user-defined class called Sample?1. All objects of Sample class will always have exactly same data. |
A. | 1, 3 |
B. | 2, 4 |
C. | 4, 5 |
D. | 3, 5 |
Answer» D. 3, 5 | |
1466. |
Which of the following statements are correct about the C#.NET code snippet given below?
namespace McqsMentorConsoleApplication { class Sample { int i, j; public void SetData(int ii, int jj) { this.i = ii; this.j = jj } } class MyProgram { static void Main(string[ ] args) { Sample s1 = new Sample(); s1.SetData(10, 2); Sample s2 = new Sample(); s2.SetData(5, 10); } } } |
A. | The code will not compile since we cannot explicitly use this. |
B. | Using this in this program is necessary to properly set the values in the object. |
C. | The call to SetData() is wrong since we have not explicitly passed the this reference to it. |
D. | Contents of this will be different during each call to SetData(). |
Answer» E. | |
1467. |
Which of the following statements are correct about the C#.NET code snippet given below?
class Sample { static int i; int j; public void proc1() { i = 11; j = 22; } public static void proc2() { i = 1; j = 2; } static Sample() { i = 0; j = 0; } } |
A. | I cannot be initialized in proc1(). |
B. | Proc1() can initialize i as well as j. |
C. | J can be initialized in proc2(). |
D. | The constructor can never be declared as static. |
Answer» C. J can be initialized in proc2(). | |
1468. |
What will be the output of the C#.NET code snippet given below?
namespace McqsMentorConsoleApplication { class Sample { static Sample() { Console.Write("Sample class "); } public static void Bits1() { Console.Write("Bits1 method "); } } class MyProgram { static void Main(string[ ] args) { Sample.Bits1(); } } } |
A. | Sample class Bits1 method |
B. | Bits1 method |
C. | Sample class |
D. | Bits1 method Sample class |
Answer» B. Bits1 method | |
1469. |
How much memory will be allocated for an object of class given below?
class Test{ int mark1; int mark2; float avg; char name[10]; }; |
A. | 22 Bytes |
B. | 24 Bytes |
C. | 20 Bytes |
D. | 18 Bytes |
Answer» B. 24 Bytes | |
1470. |
Which among function will be overridden from the function defined in derived class below:
class A { int i; void show() { cout<<i; } void print() { cout <<i; } }; class B { int j; void show() { cout<<j; } }; |
A. | Show() |
B. | Print() |
C. | Show() and print() |
D. | Compile time error |
Answer» B. Print() | |
1471. |
Which language doesn t support method overriding implicitly? |
A. | C++ |
B. | C# |
C. | Java |
D. | SmallTalk |
Answer» C. Java | |
1472. |
How many parameters must be passed if only the following prototype is given to a constructor?
|
A. | 1 |
B. | 2 |
C. | 3 |
D. | Compile time error |
Answer» C. 3 | |
1473. |
In which of the following collections is the Input/Output index-based?1. Stack |
A. | 1 and 2 only |
B. | 3 and 4 only |
C. | 5 only |
D. | 1, 2 and 5 only |
Answer» C. 5 only | |
1474. |
In which of the following collections is the Input/Output based on a key?1. Map |
A. | 1 and 2 only |
B. | 2 and 3 only |
C. | 1, 2 and 3 only |
D. | 4 and 5 only |
Answer» E. | |
1475. |
Which of the following statements are correct about the Stack collection?1. It can be used for evaluation of expressions. |
A. | 1 and 2 only |
B. | 3 and 4 only |
C. | 1, 2 and 5 only |
D. | All of the above |
Answer» D. All of the above | |
1476. |
A HashTable t maintains a collection of names of states and capital city of each state. Which of the following is the correct way to find out whether Kerala state is present in this collection or not? |
A. | T.ContainsKey("Kerala"), |
B. | T.HasValue("Kerala"), |
C. | T.HasKey("Kerala"), |
D. | T.ContainsState("Kerala"), |
Answer» B. T.HasValue("Kerala"), | |
1477. |
Which of the following is the correct way to access all elements of the Queue collection created using the C#.NET code snippet given below?
Queue q = new Queue();
Answer: A . |
A. | IEnumerator e; e = q.GetEnumerator(); while (e.MoveNext()) Console.WriteLine(e.Current); |
B. | IEnumerable e; e = q.GetEnumerator(); while (e.MoveNext()) Console.WriteLine(e.Current); |
C. | IEnumerator e; e = q.GetEnumerable(); while (e.MoveNext()) Console.WriteLine(e.Current); |
D. | IEnumerator e; e = Queue.GetEnumerator(); while (e.MoveNext()) Console.WriteLine(e.Current); |
Answer» B. IEnumerable e; e = q.GetEnumerator(); while (e.MoveNext()) Console.WriteLine(e.Current); | |
1478. |
Which of the following is an ordered collection class?1. Map |
A. | 1 only |
B. | 2 and 3 only |
C. | 4 and 5 only |
D. | All of the above |
Answer» C. 4 and 5 only | |
1479. |
Which of the following statements are correct about a HashTable collection?1. It is a keyed collection. |
A. | 1 and 2 only |
B. | 1, 2 and 3 only |
C. | 4 and 5 only |
D. | 1, 4 and 5 only |
Answer» E. | |
1480. |
Which of the following is the correct way to access all elements of the Stack collection created using the C#.NET code snippet given below?
Stack st = new Stack(); st.Push(11); st.Push(22); st.Push(-53); st.Push(33); st.Push(66); |
A. | IEnumerable e; e = st.GetEnumerator(); while (e.MoveNext()) Console.WriteLine(e.Current); |
B. | IEnumerator e; >e = st.GetEnumerable(); while (e.MoveNext()) Console.WriteLine(e.Current); |
C. | IEnumerator e; e = st.GetEnumerator(); while (e.MoveNext()) Console.WriteLine(e.Current); |
D. | IEnumerator e; e = Stack.GetEnumerator(); while (e.MoveNext()) Console.WriteLine(e.Current); |
Answer» D. IEnumerator e; e = Stack.GetEnumerator(); while (e.MoveNext()) Console.WriteLine(e.Current); | |
1481. |
For overloading ( ) , [ ] or -> operators, a class __________ |
A. | Must use static member functions |
B. | Must use non-static member functions |
C. | Must be non-static member and should not be friend of class |
D. | Must use static member function or a friend member function |
Answer» D. Must use static member function or a friend member function | |
1482. |
What will be the output of given code snippet?
class UnsafeCode { struct MyStruct { public int a; public int b; public int Sum() { return a / b; } } unsafe static void Main() { MyStruct o = new MyStruct(); MyStruct* p; p = &o; p->a = 60; p->b = 15; int c = 30; Console.WriteLine("Value is : " + p->Sum()*c); Console.ReadLine(); } } |
A. | Compile time error |
B. | 120 |
C. | Run time error |
D. | 4 |
Answer» C. Run time error | |
1483. |
What will be the output of given code snippet?
class UnsafeCode { unsafe static void Main() { int[] nums = new int[10]; fixed (int* p = &nums[0], p2 = nums) { if (p == p2) Console.WriteLine("p and p2 point to same address."); Console.ReadLine(); } } } |
A. | Run time error |
B. | Compile time error |
C. | P and p2 point to the same address |
D. | Only b |
Answer» D. Only b | |
1484. |
What will be the output of given code snippet?
class UnsafeCode { static void Main() { int? count = null; int? result = null; int incr = 10; result = count + incr; if (result.HasValue) Console.WriteLine("result has this value: " + result.Value); else Console.WriteLine("result has no value"); Console.ReadLine(); } } |
A. | Run time error |
B. | 0 |
C. | Result has no value |
D. | Compile time error |
Answer» D. Compile time error | |
1485. |
What will be the output of given code snippet?
class UnsafeCode { static void Main() { int count = 100; int? result = null; int incr = 10; result = count + incr; if (result.HasValue) Console.WriteLine("result has this value: " + result.Value); else Console.WriteLine("result has no value"); Console.ReadLine(); } } |
A. | Run time error |
B. | 110 |
C. | Result has no value |
D. | Compile time error |
Answer» C. Result has no value | |
1486. |
What will be the output of the given code snippet?
class a { public void x(int p, double k) { Console.WriteLine("k : csharp!"); } }public class Generic |
A. | 0 |
B. | Runtime Error |
C. | 40 |
D. | Compile time Error |
Answer» D. Compile time Error | |
1487. |
What will be the output of the given code snippet?
public class Generic |
A. | Compile time error |
B. | Csharp |
C. | 0 |
D. | Run time error |
Answer» C. 0 | |
1488. |
For the code set given below,which of the following statements are perfectly valid?
public class MyContainer |
A. | Class MyConatiner requires that its type argument must implement Icomparable interface |
B. | There are multiple constraints on type argument to MyConatiner class |
C. | Compiler will report an error |
D. | None of the mentioned |
Answer» C. Compiler will report an error | |
1489. |
For the code given below which statements are perfectly valid?
public class Csharp { public void subject <S>(S arg) { Console.WriteLine(arg); } } class Program { static Void Main(string[] args) { Csharp c = new Csharp(); c.subject("hi"); c.subject(20); } } |
A. | Run time exception error |
B. | Compile time error |
C. | Code runs successfully and prints required output |
D. | None of the mentioned |
Answer» D. None of the mentioned | |
1490. |
Which statement is valid for the given snippet of code:
public class Generic |
A. | Compile time error |
B. | Generic being a keyword cannot be used as a class name |
C. | Run time error |
D. | Code runs successfully |
Answer» E. | |
1491. |
Which statement is valid for the given snippet of code:
public class Generic |
A. | Compile time error |
B. | A |
C. | Run time error |
D. | Code runs successfully but prints nothing |
Answer» C. Run time error | |
1492. |
Consider an integer pointer *a.
|
A. | Value at a, address contained in a |
B. | Value at a,value at a |
C. | Address contained in a, address contained in a |
D. | Address contained in a, value at a |
Answer» B. Value at a,value at a | |
1493. |
What will be the ouput of the given code snippet?
class UnsafeCode { unsafe static void Main() { int* a; int a1 = 10; int b1; b1 = *&a1; a = &b1; { Console.WriteLine(*a); Console.ReadLine(); } } } |
A. | Program will print garbage value |
B. | Program will print address of a |
C. | Program will print value of a1 |
D. | Program will print address of a1 |
Answer» D. Program will print address of a1 | |
1494. |
What will be the output of the code snippet?
class UnsafeCode { unsafe static void Main() { int n = 10; int* p = &n; int** p1 = &p; int*** p2 = &p1; Console.WriteLine(*p * **p1 * ***p2); Console.ReadLine(); } } |
A. | Compile time error |
B. | Garbage value is printed |
C. | Program will print 1000 |
D. | Program will print 100 |
Answer» D. Program will print 100 | |
1495. |
What will be the output of the following code snippet?
class UnsafeCode { unsafe static void Main() { int* p; p = (int*)(65535); Console.WriteLine((uint)p); Console.ReadLine(); } } |
A. | Compile time error |
B. | Garbage value |
C. | Program prints value at address 65535 |
D. | Program prints 65535 |
Answer» E. | |
1496. |
What will be the output of the given code?
class UnsafeCode { unsafe static void Main() { int m = 10; int *mptr = &m; int **ptr = &mptr; int n = 20; int *nptr = &n; int **prt = &nptr; m = **prt + *nptr; n = *mptr* **prt; Console.WriteLine(n + " " + m); Console.ReadLine(); } } |
A. | 20 200 |
B. | 40 200 |
C. | 800 40 |
D. | 40 800 |
Answer» D. 40 800 | |
1497. |
What will be the output of the code snippet?
unsafe static void Main() { int a = 5; int b = 5; int c = 5; int*[] ptr = new int* [3]; ptr[0] = &a; ptr[1] = &b; ptr[2] = &c; for (a = 0; a < 3; a++) { c += *ptr[a]; Console.WriteLine(c); } Console.ReadLine(); } |
A. | 5 10 |
B. | 10 20 |
C. | Compile time error |
D. | 5 10 20 |
Answer» E. | |
1498. |
What will be the output of the code snippet?
class UnsafeCode { unsafe static void Main() { int* ptrs = stackalloc int[3]; ptrs[0] = 1; ptrs[1] = 2; ptrs[2] = 3; for (int i = 2; i >= 0; --i) { ptrs[i] = ptrs[i]* 3; ptrs[i] = ptrs[i] + 4; Console.WriteLine(ptrs[i]); } Console.ReadLine(); } } |
A. | 20, 10, 7 |
B. | 13, 10, 7 |
C. | 6, 9, 3 |
D. | Compile time error |
Answer» C. 6, 9, 3 | |
1499. |
what will be the output of code snippet?
class UnsafeCode { unsafe static void Main() { char[] arr = { 'A', 'B', 'C', 'D', 'E' }; fixed (char* P = arr) { int i; for (i = 0 ;i < 5 ;i++) if (*P % 2 == 0) ++*P; else (*P)++; Console.WriteLine(arr); } Console.ReadLine(); } } |
A. | ACCEE |
B. | FBCDE |
C. | BBDDF |
D. | BBCEE |
Answer» C. BBDDF | |
1500. |
What will be the output of given code snippet?
class UnsafeCode { unsafe static void Main() { int[] nums = new int[10]; Console.WriteLine("Index pointer like array."); fixed (int* p = nums) { for (int i = 0 ;i <10 ;i++) p[i] = i; for (int i = 10 ;i >0 ;i--) Console.WriteLine("p[{0}]: {1} ", i, p[i]); Console.ReadLine(); } } } |
A. | P[10] :0, p[9] :9, p[8] :8 ..p[1]:1 |
B. | P[10] : 1, p[9] :2, p[8] :3 ..p[1] :0 |
C. | P[1] : 1, p[2] :2, p[3] :3 ..p[10] :0 |
D. | Compile time error |
Answer» B. P[10] : 1, p[9] :2, p[8] :3 ..p[1] :0 | |