

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.
1251. |
Which of the following statements are correct about functions used in C#.NET? 1. Function definitions cannot be nested. 2. Functions can be called recursively. 3. If we do not return a value from a function then a value -1 gets returned. 4. To return the control from middle of a function exit function should be used. 5. Function calls can be nested. |
A. | 1, 2, 5 |
B. | 2, 3, 5 |
C. | 2, 3 |
D. | 4, 5 |
Answer» B. 2, 3, 5 | |
1252. |
What will be the output of the C#.NET code snippet given below? namespace McqsMentorConsoleApplication { class SampleProgram { static void Main(string[ ] args) { object[] o = new object[] {"1", 4.0, "CompSci", 'B'}; fun (o); } static void fun (params object[] obj) { for (int i = 0; i < obj.Length-1; i++) Console.Write(obj[i] + " "); } } } |
A. | 1 4.0 CompSci B |
B. | 1 4.0 CompSci |
C. | 1 4 CompSci |
D. | 1 CompSci B |
Answer» D. 1 CompSci B | |
1253. |
What will be the output of the C#.NET code snippet given below? namespace McqsMentorConsoleApplication { class SampleProgram { static void Main(string[ ] args) { int i; int res = fun(out i); Console.WriteLine(res); } static int fun (out int i) { int s = 1; i = 7; for(int j = 1; j <= i; j++) { s = s * j; } return s; } } } |
A. | 1 |
B. | 7 |
C. | 8 |
D. | 5040 |
Answer» E. | |
1254. |
What does the following C#.NET code snippet will print? int i = 0, j = 0; label: i++; j+=i; if (i < 10) { Console.Write(i +" "); goto label; } |
A. | Prints 1 to 9 |
B. | Prints 0 to 8 |
C. | Prints 2 to 8 |
D. | Prints 2 to 9 |
Answer» B. Prints 0 to 8 | |
1255. |
Which of the following is the correct output for the C#.NET program given below? int i = 20 ; for( ; ; ) { Console.Write(i + " "); if (i >= -10) i -= 4; else break; } |
A. | 20 16 12 84 0 -4 -8 |
B. | 20 16 12 8 4 0 |
C. | 20 16 12 8 4 0 -4 -8 -12 |
D. | 16 12 8 4 0 |
Answer» D. 16 12 8 4 0 | |
1256. |
What is the output of the C#.NET code snippet given below? namespace McqsMentorConsoleApplication { public enum color { red, green, blue }; class SampleProgram { static void Main (string[ ] args) { color c = color.blue; switch (c) { case color.red: Console.WriteLine(color.red); break; case color.green: Console.WriteLine(color.green); break; case color.blue: Console.WriteLine(color.blue); break; } } } } |
A. | Red |
B. | Blue |
C. | 0 |
D. | 1 |
Answer» C. 0 | |
1257. |
Which of the following is the correct way to rewrite the following C#.NET code snippet given below? int i = 0; do { Console.WriteLine(i); i+ = 1; } while (i <= 10); A. int i = 0; do { Console.WriteLine(i); } until (i <= 10); B. int i; for (i = 0; i <= 10 ; i++) Console.WriteLine(i); C. int i = 0; while (i <= 11) { Console.WriteLine(i); i += 1; } D. int i = 0; do while ( i <= 10) { Console.WriteLine(i); i += 1; } |
A. | A |
B. | B |
C. | C |
D. | D |
Answer» C. C | |
1258. |
What will be the output of the C#.NET code snippet given below? int val; for (val = -5; val <= 5; val++) { switch (val) { case 0: Console.Write ("CompSci"); break; } if (val > 0) Console.Write ("B"); else if (val < 0) Console.Write ("X"); } |
A. | XXXXXCompSci |
B. | CompSciBBBBB |
C. | XXXXXCompSciBBBBB |
D. | BBBBBCompSciXXXXX |
Answer» D. BBBBBCompSciXXXXX | |
1259. |
What will be the output of the C#.NET code snippet given below? char ch = Convert.ToChar ('a' | 'b' | 'c'); switch (ch) { case 'A': case 'a': Console.WriteLine ("case A | case a"); break; case 'B': case 'b': Console.WriteLine ("case B | case b"); break; case 'C': case 'c': case 'D': case 'd': Console.WriteLine ("case D | case d"); break; } |
A. | Case A | case a |
B. | Case B | case b |
C. | Case D | case d |
D. | Compile Error |
Answer» D. Compile Error | |
1260. |
Select the output for the following set of Code : static void Main(string[] args) { int a = 5, b = 10; if (Convert.ToBoolean(Convert.ToInt32(++a)) || Convert.ToBoolean(Convert.ToInt32(++b))) { Console.WriteLine(a + " n" + b); } else Console.WriteLine(" C# "); } |
A. | 6 11 |
B. | 6 16 |
C. | 6 12 |
D. | 6 10 |
Answer» E. | |
1261. |
Select the output for the following set of code. static void Main(string[] args) { int movie = 1; switch (movie << 2 + movie) { default: Console.WriteLine("A Movie"); break; case 4: Console.WriteLine("B Movie"); break; case 5: Console.WriteLine("C Movie"); break; case 8: Console.WriteLine("D Movie"); break; } Console.ReadLine(); } |
A. | A Movie |
B. | B Movie |
C. | C Movie |
D. | D Movie |
Answer» D. D Movie | |
1262. |
Select the output for the following set of code : static void Main(string[] args) { int i = 2, j = 4; switch (i + j * 2) { case 1 : case 2 : Console.WriteLine("1 and 2"); break; case 3 to 10: Console.WriteLine("3 to 10"); break; } Console.ReadLine(); } |
A. | 3 to 10 will be printed |
B. | 1 and 2 will be printed |
C. | The code reports an error as missing , before : |
D. | The code gives output as 3 to 10 |
Answer» D. The code gives output as 3 to 10 | |
1263. |
Select the output for the following set of code : static void Main(string[] args) { int i = 2, k = 3; switch (i - k) { case -1: ++i; ++k; break; case 2: --i; ++k; break; default: i += 3; k += i; break; } Console.WriteLine(i + " n" + k); Console.ReadLine(); } |
A. | 2 3 3 |
B. | 3 2 3 |
C. | 3 4 4 |
D. | 5 10 10 |
Answer» D. 5 10 10 | |
1264. |
Select output for the following set of code : static void Main(string[] args) { int const p = 0; switch (3 * 5 / 6) { case p: Console.WriteLine("A"); break; case p * 1: Console.WriteLine("B"); break; case p - 2: Console.WriteLine("C"); break; default: Console.WriteLine("D"); } } |
A. | A |
B. | B |
C. | C |
D. | Compile time error |
Answer» E. | |
1265. |
Select output for the following set of code : static void Main(string[] args) { int i = 2, j = 3, k = 4; switch (i + j - k) { case 0: case 2: case 4: ++i; k += j; break; case 1: case 3: case 5 : --i; k -= j; break; default: i += j; break; } Console.WriteLine(i + " n" + j + " n" + k); Console.ReadLine(); } |
A. | 1 3 1 |
B. | 2 3 4 |
C. | 5 3 4 |
D. | Compile time error. |
Answer» B. 2 3 4 | |
1266. |
Select the output for the following set of code : static void Main(string[] args) { int i = 9 , j = 7; switch (i - j + 3) { case 9: 7: j += 6; break; case 5: i -= 4; break; } Console.WriteLine(i + " n" + j); Console.ReadLine(); } |
A. | 5 7 |
B. | 9 13 |
C. | Compile time error |
D. | 9 7 |
Answer» D. 9 7 | |
1267. |
Select the output for the following code : static void Main(string[] args) { switch (5) { case 5.0f: Console.WriteLine("Jhon"); break; case 5: Console.WriteLine("Ammar"); break; case 5.0L: Console.WriteLine("Tailor"); break; default: Console.WriteLine("Sara"); } Console.ReadLine(); } |
A. | Ammar |
B. | Tailor |
C. | Jhon |
D. | Sara |
Answer» F. | |
1268. |
Select output for the following code: static void Main(string[] args) { int i; int j = 1; int []ar = {21, 22, 13, 4}; switch (ar[j]) { case 1: i++; break; case 2: i += 2; j = 3; continue; case 3: i %= 2; j = 4; continue; default: --i; } Console.WriteLine(i); Console.ReadLine(); } |
A. | 23 |
B. | 15 |
C. | Compile time error |
D. | 12 |
Answer» D. 12 | |
1269. |
Select the output for the following set of Code: static void Main(string[] args) { char ch = Convert.ToChar('a' | 'b' | 'c'); switch (ch) { case 'A': case 'a': Console.WriteLine("case A|case a"); break; case 'B': case 'b': Console.WriteLine("case B|case b"); break; case 'C': case 'c': case 'D': case 'd': Console.WriteLine("case D|case d"); break; } Console.ReadLine(); } |
A. | Compile time error |
B. | Case A|case a |
C. | Case B|case b |
D. | Case D|case d |
Answer» E. | |
1270. |
Select the output for the following set of Code: static void Main(string[] args) { char ch = 'p'; switch (ch) { case 'p': Console.WriteLine("coco" + " t" + Convert.ToInt32(ch)); break; default: Console.WriteLine("default"); break; } Console.WriteLine("main"); } |
A. | Coco main |
B. | Coco 112 |
C. | Coco 112 main |
D. | Compile time error |
Answer» D. Compile time error | |
1271. |
Select the output for the following set of code : static void Main(string[] args) { int i; for (i = 0; ; ) { Console.WriteLine("hello"); } Console.ReadLine(); } |
A. | No output |
B. | Hello |
C. | Hello printed infinite times |
D. | Code will give error as expression syntax |
Answer» D. Code will give error as expression syntax | |
1272. |
Select the output for the following set of code : static void Main(string[] args) { float f; for (f = 0.1f; f <= 0.5; f += 1) Console.WriteLine( ++f ); Console.ReadLine(); } |
A. | 1.1 |
B. | 0.1 |
C. | 0.1 0.2 0.3 0.4 0.5 |
D. | None of the mentioned |
Answer» B. 0.1 | |
1273. |
Select the output for the following set of code: static void Main(string[] args) { int I, X; for (I = 1; I <= (9 % 2 + I); I++) { X = (I * 3 + I * 2) / I; Console.WriteLine(X); } Console.ReadLine(); } |
A. | Output of code is 5 10 |
B. | Output is 5 5 5 5 |
C. | Print 5 infinite times |
D. | None of the mentioned |
Answer» D. None of the mentioned | |
1274. |
Select output for the following set of code: static void Main(string[] args) { int I, J = 0; for (I = 1; I < 10; ) ; { J = J + I; I += 2; } Console.WriteLine("Sum of first 10 even numbers is:"+J); Console.ReadLine(); } |
A. | 1 2 3 4 5 6 7 8 9 |
B. | 25 |
C. | 1 |
D. | Run time error |
Answer» E. | |
1275. |
Which of the following is another way to rewrite the code snippet given below? int a = 1, b = 2, c = 0; if (a < b) c = a; |
A. | Int a = 1, b = 2, c = 0; c = a < b ? a : 0, |
B. | Int a = 1, b = 2, c = 0; a < b ? c = a : c = 0; |
C. | Int a = 1, b = 2, c = 0; a < b ? c = a : c = 0 ? 0 : 0; |
D. | Int a = 1, b = 2, c = 0; a < b ? return (c): return (0); |
Answer» B. Int a = 1, b = 2, c = 0; a < b ? c = a : c = 0; | |
1276. |
Which of the following statements are correct? 1. The switch statement is a control statement that handles multiple selections and enumerations by passing control to one of the case statements within its body. 2. The goto statement passes control to the next iteration of the enclosing iteration statement in which it appears. 3. Branching is performed using jump statements which cause an immediate transfer of the program control. 4. A common use of continue is to transfer control to a specific switch-case label or the default label in a switch statement. 5. The do statement executes a statement or a block of statements enclosed in {} repeatedly until a specified expression evaluates to false. |
A. | 1, 2, 4 |
B. | 1, 3, 5 |
C. | 2, 3, 4 |
D. | 3, 4, 5 |
Answer» C. 2, 3, 4 | |
1277. |
Which of the following statements are correct about the C#.NET code snippet given below? if (age > 18 || no < 11) a = 25; 1. The condition no < 11 will get evaluated only if age > 18 evaluates to False. 2. The condition no < 11 will get evaluated if age > 18 evaluates to True. 3. The statement a = 25 will get evaluated if any one one of the two conditions is True. 4. || is known as a short circuiting logical operator. 5. The statement a = 25 will get evaluated only if both the conditions are True. |
A. | 1, 4, 5 |
B. | 2, 4 |
C. | 1, 3, 4 |
D. | 2, 3, 5 |
Answer» D. 2, 3, 5 | |
1278. |
What will be the output of the code snippet given below? int i; for(i = 0; i<=10; i++) { if(i == 4) { Console.Write(i + " "); continue; } else if (i != 4) Console.Write(i + " "); else break; } |
A. | 1 2 3 4 5 6 7 8 9 10 |
B. | 1 2 3 4 |
C. | 0 1 2 3 4 5 6 7 8 9 10 |
D. | 4 5 6 7 8 9 10 |
Answer» D. 4 5 6 7 8 9 10 | |
1279. |
Which of the following loop correctly prints the elements of the array? char[ ] arr = new char[ ] {'k', 'i','C', 'i','t'} ; |
A. | do { Console.WriteLine((char) i); } while (int i = 0; i < arr; i++); |
B. | foreach (int i in arr) { Console.WriteLine((char) i); } |
C. | for (int i = 0; i < arr; i++) { Console.WriteLine((char) i); } |
D. | while (int i = 0; i < arr; i++) { Console.WriteLine((char) i); } |
Answer» C. for (int i = 0; i < arr; i++) { Console.WriteLine((char) i); } | |
1280. |
Which of the following statements is correct about the C#.NET code snippet given below? int i, j, id = 0; switch (id) { case i: Console.WriteLine("I am in Case i"); break; case j: Console.WriteLine("I am in Case j"); break; } |
A. | The compiler will report case i and case j as errors since variables cannot be used in cases. |
B. | Compiler will report an error since there is no default case in the switch case statement. |
C. | The code snippet prints the result as "I am in Case i"". |
D. | The code snippet prints the result as "I am in Case j". |
Answer» B. Compiler will report an error since there is no default case in the switch case statement. | |
1281. |
Select output for the following set of Code: static void Main(string[] args) { int i; int b = 8, a = 32; for (i = 0; i <= 10; i++) { if ((a / b * 2)== 2) { Console.WriteLine( i + " "); continue; } else if (i != 4) Console.Write(i + " "); else break; } Console.ReadLine(); } |
A. | 1 2 3 4 5 6 7 8 9 |
B. | 0 1 2 3 4 5 6 7 8 |
C. | 0 1 2 3 |
D. | 0 1 2 3 4 |
Answer» D. 0 1 2 3 4 | |
1282. |
Select the output for the following set of Code. Which of the following conditions are true ? static void Main(string[] args) { Console.WriteLine("Enter a letter:"); char c = (char)Console.Read(); if (Char.IsDigit(c) == true) Console.WriteLine("A number"); else if (char.IsLower(c) == true) Console.WriteLine("A lower case letter"); else if (char.IsUpper(c) == true) Console.WriteLine("An upper case letter"); Console.ReadLine(); } A. Enter a letter : a An upper case letter B. Enter a letter : A An upper case letter C. Enter a letter : 2 A number D. Enter a letter : 2 A lower case letter. |
A. | A ,B ,C |
B. | B ,C ,D |
C. | A ,D ,B |
D. | B ,C |
Answer» E. | |
1283. |
Select the correct if statement to be filled in the given set of code : static void Main(string[] args) { int []num = {50, 65, 56, 88, 43, 52}; int even = 0, odd = 0; for (int i = 0 ;i < num.Length ;i++) { /*___________________________*/ } Console.WriteLine("Even Numbers:" +even); Console.WriteLine("Odd Numbers:" +odd); Console.ReadLine(); } a) if ((num % 2) == 0) { even += 1; } else { odd += 1; } b) if((num * i) == 0) { even += 1; } else { odd += 1; } c) if(num[i] % 2 == 0) { even += 1; } else { odd += 1; } d) if(num[i] % 2 = 0) { even += 1; } else { odd += 1; } |
A. | A |
B. | B |
C. | C |
D. | D |
Answer» D. D | |
1284. |
What is the output for the following code ? static void Main(string[] args) { int a = 15, b = 10, c = 1; if (Convert.ToBoolean(a) && (b > c)) { Console.WriteLine("cquestionbank"); } else { break; } } |
A. | Cquestionbank |
B. | It will print nothing |
C. | Compile time error |
D. | Run time error |
Answer» D. Run time error | |
1285. |
Select the output for the following set of Code : static void Main(string[] args) { int a = -1; int b = -1; if (Convert.ToBoolean (++a = ++b)) Console.WriteLine("a"); else Console.WriteLine("b"); Console.ReadLine(); } |
A. | A |
B. | B |
C. | Compile time error |
D. | Code execute successfully with no output |
Answer» D. Code execute successfully with no output | |
1286. |
What is the output for the following code ? static void Main(string[] args) { int a = 5; if (Convert.ToBoolean((.002f) -(0.1f))) Console.WriteLine("Saeed Anwar"); else if (a == 5) Console.WriteLine("Rmeez Raja"); else Console.WriteLine("Ijaz Ahmed"); Console.ReadLine(); } |
A. | Rameez Raja |
B. | Saeed Anwar |
C. | Ijaz Ahmed |
D. | Warning : Unreachable Code |
Answer» C. Ijaz Ahmed | |
1287. |
Select the output for the following set of Code : static void Main(string[] args) { int a = 5, b = 10; if (Convert.ToBoolean(Convert.ToInt32(0xB))) if (Convert.ToBoolean(Convert.ToInt32(022))) if (Convert.ToBoolean(Convert.ToInt32(' xeb'))) Console.WriteLine("java"); else ; else ; else ; } |
A. | Compile time error: Misplaced else |
B. | Compile time error: Undefined symbol |
C. | Java |
D. | Warning: Condition is always true |
Answer» D. Warning: Condition is always true | |
1288. |
Which of the following code snippets are the correct way to determine whether a is Odd or Even? 1. int a; String res; if (a % 2 == 0) res = "Even"; else res = "Odd"; 2. int a; String res; if (a Mod 2 == 0) res = "Even"; else res = "Odd"; 3. int a; Console.WriteLine(a Mod 2 == 0 ? "Even": "Odd"); 4. int a; String res; a % 2 == 0 ? res = "Even" : res = "Odd"; Console.WriteLine(res); |
A. | 1, 3 |
B. | 1 Only |
C. | 2, 3 |
D. | 4 Only |
Answer» C. 2, 3 | |
1289. |
Which of the following can be used to terminate a while loop and transfer control outside the loop?1. exit while2. continue3. exit statement4. break5. goto |
A. | 1, 3 |
B. | 2, 4 |
C. | 3, 5 |
D. | 4, 5 |
Answer» E. | |
1290. |
The C#.NET code snippet given below generates ____ numbers series as output? int i = 1, j = 1, val; while (i < 25) { Console.Write(j + " "); val = i + j; j = i; i = val; } |
A. | Prime |
B. | Fibonacci |
C. | Palindrome |
D. | Odd |
Answer» C. Palindrome | |
1291. |
Which of the following statements are correct about the C#.NET code snippet given below? if (age > 18 && no < 11) a = 25; 1. The condition no < 11 will be evaluated only if age > 18 evaluates to True. 2. The statement a = 25 will get executed if any one condition is True. 3. The condition no < 11 will be evaluated only if age > 18 evaluates to False. 4. The statement a = 25 will get executed if both the conditions are True. 5. && is known as a short circuiting logical operator. |
A. | 1, 3 |
B. | 2, 5 |
C. | 1, 4, 5 |
D. | 3, 4, 5 |
Answer» D. 3, 4, 5 | |
1292. |
Which of the following statements are correct? 1. A switch statement can act on numerical as well as Boolean types. 2. A switch statement can act on characters, strings and enumerations types. 3. We cannot declare variables within a case statement if it is not enclosed by { }. 4. The foreach statement is used to iterate through the collection to get the desired information and should be used to change the contents of the collection to avoid unpredictable side effects. 5. All of the expressions of the for statement are not optional. |
A. | 1, 2 |
B. | 2, 3 |
C. | 3, 5 |
D. | 4, 5 |
Answer» B. 2, 3 | |
1293. |
What will be the output of the C#.NET code snippet given below? int i = 2, j = i; if (Convert.ToBoolean((i | j & 5) & (j - 25 * 1))) Console.WriteLine(1); else Console.WriteLine(0); |
A. | 0 |
B. | 1 |
C. | Compile Error |
D. | Run time Error |
Answer» B. 1 | |
1294. |
Which of the following statements is correct about the C#.NET code snippet given below? switch (id) { case 6: grp = "Grp B"; break; case 13: grp = "Grp D"; break; case 1: grp = "Grp A"; break; case ls > 20: grp = "Grp E"; break ; case Else: grp = "Grp F"; break; } |
A. | Compiler will report an error in case ls > 20 as well as in case Else. |
B. | There is no error in this switch case statement. |
C. | Compiler will report an error only in case Else. |
D. | Compiler will report an error as there is no default case. |
Answer» B. There is no error in this switch case statement. | |
1295. |
What would be the output of given code snippet? static void Main(string[] args) { String a ="i love iostream"; Console.WriteLine(a.IndexOf('i') + " " + a.IndexOf('e') + " " + a.LastIndexOf('i') + " " + a.LastIndexOf('e')); Console.ReadLine(); } |
A. | 0 6 7 8 |
B. | 0 5 7 9 |
C. | 5 9 0 7 |
D. | 0 5 7 12 |
Answer» E. | |
1296. |
What will be the output of given code snippet? static void Main(string[] args) { StringBuilder sb = new StringBuilder("hello world"); sb.Insert(6, "good"); Console.WriteLine(sb); Console.ReadLine(); } |
A. | Hello 6world |
B. | Hello good world |
C. | Hello goodworld |
D. | Hello good world |
Answer» D. Hello good world | |
1297. |
What will be the output of given code snippet? static void Main(string[] args) { string h = "i lovelife"; string h1 = new string(h.Reverse().ToArray()); Console.WriteLine(h1); Console.ReadLine(); } |
A. | Efil evoli |
B. | Lifelove i |
C. | Efilevol i |
D. | Efil evol i |
Answer» D. Efil evol i | |
1298. |
Choose the output for the following set of code? static void Main(string[] args) { Console.WriteLine("This is a Console Application:"); Console.Write("Please enter your lucky number:"); string val1 = Console.ReadLine(); int val2 = System.Convert.ToInt32(val1, 10); val2 = val2 * val2; Console.WriteLine("square of number is:" +val2); Console.Read(); } |
A. | Compile time error |
B. | Runs successfully does not print anything |
C. | Runs successfully, ask for input and hence displays the result |
D. | Syntax Error |
Answer» D. Syntax Error | |
1299. |
What would be the output for following input from the console as a character? static void Main(string[] args) { Console.WriteLine("what is your name?"); char s; s = Convert.ToChar(Console.ReadLine()); Console.WriteLine("how are you: "+s); Console.Read(); } |
A. | Compile time error |
B. | Code run successfully prints nothing on console |
C. | Code runs successfully prints input on console |
D. | Run time error |
Answer» E. | |
1300. |
The correct way to apply the custom attribute called Employer which receives two arguements name of the employee and employeeid is? |
A. | Custom attribute can be applied to an assembly |
B. | [assembly : Employer( Hanna ,employeeid.one)]. |
C. | [ Employer( Hanna , employeeid.second)] class employee{} |
D. | All of the mentioned |
Answer» E. | |