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.

1351.

What is the output for the following set of code ?
 static void Main(string[] args) { double a = 345.09; byte c = (byte) a; Console.WriteLine(c); Console.ReadLine(); }  

A. 98
B. 89
C. 88
D. 84
Answer» C. 88
1352.

Which statement is correct about following c#.NET code ?

int[] a= {11, 3, 5, 9, 6};

A. a is a reference to the array created on stack
B. a is a reference to an object created on stack
C. a is a reference to an object of a class that compiler drives from System.Array class
D. None of the mentioned
Answer» D. None of the mentioned
1353.

What is output of the given set of Code?
  class Program { static void Main(string[] args) { String c = "i love Csharp"; bool a; a = c.StartsWith("I"); Console.WriteLine(a); Console.ReadLine(); } }  

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

What will be the output of the following set of code?
 class sum { public int x; private int y; public void math(int a, int b) { x = a * 4; y = b; } } class Program { static void Main(string[] args) { sum p = new sum(); p.math(12, 30); Console.WriteLine(p.x + " " + p.y); Console.ReadLine(); } }  

A. 48, 30
B. 48, 0
C. 0, 0
D. Compile time error
Answer» E.
1355.

What will be the output of the following code?
 class math { public int a,b; public math(int i, int j) { a = i; b = j; } public void sum(math m) { m.a *= 2; m.b += 2; } } class Program { static void Main(string[] args) { math t = new math(20, 10); t.sum(t); Console.WriteLine(t.a + " " + t.b); Console.ReadLine(); } }  

A. 10, 20
B. 20, 10
C. 40, 12
D. 5, 40
Answer» D. 5, 40
1356.

What is output for the following code snippet?

A. 36, 10
B. 10, 36
C. 0, 0
D. 36, 0
Answer» C. 0, 0
1357.

True Statement about ref keyword used in C#.NET are?

A. The ref keyword causes arguments to be passed by reference
B. While using ref keyword any changes made to the parameter in the method will be reflected in the variable when control is passed back to the calling method
C. Ref usage eliminates overhead of copying large data items
D. All of the mentioned
Answer» E.
1358.

Which method does following set of code explains?
 static void Main(string[] args) { int a = 10, b = 20; method(ref a, ref b); console.writeline(a + " " + b); } static void swap(ref int i, ref int j) { int t; t = i; i = j; j = t; }  

A. Call by reference
B. Call by value
C. Output parameter
D. Parameter arrays
Answer» B. Call by value
1359.

What will be the output for the given set of code?
 static void Main(string[] args) { String c = "Hello"; String a = c + "Bye"; Console.WriteLine(a); Console.ReadLine(); }  

A. Hello Bye
B. HelloBye
Answer» E.
1360.

What will be the output for the given set of code?
 static void main(string[] args) { int []arr = new int[]{ 1, 2, 3, 4, 5}; fun (ref arr); for (int i = 0; i < arr.Length ; i++) Console.WriteLine( arr[i] + " "); } static void fun(ref int[]a) { a = new int[6]; a[3] = 32; a[1] = 24; }  

A. 0, 0, 32, 0, 0, 0
B. 0, 24, 0, 32, 0, 0
C. 24, 0, 32, 0, 0, 0
D. 0, 0, 32, 0, 0, 0
Answer» C. 24, 0, 32, 0, 0, 0
1361.

What will be the output for the given set of code?
 static void Main(string[] args) { String c = "Hello"; String a ; a = c.Replace('l', 'w'); Console.WriteLine(a); Console.ReadLine(); }  

A. Helloll
B. Hewlo
C. Helwo
D. Hewwo
Answer» E.
1362.

What will be the output of the given code snippet?
 static void Main(string[] args) { String c = "Hello i love you"; String a ; a = c.Substring(12, 3); Console.WriteLine(a); Console.ReadLine(); }  

A. Ove
B. You
C. Yo
D. Love you
Answer» D. Love you
1363.

Which among the following is the correct way to find out the index of second s in the string She sold her beauty in one night to someone else ?
 a) : String a = "She sold her beauty in one night to someone else"; int i; i = a.SecondIndexOf("s"); b) : String a = "She sold her beauty in one night to someone else"; int i, j; i = a.FirstIndexOf("s"); j = a.IndexOf("s", i + 1); c) : String a = "She sold her beauty in one night to someone else"; int i, j; i = a.IndexOf("s"); j = a.IndexOf("s", i + 1);  

A. A
B. B
C. C
D. None of the mentioned
Answer» D. None of the mentioned
1364.

What will be the output of given set of code?
 static void main(string[] args) { int i; int res = fun (out i); console.writeline(res); console.readline(); } static int fun(out int i) { int s = 1; i = 7; for (int j = 1; j <= i; j++ ) s = s * j; return s; }  

A. 4490
B. 5040
C. 5400
D. 3500
Answer» C. 5400
1365.

What will be the output of the given set of code?
 static void Main(string[] args) { int a = 5; int b = 0, c = 0; method (a, ref b, ref c); Console.WriteLine(b + " " + c); Console.ReadLine(); } static int method(int x, int p, ref int k) { p = x + x * x; k = x * x + p; return 0; }  

A. 30, 55
B. 55, 30
C. Compile time error
D. 0, 0
Answer» D. 0, 0
1366.

Select the correct match of parameter declaration:
 static Void main(string[] args) { int a = 5; int b = 6; float c = 7.2f; math (ref a, ref b, ref c); Console.WriteLine(a + " " + b + " " + c); } static int math(/*add parameter decelaration */) { a += b; b *= (int)c; c += a * b; return 0; }  

A. Ref int a, int b, ref float c
B. Ref int a, ref float c, ref int b
C. Ref int a, ref int b, float c
D. Ref int a, ref int b, ref float c
Answer» E.
1367.

What will be the output for the given set of code ?
 static void Main(string[] args) { object[] a = {" 1 ", 4.0f, " harsh "}; fun(a); Console.ReadLine(); } static void fun(params object[] b) { for (int i = 0; i < b.Length - 1; i++) Console.WriteLine(b[i] + " "); }  

A. 1 4.0 harsh
B. 1 4
C. 1 4 hars
D. 1 4 harsh
Answer» E.
1368.

What will be the output the of given set of code?
 static void Main(string[] args) { int [] a = {1, 2, 3, 4, 5}; fun(a); Console.ReadLine(); } static void fun(params int[] b ) { for (int i = 0; i < b.Length; i++) { b[i] = b[i] * 5 ; Console.WriteLine(b[i] + ""); } }  

A. 1, 2, 3, 4, 5
B. 5, 10, 15, 20, 25
C. 5, 25, 125, 625, 3125
D. 6, 12, 18, 24, 30
Answer» C. 5, 25, 125, 625, 3125
1369.

What will be the output of the set of code?
 static void Main(string[] args) { int [] a = {1, 2, 3, 4, 5}; fun(a); Console.ReadLine(); } static void fun(params int[] b ) { int[] k = { 3, 4, 7, 8,' 0' }; for (int i = 0; i < b.Length; i++) { b[i] = b[i] + k[i] ; Console.WriteLine( b[i] + " "); } }  

A. Compile time error
B. 3, 4, 7, 8, 5
C. 3, 4, 7, 8, 5, 1, 2, 3, 4, 5
D. 4, 6, 10, 12, 5
Answer» E.
1370.

What will be the output of the given set of code?
 static void Main(string[] args) { int[] a = { 2, 21, 34, 46, 85, 88, 90}; fun(a); Console.WriteLine(a + " "); Console.ReadLine(); } static void fun(params int [] b ) { int [] c = { 1, 2, 3, 4, 5, 6, 7}; int i ; for (i = 0 ;i < b.Length ;i++) if (b[i] % 2 == 0) { c[i] = b[i]; } Console.WriteLine("even numbers are:"); for (i = 0 ;i <= b.Length ;i++) { Console.WriteLine(c[i]); } }  

A. Compile time error
B. 2, 21, 34, 4, 6, 46, 88, 90
C. 2, 4, 34, 46, 6, 88, 90
D. 2, 34, 46, 88, 90
Answer» E.
1371.

What will be the output of the given set of code?
 static void Main(string[] args) { int[] x = { 80, 82, 65, 72, 83, 67 }; fun(x); Console.ReadLine(); } static void fun(params int [] b ) { int i; for (i = 5; i >=0 ; i--) { Console.WriteLine(Convert.ToChar(b[i])); } }  

A. 67 83 72 65 82 80
B. P R A H S C
C. C S H A R P
D. 80 82 65 72 83 67
Answer» D. 80 82 65 72 83 67
1372.

What will be the output of the given set of code?
 static void Main(string[] args) { int[] x = {65, 66, 67, 68, 69, 70}; fun(x); Console.ReadLine(); } static void fun(params int[] b ) { int i; for (i = 5; i > 0 ; i--) { b[i] = b[i] + 32; Console.WriteLine(Convert.ToChar(b[i])); } }  

A. A, B, C, D, E, F
B. F, E, D, C, B, A
C. F, e, d, c, b
D. B, c, d, e, f
Answer» D. B, c, d, e, f
1373.

What will be the output of the given code snippet?
 static void main(String args[]) { char chars[] = {'x', 'y', 'z'}; String s = new String(chars); Console.WriteLine(s); }  

A. X
B. Xy
C. Z
D. Xyz
Answer» E.
1374.

Choose the effective stringBuilder method which helps in producing output for the given code?
 static void Main(string[] args) { StringBuilder s = new StringBuilder("object"); s./*______*/("Oriented Language"); Console.WriteLine(s); Console.ReadLine(); } Output : objectOriented Language  

A. Insert()
B. Add()
C. Append()
D. Join()
Answer» D. Join()
1375.

What will be the output for the given code snippet?
 static void Main(string[] args) { string s = " i love you"; Console.WriteLine(s.IndexOf('l') + " " + s.lastIndexOf('o') + " " + s.IndexOf('e')); Console.ReadLine(); }  

A. 3 5 7
B. 4 5 6
C. 3 9 6
D. 2 4 6
Answer» D. 2 4 6
1376.

What will be the output of the given code snippet?
 static void Main(string[] args) { string c = "hello"; string c1 = c.Remove(1); Console.WriteLine(c1); Console.ReadLine(); }  

A. Ello
B. H
C. Hell
D. None of the mentioned
Answer» C. Hell
1377.

How to print on the screen?

A. Console.WriteLine( ),
B. Console.WriteLine( ),
C. Console.WriteLine( ),
D. Console.WriteLine( ),
Answer» D. Console.WriteLine( ),
1378.

What is the output of the given set of Code?
  class Program { static void Main(string[] args) { String s1 = "I love You"; String s2 = s1; Console.WriteLine((s1 == s2) + " " + s1.Equals(s2)); Console.ReadLine(); } }  

A. True true
B. False false
C. True false
D. False true
Answer» B. False false
1379.

What is output of the given set of Code?
  class Program { static void Main(string[] args) { String []chars = {"z", "x", "y", "z", "y"}; for (int i = 0; i < chars.Length; ++i) for (int j = i + 1; j < chars.Length; ++j) if(chars[i].CompareTo(chars[j]) == 0) Console.WriteLine(chars[j]); Console.ReadLine(); } }  

A. Zx
B. Xy
C. Zy
D. Yz
Answer» D. Yz
1380.

What will be the output for the given set of code ?
  String a = "Csharp"; String b = "CSHARP"; int c; c = a.CompareTo(b); Console.WriteLine(c);  

A. 0
B. 1
C. -2
D. -1
Answer» E.
1381.

What will be the output for the given set of code?
  static void Main(string[] args) { String a = "Ilove"; String b = "CSHARP"; b = string.Concat(a, ' ', b); Console.WriteLine(b); Console.ReadLine(); }  

A. IloveCSHARP
B. I loveCSHARP
C. Ilove
D. Ilove CSHARP
Answer» E.
1382.

What will be the output for the given set of code?
 static void Main(string[] args) { String a = "Ilove"; String b = "CSHARP"; b = string.Concat(a,' ',b); string d = b.TrimStart('I', 'l', 'o', 'H'); Console.WriteLine(d); Console.ReadLine(); }  

A. Ilove CSHARP
B. Love CSHARP
C. Ve CSHARP
D. Ve CSARP
Answer» D. Ve CSARP
1383.

What will be the output for the given set of code?
 static void Main(string[] args) { String c = " Hello Computer "; String a = c.Trim(); Console.WriteLine(" "" + s + " ""); }  

A. Hello Computer
B. HelloComputer
C. Hello Computer
D. Hello Computer
Answer» D. Hello Computer
1384.

Choose Output for the following set of code :
 static void Main(string[] args) { string s1 = "Hello" + " I " + "Love" + " ComputerScience "; Console.WriteLine(s1); Console.ReadLine(); }  

A. HelloILoveComputerScience
B. Hello I Love ComputerScience
C. Compile time error
D. Hello
Answer» C. Compile time error
1385.

What will be output of the following set of code :
 static void Main(string[] args) { string s1 = "Hello I Love Csharp "; Console.WriteLine(Convert.ToChar( (s1.IndexOf('I') - s1.IndexOf('l')) * s1.IndexOf('p')); Console.ReadLine(); }  

A. I
B. Hello I
C. Love
D. H
Answer» E.
1386.

What would be the output for the following set of code?
 static void Main(string[] args) { String obj = "hello"; String obj1 = "world"; String obj2 = obj; Console.WriteLine (obj.Equals(obj2) + " " + obj2.CompareTo(obj) ); Console.ReadLine(); }  

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

What is output for the following set of Code?
  static void Main(string[] args) { String obj = "hello"; String obj1 = "world"; String obj2 = obj; string s = obj+" "+obj1; Console.WriteLine(s.IndexOf('r')); Console.ReadLine(); }  

A. 7
B. 8
C. 9
D. 10
Answer» C. 9
1388.

What is output for the set of code?
  static void Main(string[] args) { String obj = "hello"; String obj1 = "world"; String obj2 = obj; string s = obj + " " + obj1; Console.WriteLine(s.Substring(6 ,5)); Console.ReadLine(); }  

A. Hello
B. Orld
C. World
D. O world
Answer» D. O world
1389.

What will be the output for the set of given code?
  static void Main(string[] args) { String obj = "hello"; String obj1 = "worn"; String obj2 = obj; Console.WriteLine(obj + " " + (obj1.Replace('w' ,'c'))); Console.ReadLine(); }  

A. Hello hello
B. Hello worn
C. Hello corn
D. Hello
Answer» D. Hello
1390.

Which statement is correct about following set of code ?

int[, ]a={{5, 4, 3},{9, 2, 6}};

A. A represents 1-D array of 5 integers
B. A.GetUpperBound(0) gives 9
C. A represents rectangular array of 2 columns and 3 arrays
D. A.GetUpperBound(0) gives 2
Answer» D. A.GetUpperBound(0) gives 2
1391.

What is output of the following set of code?
 static void Main(string[] args) { Program p = new Program(); p.display(2, 3, 8); int []a = { 2, 56, 78, 66 }; Console.WriteLine("example of array"); Console.WriteLine("elements added are"); p.display(a); Console.ReadLine(); } public void display(params int[] b) { foreach (int i in b) { Console.WriteLine("ARRAY IS HAVING:{0}", i); } }  

A. Compile time error
B. Run time error
C. Code runs successfully but prints nothing
D. Code runs successfully and prints given on console
Answer» E.
1392.

What is output for the following set of code:
 static void Main(string[] args) { string s1 = " Cshr "; string s2 = s1.Insert(3 , " a "); string s3 = s2.Insert(5 , " p "); for (int i = 0;i < s3.Length; i++) Console.WriteLine(s3[i]); Console.ReadLine(); }  

A. Cshar
B. CsharP
C. Csharp
D. Cshrap
Answer» D. Cshrap
1393.

What is output for the following set of code?
 static void Main(string[] args) { string s1 = "Hello"; string s2 = "hello"; if (s1 == s2) Console.WriteLine("Equal"); else Console.WriteLine("Unequal"); if (s1.Equals (s2)) Console.WriteLine("Equal"); else Console.WriteLine("Unequal"); Console.ReadLine(); }  

A. Equal - Unequal
B. Unequal - Equal
C. Equal - Equal
D. Unequal - Unequal
Answer» E.
1394.

Which of the following statements are true about the C#.NET code snippet given below?

1. String objects cannot be created without using new.
2. Only one object will get created.
3. s1 and s2 both will refer to the same object.
4. Two objects will get created, one pointed to by s1 and another pointed to by s2.
5. s1 and s2 are references to the same object.

String s1, s2; s1 = "Hi"; s2 = "Hi"; 

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

Which of the following will be the correct output for the C#.NET code snippet given below?
 String s1 = "ALL MEN ARE CREATED EQUAL"; String s2; s2 = s1.Substring(12, 3); Console.WriteLine(s2);  

A. ARE
B. CRE
C. CR
D. REA
Answer» C. CR
1396.

Which of the following will be the correct output for the C#.NET code snippet given below?
 String s1 = "Nagpur"; String s2; s2 = s1.Insert(6, "Mumbai"); Console.WriteLine(s2);  

A. NagpuMumbair
B. Nagpur Mumbai
C. Mumbai
D. NagpurMumbai
Answer» E.
1397.

What will be the output of the C#.NET code snippet given below?
 namespace McqsMentorConsoleApplication { class SampleProgram { static void Main(string[ ] args) { string str= "Hello World!"; Console.WriteLine( String.Compare(str, "Hello World?" ).GetType() ); } } }  

A. 0
B. 1
C. String
D. System.Int32
Answer» E.
1398.

Which of the following snippets are the correct way to convert a Single into a String?
  1. Single f = 9.8f; String s; s = (String) (f); 2. Single f = 9.8f; String s; s = Convert.ToString(f); 3. Single f = 9.8f; String s; s = f.ToString(); 4. Single f = 9.8f; String s; s = Clnt(f); 5. Single f = 9.8f; String s; s = CString(f);  

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

Which of the following will be the correct output for the C#.NET code snippet given below?
 String s1="Kicit"; Console.Write(s1.IndexOf('c') + " "); Console.Write(s1.Length);  

A. 3 6
B. 2 5
C. 3 5
D. 2 6
Answer» C. 3 5
1400.

Which of the following is correct way to convert a String to an int?
 1. String s = "123"; int i; i = (int)s; 2. String s = "123"; int i; i = int.Parse(s); 3. String s = "123"; int i; i = Int32.Parse(s); 4. String s = "123"; int i; i = Convert.ToInt32(s); 5. String s = "123"; int i; i = CInt(s);  

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