Explore topic-wise MCQs in General Awareness.

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.

1501.

What will be the output of the given code snippet?
 class UnsafeCode { unsafe static void Main() { string str = "this is a test"; fixed (char* p = str) { for (int i = str.Length-1 ;p[i] != 0 ;i--) Console.Write(p[i]); } Console.ReadLine(); } } 

A. Test a is this
B. Compile time error
C. Tset a si siht
D. Run time error
Answer» D. Run time error
1502.

What will be the output of given code snippet?
 class UnsafeCode { unsafe static void Main() { int* p ; int ch = 13*5; p = &(ch); Console.WriteLine(Convert.ToChar(*p)); if (*p == 'A') Console.WriteLine(Convert.ToBoolean(1)); else Console.WriteLine(Convert.ToBoolean(0)); Console.ReadLine(); } } 

A. 65 False
B. 65 1
C. A True
D. A 1
Answer» D. A 1
1503.

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 = 10; p->b = 20; Console.WriteLine("Value is " + p->Sum()); Console.ReadLine(); } } 

A. Compile time error
B. Run time error
C. 200
D. 30
Answer» D. 30
1504.

For the code set given below,which of the following statements are perfectly valid?
public class MyContainer where T: IComparable { /* insert code here */ }

A. Class MyConatiner requires that its type arguement must implement Icomparable interface
B. There are multiple constraints on type arguement to MyContainer class
C. Type arguement of class MyContainer should be Icomparable
D. None of the mentioned
Answer» B. There are multiple constraints on type arguement to MyContainer class
1505.

Choose the statements which are valid for given code snippet:
public class Generic { public T Field; public void testSub() { T i = Field + 1; } } class Program { static void Main(string[] args) { Genericg = new Generic(); g.testSub(); } } 

A. Code runs successfully but prints nothing
B. Code runs successfully and prints 1
C. Program will give run time error
D. Compile time error
Answer» E.
1506.

What does the following code depicts?

1. System.Nullable count;
2. bool? done;

A. Code 1 declares the objects of nullable of type Nullable defined in the System namespace
B. Code 2 declares a nullable type in much shorter and in more commonly used way using ?
C. Both a & b
D. None of the mentioned
Answer» D. None of the mentioned
1507.

What will be the output of given code snippet?
 unsafe struct FixedBankRecord { public fixed byte Name[80]; public double Balance; public long ID; } class UnsafeCode { unsafe static void Main() { Console.WriteLine("Size of FixedBankRecord is " + sizeof(FixedBankRecord)); Console.ReadLine(); } } 

A. Run time error
B. 80
C. 96
D. Compile time error
Answer» D. Compile time error
1508.

What will be the output of given 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--) Console.WriteLine(ptrs[i]); Console.ReadLine(); } } 

A. 3 2 1
B. 1 2 3
C. None of the mentioned
D. Run time error
Answer» B. 1 2 3
1509.

What will be the output of given code snippet?
public class Generic { Stack stk = new Stack(); public void push(T obj) { stk.Push(obj); } public T pop() { T obj = stk.Pop(); return obj; } } class Program { static void Main(string[] args) { Generic g = new Generic(); g.push("Csharp"); Console.WriteLine(g.pop()); Console.ReadLine(); } }

A. Compile time error
B. Csharp
C. 0
D. Run time error
Answer» C. 0
1510.

What will be the output of given code snippet?
 public class Generic { Stack stk = new Stack(); public void push(T obj) { stk.Push(obj); } public T pop() { T obj = stk.Pop(); return obj; } } class Program { static void Main(string[] args) { Generic g = new Generic(); g.push(30); Console.WriteLine(g.pop()); Console.ReadLine(); } }

A. 0
B. 30
C. Runtime Error
D. Compile time Error
Answer» C. Runtime Error
1511.

Which of the following statements are correct about subroutines used in C#.NET?

1. If we do not return a value from a subroutine then a value -1 gets returned.
2. Subroutine definitions cannot be nested.
3. Subroutine can be called recursively.
4. To return the control from middle of a subroutine exit subroutine should be used.
5. Subroutine calls can be nested.

A. 1, 2, 3
B. 2, 3, 5
C. 3, 5
D. 3, 4
Answer» C. 3, 5
1512.

Which of the following statements are correct about the C#.NET program given below?
 namespace McqsMentorConsoleApplication { class SampleProgram { static void Main(string[ ] args) { int a = 5; int s = 0, c = 0; s, c = fun(a); Console.WriteLine(s +" " + c) ; } static int fun(int x) { int ss, cc; ss = x * x; cc = x * x * x; return ss, cc; } } } An error will be reported in the statement s, c = fun(a); since multiple values returned from a function cannot be collected in this manner. It will output 25 125. It will output 25 0. It will output 0 125. An error will be reported in the statement return ss, cc; since a function cannot return multiple values.

A. 1, 3
B. 2, 4
C. 4, 5
D. 1, 5
Answer» E.
1513.

Select the output for the following set of code:
 static void Main(string[] args) { int i = 5; for (; Convert.ToBoolean(Convert.ToInt32(i)); Console.WriteLine(i--)) ; Console.ReadLine(); }  

A. 4 3 2 1
B. 3 2 1
C. 5 4 3 2 1
D. 2 1
Answer» D. 2 1
1514.

Select the output for the following set of code:
 static void Main(string[] args) { int i, s = 0; for (i = 1; i <= 10; s = s + i, i++); { Console.WriteLine(s); } Console.ReadLine(); }  

A. Code report error
B. Code runs in infinite loop condition
C. Code gives output as 0 1 3 6 10 15 21 28 36 45
D. Code give output as 55
Answer» E.
1515.

Which statement is correct among the mentioned statements?

1. The for loop works faster than a while loop
2. for( ; ; )implements an infinite loop

A. Only 1 is correct
B. Only 2 is correct
C. Both 1 and 2 are correct
D. Both 1 and 2 are incorrect
Answer» C. Both 1 and 2 are correct
1516.

Select the output for the following set of code :
 { int i; Console.WriteLine("Hi"); for (i = 1; i <= 10; i++) Program.Main(args); Console.ReadLine(); }  

A. Prints Hi for one time
B. Prints Hi for infinite times
C. Stack overflow exception Condition generated
D. None of above mentioned
Answer» D. None of above mentioned
1517.

Which of the code should be added to get the following output?
 * * * * * * * * * * * * * * * static void Main(string[] args) { int i,j; /* Add code here */ }  

A. For (i = 0; i &lt;= 4; i++) { for(j = 4; j &lt;= i; j ) console.WriteLine( * ); console.WriteLine( );}
B. For ( i = 0; i &lt;= 4; i++ )
C. For (i = 0;i &lt;= 4; i++) { for (j = i; j &lt;= 4; j++) console.WriteLine( * ); console.WriteLine( ); }
D. For ( i = 0;i &lt;= 4; i++) { for (j = 0;j &lt;= i; j++) console.WriteLine( * ); console.WriteLine( ); }
Answer» A. For (i = 0; i &lt;= 4; i++) { for(j = 4; j &lt;= i; j ) console.WriteLine( * ); console.WriteLine( );}
1518.

Predict the output for the following set of code :
 static void Main(string[] args) { int i; for (i =-3; i <= 3; i++) { switch (i) { case 0: Console.WriteLine("zero"); break; } if (i > 0) Console.WriteLine("A"); else if (i < 0) Console.WriteLine("B"); } Console.ReadLine(); }  

A. B B zero A A A
B. B zero A A A
C. B B B zero A A A
D. A A A zero B B B
Answer» D. A A A zero B B B
1519.

Select the output for the following set of code :
 static void Main(string[] args) { int i, j; for (i = 1, j = i; i <= 3 && j >= 0; i++, j--) { if (i == j) continue; else Console.WriteLine(j); } Console.ReadLine(); }  

A. I = 0, j = 1,
B. I = 1, j = 0,
C. J = 0,
D. None of the mentioned
Answer» D. None of the mentioned
1520.

Select the output for the following set of code :
 static void Main(string[] args) { int i = -10; for ( ;Convert.ToBoolean(Convert.ToInt32(i)) ;Console.WriteLine(i++)) ; Console.ReadLine(); }  

A. -9 -8 -7 -6 -5 -4 -3 -2 -1
B. -10 -9 -8 -7 -6 -5 -4 -3 -2
C. -10 -9 -8 -7 -6 -5 -4 -3 -2 -1
D. -8 -7 -6 -5 -4 -3 -2 -1
Answer» D. -8 -7 -6 -5 -4 -3 -2 -1
1521.

Select the output for the following set of code :
 static void Main(string[] args) { int i, j; for (i = 1; i <= 3; i++) { j = 1; while (i % j == 2) { j++; } Console.WriteLine(i + " " + j); } Console.ReadLine(); }  

A. 11 21
B. 1 12 13 1
C. 11 21 31
D. 1 1 2 1 3 1
Answer» D. 1 1 2 1 3 1
1522.

Select the output for the following set of code:
 static void Main(string[] args) { float s = 0.1f; while (s <= 0.5f) { ++s; Console.WriteLine(s); } Console.ReadLine(); }  

A. 0.1
B. 1.1
C. 0.1 0.2 0.3 0.4 0.5
D. No output
Answer» C. 0.1 0.2 0.3 0.4 0.5
1523.

Select the relevant output for the set of code :

m = 5;
int y;
1. y = m++;
2. y = ++m;

A. Y = 5, m = 6 , y = 5, m = 5
B. Y = 6, m = 6, y = 7, m = 6
C. Y = 5, m = 6, y = 7, m = 7
D. Y = 5, m = 6, y = 7, m = 8
Answer» D. Y = 5, m = 6, y = 7, m = 8
1524.

Predict the output for the follwing set of code :
static void Main(string[] args) { int a = 3, b = 5, c = 1; int z = ++b; int y = ++c; b = Convert.ToInt32((Convert.ToBoolean(z)) && (Convert.ToBoolean(y)) || Convert.ToBoolean(Convert.ToInt32(!(++a == b)))); a = Convert.ToInt32(Convert.ToBoolean(c) || Convert.ToBoolean(a--)); Console.WriteLine(++a); Console.WriteLine(++b); Console.WriteLine(c); } 

A. 2 ,2 ,1
B. 2 ,3 ,2
C. 2 ,2 ,2
D. 2 ,0 ,9
Answer» D. 2 ,0 ,9
1525.

Select the output for the relevant code set :
 static void Main(string[] args) { int a = 4, b = 5, c = 7, u = 9; int h; h = (Convert.ToInt32(u < b)) + (a + b--) + 2; Console.WriteLine(h); Console.WriteLine(b); Console.WriteLine(u < b); }

A. 12, 5, 0
B. 11, 4, False
C. 11, 5, 0
D. 12, 4, False
Answer» C. 11, 5, 0
1526.

Select the suitable output for the following set of code :
 static void Main(string[] args) { int m = 10, n = 5, p = 20; bool b1 = m * p / n <= p * n / m ; int l = p - 2 * m; bool b2 = l == 0; int z = Convert.ToInt32(b2); int k = Convert.ToInt32(b1); Console.WriteLine(k); Console.WriteLine(z); }

A. 0 0
B. 1 0
C. 0 1
D. 1 1
Answer» D. 1 1
1527.

Select the output for the following set of code :
class method1 { public int fun(int m) { return( m++ % 10); } } class Program { static void Main(string[] args) { int a = 23, b = 0, c; method1 z = new method1(); c = z.fun (++b * --a % 2); int d = (z.fun (c-- + --a)); Console.WriteLine(c); Console.WriteLine(a++); Console.WriteLine(d); Console.ReadLine(); } } 

A. -1, 22, 0
B. -1, 21, 1
C. 0, 22, 1
D. 0, 22, 0
Answer» C. 0, 22, 1
1528.

Select the output for the following set of Code :
 static void Main(string[] args) { int a = 8, b = 6, c = 10; int d = a * c * 2 / Convert.ToInt32(Math.Pow ((c - b), 2)); if (d == (c = Convert.ToInt32(Math.Sqrt (a * a + b * b))) && c == 10) { Console.WriteLine("figure is hypotenuse"); } else { Console.WriteLine("figure is square"); } }

A. Figure is square
B. Figure is hypotenuse
C. False
D. None of the mentioned
Answer» B. Figure is hypotenuse
1529.

Select the relevant output for the following set of code :
static void Main(string[] args) { byte varA = 10; byte varB = 20; long result = varA & varB; Console.WriteLine("{0} AND {1} Result :{2}", varA, varB, result); varA = 10; varB = 10; result = varA & varB; Console.WriteLine("{0} AND {1} Result : {2}", varA, varB, result); Console.ReadLine(); } 

A. 0, 20
B. 10, 10
C. 0, 10
D. 0, 0
Answer» D. 0, 0
1530.

Select the relevant output for the following set of code :
 public static void Main() { byte varA = 10; byte varB = 20; long result = varA | varB; Console.WriteLine("{0} OR {1} Result :{2}", varA, varB, result); varA = 10; varB = 10; result = varA | varB; Console.WriteLine("{0} OR {1} Result : {2}", varA, varB, result); }

A. 20, 10
B. 30, 10
C. 10, 20
D. 10, 10
Answer» C. 10, 20
1531.

Select the output for the following set of Code:
 static void Main(string[] args) { byte b1 = 0 * AB; byte b2 = 0 * 99; byte temp; temp = (byte) ~b2; Console.Write( temp + " "); temp = (byte) (b1 << b2); Console.Write(temp + " "); temp = (byte)(b2 >> 2); Console.WriteLine(temp); Console.ReadLine(); }

A. 101 0 34
B. 103 2 38
C. 102 0 38
D. 101 1 35
Answer» D. 101 1 35
1532.

Select the output for the following set of Code:
bool a = true; bool b = false; a |= b; Console.WriteLine(a); Console.ReadLine(); 

A. 0
B. 1
C. True
D. False
Answer» D. False
1533.

Select the relevant code set to fill up the blank for the following program :
static void Main(string[] args) { int x = 10, y = 20; int res; /*_______________*/ Console.WriteLine(res); } 

A. X % y == 0 ? (x == y ? (x += 2):(y = x + y)):y = y*10,
B. X % y == 0 ? y += 10:(x += 10),
C. X % y == 0 ? return(x) : return (y),
D. All of the mentioned.
Answer» C. X % y == 0 ? return(x) : return (y),
1534.

In the given constructor declaration for character based file operation what does path and bool specifies?
StreamWriter(string path, bool append)

A. The name of the file to open
B. Specifies the full path of file
C. If append is true, the file is appended to the end of the existing file
D. All of the mentioned
Answer» E.
1535.

Select the output for the following set of code:
static void Main(string[] args) { int y = 5; int x; int k = (!(Convert.ToInt32(y) > 10))? x = y + 3 : x = y + 10; Console.WriteLine(x); Console.WriteLine(y); Console.ReadLine(); } 

A. 5, 8
B. 10, 4
C. 8, 5
D. 11, 8
Answer» D. 11, 8
1536.

Arrange the operators in the increasing order as defined in C#:
!=, ?:, &, ++, &&

A. ?: &lt; &amp;&amp; &lt; != &lt; &amp; &lt; ++
B. ?: &lt; &amp;&amp; &lt; != &lt; ++ &lt; &amp;
C. ?: &lt; &amp;&amp; &lt; &amp;
D. ?: &lt; &amp;&amp; &lt; != &lt; &amp; &lt; ++
Answer» D. ?: &lt; &amp;&amp; &lt; != &lt; &amp; &lt; ++
1537.

What will be the output of the C#.NET code snippet given below?
int i, j = 1, k; for (i = 0; i < 5; i++) { k = j++ + ++j; Console.Write(k + " "); } 

A. 8 4 16 12 20
B. 4 8 12 16 20
C. 4 8 16 32 64
D. 2 4 6 8 10
Answer» C. 4 8 16 32 64
1538.

What will be the output of the C#.NET code snippet given below?
int a = 10, b = 20, c = 30; int res = a < b ? a < c ? c : a : b; Console.WriteLine(res); 

A. 10
B. 20
C. 30
D. Compile Error / Syntax Error
Answer» D. Compile Error / Syntax Error
1539.

Which of the following statements are correct about the following code snippet?
int a = 10; int b = 20; bool c; c = !(a > b); 

1. There is no error in the code snippet.
2. An error will be reported since ! can work only with an int.
3. A value 1 will be assigned to c.
4. A value True will be assigned to c.
5. A value False will be assigned to c.

A. 1, 3
B. 2, 4
C. 4, 5
D. 1, 4
Answer» E.
1540.

Correct Set of Code for given data a and b to print output for c as 74 ?

A. int a = 12; float b = 6.2f; int c; c = a / b + a * b; Console.WriteLine(c);
B. int a = 12; float b = 6.2f; int c; c = a / convert.ToInt32(b) + a * b; Console.WriteLine(c);
C. int a = 12; float b = 6.2f; int c; c = a / convert.ToInt32(b) + a * convert.ToInt32(b); Console.WriteLine(c);
D. int a = 12; float b = 6.2f; int c; c = convert.ToInt32(a / b + a * b); Console.WriteLine(c);
Answer» D. int a = 12; float b = 6.2f; int c; c = convert.ToInt32(a / b + a * b); Console.WriteLine(c);
1541.

Does the output remain same or different for both cases?
1) char l ='k'; float b = 19.0f; int c; c = (l / convert.ToInt32(b)); Console.Writeline(c); 2) char l ='k'; float b = 19.0f; int c; c = Convert.ToInt32(l / b); console.writeline(c); 

A. Yes
B. No
C. Depends on compiler
D. None of the above
Answer» C. Depends on compiler
1542.

Default Type of number without decimal is ?

A. Long Int
B. Unsigned Long
C. Int
D. Unsigned Int
Answer» D. Unsigned Int
1543.

Correct output for code is?
static void Main(string[] args) { float a = 10.553f; long b = 12L; int c; c = Convert.ToInt32(a + b); Console.WriteLine(c); } 

A. 23.453
B. 22
C. 23
D. 22.453
Answer» D. 22.453
1544.

Number of digits upto which precision value of float datatype is valid ?

A. Upto 6 digit
B. Upto 8 digit
C. Upto 9 digit
D. Upto 7 digit
Answer» E.
1545.

Valid Size of float datatype is ?

A. 10 Bytes
B. 6 Bytes
C. 4 Bytes
D. 8 Bytes
Answer» D. 8 Bytes
1546.

Select correct set of code to display the value of given variable c as 25.302 .
a) float a = (double) 12.502f; float b = 12.80f; float c; c = (float) a + b; Console.Writeline(c); Console.ReadLine(); b) float a = 12.502D; float b = 12.80f; float c; c = a + b; Console.WriteLine(c); Console.ReadLine(); c) double a = 12.502; float b = 12.802f; float c; c = (float)a + b; Console.WriteLine(c); Console.ReadLine(); d) double a = (float) 12.502f; float b = 12.80f; float c; c = a + b; Console.WriteLine(c); Console.ReadLine(); 

A. A
B. B
C. C
D. D
Answer» D. D
1547.

Minimum and Maximum range of values supported by float data type are ?

A. 1.5 * 10^-40 to 3.4 * 10^38
B. 1.5 * 10^-45 to 3.4 * 10^30
C. 1.5 * 10^-45 to 3.4 * 10^38
D. 1.5 * 10^-45 to 3.4 * 10^37
Answer» D. 1.5 * 10^-45 to 3.4 * 10^37
1548.

Select appropriate difference between decimal, float and double data type in C# ?

1) Float and Double are floating binary point types while decimal is a floating decimal point type.
2) Precision difference for float is 7 digit for double is 15 to 16 digit and for decimal is 28 to 29 digits.
3) Some values which cannot be exactly represented hence for those values float and double are more appropriate.

A. 1
B. 1, 3
C. 1, 2, 3
D. 2, 3
Answer» D. 2, 3
1549.

Why does a float variable stop incrementing at number 16777216 in given code in C#?
float a = 0 ; while (true) { a++; if (a > 16777216) break; } 

A. Sign and Exponent for 16777217 is same as for 16777216
B. Mantissa is different for 16777216 and 16777217
C. Sign and Exponent for 16777217 is different from 16777216
D. None of the mentioned
Answer» C. Sign and Exponent for 16777217 is different from 16777216
1550.

Select the output of the following set of code ?
static void Main(string[] args) { int x = 1; float y = 2. 4f; short z = 1; Console. WriteLine((float) x + y * z - (x + = (short) y) ); Console. ReadLine(); } 

A. 0.4000004
B. 0.4000023
C. 0.0400021
D. 0.4000001
Answer» E.