

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.
1401. |
Which of the following will be the correct output for the C#.NET code snippet given below?
String s1 = "Five Star"; String s2 = "FIVE STAR"; int c; c = s1.CompareTo(s2); Console.WriteLine(c); |
A. | 0 |
B. | 1 |
C. | 2 |
D. | -1 |
Answer» E. | |
1402. |
If s1 and s2 are references to two strings then which of the following are the correct ways to find whether the contents of the two strings are equal?
1. if(s1 = s2) 2. if(s1 == s2) 3. int c; c = s1.CompareTo(s2); 4. if( strcmp(s1, s2) ) 5. if (s1 is s2) |
A. | 1, 2 |
B. | 2, 3 |
C. | 4, 5 |
D. | 3, 5 |
Answer» C. 4, 5 | |
1403. |
Which of the following statements are correct about the String Class in C#.NET?1. Two strings can be concatenated by using an expression of the form s3 = s1 + s2; |
A. | 1, 2, 5 |
B. | 2, 4 |
C. | 1, 3, 4 |
D. | 3, 5 |
Answer» D. 3, 5 | |
1404. |
Which of the following statements are correct?1. String is a value type. |
A. | 1, 3 |
B. | 3, 5 |
C. | 2, 4 |
D. | 1, 2, 4 |
Answer» D. 1, 2, 4 | |
1405. |
Which of the following statements are correct about the C#.NET code snippet given below?
int[][]intMyArr = new int[2][]; intMyArr[0] = new int[4]{6, 1, 4, 3}; intMyArr[1] = new int[3]{9, 2, 7}; |
A. | IntMyArr is a reference to a 2-D jagged array. |
B. | The two rows of the jagged array intMyArr are stored in adjacent memory locations. |
C. | IntMyArr[0] refers to the zeroth 1-D array and intMyArr[1] refers to the first 1-D array. |
D. | IntMyArr refers to intMyArr[0] and intMyArr[1]. |
Answer» D. IntMyArr refers to intMyArr[0] and intMyArr[1]. | |
1406. |
Which of the following are the correct ways to define an array of 2 rows and 3 columns?
1. int[ , ] a; a = new int[2, 3]{{7, 1, 3},{2, 9, 6}}; 2. int[ , ] a; a = new int[2, 3]{}; 3. int[ , ] a = {{7, 1, 3}, {2, 9,6 }}; 4. int[ , ] a; a = new int[1, 2]; 5. int[ , ] a; a = new int[1, 2]{{7, 1, 3}, {2, 9, 6}}; |
A. | 1, 2 , 3 |
B. | 1, 3 |
C. | 2, 3 |
D. | 2, 4, 5 |
Answer» C. 2, 3 | |
1407. |
Which of the following statements is correct about the array declaration given below?
int[][][] intMyArr = new int[2][][]; |
A. | IntMyArr refers to a 2-D jagged array containing 2 rows. |
B. | IntMyArr refers to a 2-D jagged array containing 3 rows. |
C. | IntMyArr refers to a 3-D jagged array containing 2 2-D jagged arrays. |
D. | IntMyArr refers to a 3-D jagged array containing three 2-D jagged arrays. |
Answer» D. IntMyArr refers to a 3-D jagged array containing three 2-D jagged arrays. | |
1408. |
Which of the following statements is correct about the C#.NET code snippet given below?
int[] intMyArr = {11, 3, 5, 9, 4}; |
A. | IntMyArr is a reference to an object of System.Array Class. |
B. | IntMyArr is a reference to an object of a class that the compiler derives from System.Array Class. |
C. | IntMyArr is a reference to an array of integers. |
D. | IntMyArr is a reference to an object created on the stack. |
Answer» C. IntMyArr is a reference to an array of integers. | |
1409. |
Which of the following is the correct output of the C#.NET code snippet given below?
int[][] a = new int[2][]; a[0] = new int[4]{6, 1, 4, 3}; a[1] = new int[3]{9, 2, 7}; Console.WriteLine(a[1].GetUpperBound(0)); |
A. | 3 |
B. | 4 |
C. | 7 |
D. | 2 |
Answer» E. | |
1410. |
Which of the following is the correct way to define and initialise an array of 4 integers?
1. int[] a = {25, 30, 40, 5}; 2. int[] a; a = new int[3]; a[0] = 25; a[1] = 30; a[2] = 40; a[3] = 5; 3. int[] a; a = new int{25, 30, 40, 5}; 4. int[] a; a = new int[4]{25, 30, 40, 5}; 5. int[] a; a = new int[4]; a[0] = 25; a[1] = 30; a[2] = 40; a[3] = 5; |
A. | 1, 2 |
B. | 3, 4 |
C. | 1, 4, 5 |
D. | 2, 4, 5 |
Answer» D. 2, 4, 5 | |
1411. |
What will be the output of the C#.NET code snippet given below?
namespace CompScibitsConsoleApplication { class SampleProgram { static void Main(string[ ] args) { int i, j; int[ , ] arr = new int[ 2, 2 ]; for(i = 0; i < 2; ++i) { for(j = 0; j < 2; ++j) { arr[i, j] = i * 17 + i * 17; Console.Write(arr[ i, j ] + " "); } } } } } |
A. | 0 0 34 34 |
B. | 0 0 17 17 |
C. | 0 0 0 0 |
D. | 17 17 0 0 |
Answer» B. 0 0 17 17 | |
1412. |
Which of the following is the correct way to obtain the number of elements present in the array given below?
int[] intMyArr = {25, 30, 45, 15, 60}; 1. intMyArr.GetMax; 2. intMyArr.Highest(0); 3. intMyArr.GetUpperBound(0); 4. intMyArr.Length; 5. intMyArr.GetMaxElements(0); |
A. | 1, 2 |
B. | 3, 4 |
C. | 3, 5 |
D. | 1, 5 |
Answer» C. 3, 5 | |
1413. |
Which of the following statements are correct about static functions?1. Static functions can access only static data. |
A. | 1, 2, 4 |
B. | 2, 3, 5 |
C. | 3, 4 |
D. | 4, 5 |
Answer» B. 2, 3, 5 | |
1414. |
Which of the following statements is correct about the C#.NET code snippet given below?
namespace ConsoleApplication { class Sample { public int func() { return 1; } public Single func() { return 2.4f ; } } class Program { static void Main(string[ ] args) { Sample s1 = new Sample(); int i; i = s1.func(); Single j; j = s1.func(); } } } |
A. | Func() is a valid overloaded function. |
B. | Overloading works only in case of subroutines and not in case of functions. |
C. | Func() cannot be considered overloaded because: return value cannot be used to distinguish between two overloaded functions. |
D. | The call to i = s1.func() will assign 1 to i. |
Answer» D. The call to i = s1.func() will assign 1 to i. | |
1415. |
Which of the following ways to create an object of the Sample class given below will work correctly?
class Sample { int i; Single j; double k; public Sample (int ii, Single jj, double kk) { i = ii; j = jj; k = kk; } } |
A. | Sample s1 = new Sample(); |
B. | Sample s1 = new Sample(10); |
C. | Sample s2 = new Sample(10, 1.2f); |
D. | Sample s3 = new Sample(10, 1.2f, 2.4); |
Answer» E. | |
1416. |
What will be the output of the following set of code?
class static_out { public static int x; public static int y; public int add(int a, int b) { x = a + b; y = x + b; return 0; } } class Program { static void Main(string[] args) { static_out obj1 = new static_out(); static_out obj2 = new static_out(); int a = 2; obj1.add(a, a + 1); obj2.add(5, a); Console.WriteLine(static_out.x + " " + static_out.y ); Console.ReadLine(); } } |
A. | 7 7 |
B. | 6 6 |
C. | 7 9 |
D. | 9 7 |
Answer» D. 9 7 | |
1417. |
In which of the following should the methods of a class differ if they are to be treated as overloaded methods?1. Type of arguments |
A. | 2, 4 |
B. | 3, 5 |
C. | 1, 3, 5 |
D. | 3, 4, 5 |
Answer» D. 3, 4, 5 | |
1418. |
Which of the following is the correct way to define the constructor(s) of the Sample class if we are to create objects as per the C#.NET code snippet given below?
Sample s1 = new Sample(); Sample s2 = new Sample(9, 5.6f); |
A. | Public Sample() { i = 0, j = 0.0f; } public Sample (int ii, Single jj) { i = ii; j = jj;} |
B. | Public Sample (Optional int ii = 0, Optional Single jj = 0.0f) { i = ii; j = jj; } |
C. | Public Sample (int ii; Single jj) { i = ii; j = jj; } |
D. | Sample s, |
Answer» B. Public Sample (Optional int ii = 0, Optional Single jj = 0.0f) { i = ii; j = jj; } | |
1419. |
Which of the following statements are correct about constructors in C#.NET?1. Constructors cannot be overloaded. |
A. | 1, 3, 5 |
B. | 2, 3, 4 |
C. | 3, 5 |
D. | 4, 5 |
Answer» C. 3, 5 | |
1420. |
Which of the following statements are incorrect ? |
A. | Public members of class can be accessed by any code in the program |
B. | Private members of class can only be accessed by other members of the class |
C. | Private members of class can be inherited by a sub class, and become protected members in sub class |
D. | Protected members of a class can be inherited by a sub class, and become private members of the sub class |
Answer» D. Protected members of a class can be inherited by a sub class, and become private members of the sub class | |
1421. |
What will be the output of code snippet?
class test { public int a; public int b; public test(int i, int j) { a = i; b = j; } public void meth(test o) { o.a *= 2; o.b /= 2; } } class Program { static void Main(string[] args) { test obj = new test(10, 20); obj.meth(obj); Console.WriteLine(obj.a + " " + obj.b); Console.ReadLine(); } } |
A. | 20, 40 |
B. | 40, 20 |
C. | 20, 10 |
D. | 10, 20 |
Answer» D. 10, 20 | |
1422. |
Select output for the following set of code.
class sample { public int i; public int[] arr = new int[10]; public void fun(int i, int val) { arr[i] = val; } } class Program { static void Main(string[] args) { sample s = new sample(); s.i = 10; sample.fun(1, 5); s.fun(1, 5); Console.ReadLine(); } } |
A. | Sample.fun(1, 5) will not work correctly |
B. | S.i = 10 cannot work as i is public |
C. | Sample.fun(1, 5) will set value as 5 in arr[1]. |
D. | S.fun(1, 5) will work correctly |
Answer» B. S.i = 10 cannot work as i is public | |
1423. |
Select the output for the following set of code :
class sample { public int i; public int j; public void fun(int i, int j) { this.i = i; this.j = j; } } class Program { static void Main(string[] args) { sample s = new sample(); s.i = 1; s.j = 2; s.fun(s.i, s.j); Console.WriteLine(s.i + " " + s.j); Console.ReadLine(); } } |
A. | Error while calling s.fun() due to inaccessible level |
B. | Error as this reference would not be able to call i and j |
C. | 1 2 |
D. | Runs successfully but prints nothing |
Answer» D. Runs successfully but prints nothing | |
1424. |
Select the output for the following set of code :
static void Main(string[] args) { int[] arr = new int[] {1 ,2 ,3 ,4 ,5 }; fun1(ref arr); Console.ReadLine(); } static void fun1(ref int[] array) { for (int i = 0; i < array.Length; i++) { array[i] = array[i] + 5; Console.WriteLine(array[i] + " "); } } |
A. | 6 7 8 9 10 |
B. | 15 17 8 8 20 |
C. | 15 17 8 29 20 |
D. | Syntax error while passing reference of array variable. |
Answer» B. 15 17 8 8 20 | |
1425. |
Which of following statements about objects in C# is correct? |
A. | Everything you use in C# is an object, including Windows Forms and controls |
B. | Objects have methods and events that allow them to perform actions |
C. | All objects created from a class will occupy equal number of bytes in memory |
D. | All of the mentioned |
Answer» E. | |
1426. |
Select output for the set of code :
static void Main(string[] args) { int []a = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; func(ref a); Console.ReadLine(); } static void func(ref int[] x) { Console.WriteLine(" numbers are:"); for (int i = 0; i < x.Length; i++) { if (x[i] % 2 == 0) { x[i] = x[i] + 1; Console.WriteLine(x[i]); } } } |
A. | Numbers are : 2 4 6 8 10 |
B. | Numbers are : 3 5 7 9 11 |
C. | Numbers are : 2 3 4 5 6 |
D. | None of the mentioned |
Answer» C. Numbers are : 2 3 4 5 6 | |
1427. |
Select the wrong statement about ref keyword in C#? |
A. | References can be called recursively |
B. | The ref keyword causes arguments to be passed by reference |
C. | When ref are used, any changes made to parameters in method will be reflected in variable when control is passed back to calling method |
D. | All of above mentioned |
Answer» B. The ref keyword causes arguments to be passed by reference | |
1428. |
Select correct differences between = and == in C#. |
A. | == operator is used to assign values from one variable to another variable |
B. | = operator is used to assign values from one variable to another variable |
C. | No difference between both operators |
D. | None of the mentioned |
Answer» C. No difference between both operators | |
1429. |
Select the correct output for following set of code.
static void Main(string[] args) { int X = 0; if (Convert.ToBoolean(X = 0)) Console.WriteLine("It is zero"); else Console.WriteLine("It is not zero"); Console.ReadLine(); } |
A. | It is zero |
B. | It is not zero |
C. | Infinite loop |
D. | None of the mentioned |
Answer» C. Infinite loop | |
1430. |
Select the output for the following set of code :
static void Main(string[] args) { int X = 6,Y = 2; X *= X / Y; Console.WriteLine(X); Console.ReadLine(); } |
A. | 12 |
B. | 6 |
C. | 18 |
D. | Compile time error |
Answer» D. Compile time error | |
1431. |
Select the ouput for the following set of code :
static void Main(string[] args) { int x = 4 ,b = 2; x -= b/= x * b; Console.WriteLine(x + " " + b); Console.ReadLine(); } |
A. | 4 2 |
B. | 0 4 |
C. | 4 0 |
D. | None of mentioned |
Answer» D. None of mentioned | |
1432. |
What is output for the following set of expression?
int a+= (float) b/= (long)c |
A. | Float |
B. | Int |
C. | Long |
D. | None of the mentioned |
Answer» C. Long | |
1433. |
Select the output for the following set of code :
static void Main(string[] args) { int x = 8; int b = 16; int C = 64; x /= b /= C; Console.WriteLine(x + " " + b+ " " +C); Console.ReadLine(); } |
A. | 8 2 32 |
B. | 32 4 8 |
C. | 32 2 8 |
D. | Compile time error |
Answer» E. | |
1434. |
What is the output of the following set of code?
static void Main(string[] args) { int x = 8; int b = 16; int C = 64; x /= b /= C; Console.WriteLine(x + " " + b+ " " +C); Console.ReadLine(); }static void Main(string[] args) { int a = 5; int s = 0, c = 0; Mul (a, ref s, ref c); Console.WriteLine(s + "t " +c); Console.ReadLine(); } static void Mul (int x, ref int ss, ref int cc) { ss = x * x; cc = x * x * x; } |
A. | 125 25 |
B. | 25 125 |
C. | Compile time error |
D. | 0 0 |
Answer» C. Compile time error | |
1435. |
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 |
Answer» D. 3 4 4 | |
1436. |
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 |
Answer» D. Compile time error | |
1437. |
A mechanism that binds together code and data in manipulates, and keeps both safe from outside interference and misuse.In short it isolates a particular code and data from all other codes and data. A well-defined interface controls the access to that particular code and data. |
A. | Abstraction |
B. | Polymorphism |
C. | Inheritance |
D. | Encapsulation |
Answer» E. | |
1438. |
Correct way of declaration of object of the following class is ?
|
A. | Name n = new name(), |
B. | N = name(), |
C. | Name n = name(), |
D. | N = new name(), |
Answer» B. N = name(), | |
1439. |
Select the output for the following set of code :
class z { public string name1; public string address; public void show() { Console.WriteLine("{0} is in city{1}", name1, " ", address); } } class Program { static void Main(string[] args) { z n = new z(); n.name1 = "harsh"; n.address = "new delhi"; n.show(); Console.ReadLine(); } } |
A. | Syntax error |
B. | {0} is in city{1} harsh new delhi |
C. | Harsh is in new delhi |
D. | Run successfully prints nothing |
Answer» D. Run successfully prints nothing | |
1440. |
What does the following code imply ?
csharp abc; abc = new charp(); |
A. | Object creation on class csharp |
B. | Create an object of type csharp on heap or on stack depending on the size of object |
C. | Create a reference c on csharp and an object of type csharp on heap |
D. | Create an object of type csharp on stack |
Answer» D. Create an object of type csharp on stack | |
1441. |
The output of code is ?
class test { public void print() { Console.WriteLine("Csharp:"); } } class Program { static void Main(string[] args) { test t; t.print(); Console.ReadLine(); } } |
A. | Code runs successfully prints nothing |
B. | Code runs and prints Csharp |
C. | Syntax error as t is unassigned variable which is never used |
D. | None of the mentioned |
Answer» D. None of the mentioned | |
1442. |
Select the output for following set of code :
static void Main(string[] args) { int a = 5; fun1 (ref a); Console.WriteLine(a); Console.ReadLine(); } static void fun1(ref int a) { a = a * a; } |
A. | 5 |
B. | 0 |
C. | 20 |
D. | 25 |
Answer» E. | |
1443. |
Which of the following statements is correct about the C#.NET code snippet given below?
class Student s1, s2; // Here 'Student' is a user-defined class. s1 = new Student(); s2 = new Student(); |
A. | Contents of s1 and s2 will be exactly same. |
B. | The two objects will get created on the stack. |
C. | Contents of the two objects created will be exactly same. |
D. | The two objects will always be created in adjacent memory locations. |
Answer» D. The two objects will always be created in adjacent memory locations. | |
1444. |
Which of the following statements is correct about the C#.NET code snippet given below?
class Sample { private int i; public Single j; private void DisplayData() { Console.WriteLine(i + " " + j); } public void ShowData() { Console.WriteLine(i + " " + j); } } |
A. | J cannot be declared as public. |
B. | DisplayData() cannot be declared as private. |
C. | DisplayData() cannot access j. |
D. | There is no error in this class. |
Answer» E. | |
1445. |
Which of the following statements are correct?1. Instance members of a class can be accessed only through an object of that class. |
A. | 1, 3, 5 |
B. | 2, 4 |
C. | 3, 5 |
D. | 2, 4, 5 |
Answer» B. 2, 4 | |
1446. |
Which of the following is the correct way to create an object of the class Sample?
1. Sample s = new Sample(); 2. Sample s; 3. Sample s; s = new Sample(); s = new Sample(); |
A. | 1, 3 |
B. | 2, 4 |
C. | 1, 2, 3 |
D. | 1, 4 |
Answer» B. 2, 4 | |
1447. |
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) { i = i; j = j; } public void Display() { Console.WriteLine(i + " " + j); } } class MyProgram { static void Main(string[ ] args) { Sample s1 = new Sample(); s1.SetData(10, 5.4f); s1.Display(); } } } |
A. | 0 0 |
B. | 10 5.4 |
C. | 10 5.400000 |
D. | 10 5 |
Answer» B. 10 5.4 | |
1448. |
Which of the following statements are correct?1. Data members ofa class are by default public. |
A. | 1, 3, 5 |
B. | 1, 4 |
C. | 2, 4, 5 |
D. | 1, 2, 3 |
Answer» D. 1, 2, 3 | |
1449. |
Output for the following set of code :
static void Main(string[] args) { int y = 3; y++; if (y <= 5) { Console.WriteLine("hi"); Main(args); } Console.ReadLine(); } |
A. | Hi hi |
B. | Hi |
C. | Stack overflow exception |
D. | None of the mentioned |
Answer» D. None of the mentioned | |
1450. |
What is the output for selective code ?
public static void Main(string[] args) { p(); void p() { Console.WriteLine("hi"); } } |
A. | Compile time error |
B. | Hi |
C. | Hi infinite times |
D. | None of the mentioned |
Answer» B. Hi | |