

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.
1051. |
What will be the output of the following PHP code ? <?php $x = 3, 4, 5, 6; echo "$x"; ?> |
A. | 3 |
B. | 4 |
C. | 6 |
D. | Error |
Answer» E. | |
1052. |
What will be the output of the following PHP code? <?php function convertSpace($string) { return str_replace("_", " ", $string); } $string = "Peter_is_a_great_guy!"; echo filter_var($string, FILTER_CALLBACK, array("options"=>"convertSpace")); ?> |
A. | Peter_is_a_great_guy! |
B. | Peterisagreatguy! |
C. | Peter is a great guy! |
D. | Error |
Answer» D. Error | |
1053. |
What will be the output of the following PHP code ? <?php $x = 0; function fun() { echo $GLOBALS['x']; $x++; } fun(); fun(); fun(); ?> |
A. | 000 |
B. | 012 |
C. | Nothing |
D. | Error |
Answer» B. 012 | |
1054. |
Which of the following will be the correct output for the C#.NET program given below? namespace McqsMentorConsoleApplication { struct Sample { public int i; } class MyProgram { static void Main() { Sample x = new Sample(); x.i = 10; fun(x); Console.Write(x.i + " "); } static void fun(Sample y) { y.i = 20; Console.Write(y.i + " "); } } } |
A. | 10 20 |
B. | 10 10 |
C. | 20 10 |
D. | 20 20 |
Answer» D. 20 20 | |
1055. |
Which of the following is the correct way to define a variable of the type struct Emp declared below? 1. Emp e(); e = new Emp(); 2. Emp e = new Emp; 3. Emp e; e = new Emp; 4. Emp e = new Emp(); 6. Emp e; struct Emp { private String name; private int age; private Single sal; } |
A. | 1, 3 |
B. | 2, 5 |
C. | 4, 5 |
D. | 1, 2, 4 |
Answer» D. 1, 2, 4 | |
1056. |
Which of the following statements is correct about the C#.NET code snippet given below? class Trial { int i; Decimal d; } struct Sample { private int x; private Single y; private Trial z; } Sample ss = new Sample(); |
A. | Ss will be created on the heap. |
B. | Trial object referred by z will be created on the stack. |
C. | Z will be created on the heap. |
D. | Ss will be created on the stack. |
Answer» E. | |
1057. |
How many bytes will the structure variable samp occupy in memory if it is defined as shown below? class Trial { int i; Decimal d; } struct Sample { private int x; private Single y; private Trial z; } Sample samp = new Sample(); |
A. | 20 bytes |
B. | 12 bytes |
C. | 8 bytes |
D. | 16 bytes |
Answer» C. 8 bytes | |
1058. |
Which of the following will be the correct result of the statement b = a in the C#.NET code snippet given below? struct Address { private int plotno; private String city; } Address a = new Address(); Address b; b = a; |
A. | All elements of a will get copied into corresponding elements of b. |
B. | Address stored in a will get copied into b. |
C. | Once assignment is over a will get garbage collected. |
D. | Once assignment is over a will go out of scope, hence will die. |
Answer» B. Address stored in a will get copied into b. | |
1059. |
Which of the following statements are correct? 1. A struct can contain properties. 2. A struct can contain constructors. 3. A struct can contain protected data members. 4. A struct cannot contain methods. 5. A struct cannot contain constants. |
A. | 1, 2 |
B. | 3, 4 |
C. | 1, 2, 4 |
D. | 3, 5 |
Answer» B. 3, 4 | |
1060. |
When would a structure variable get destroyed? |
A. | When no reference refers to it, it will get garbage collected. |
B. | Depends upon whether it is created using new or without using new. |
C. | When it goes out of scope. |
D. | Depends upon the Project Settings made in Visual Studio.NET. |
Answer» D. Depends upon the Project Settings made in Visual Studio.NET. | |
1061. |
What does the following property defined in the array class defines in C#? public bool IsReadOnly { get; } |
A. | A property is read only by nature |
B. | Property is true if the array object is read only and false otherwise |
C. | Value is false for arrays |
D. | All of the above |
Answer» E. | |
1062. |
What does the following property define in C#? public static int BinarySearch(T[] array, int index, int length, T value) |
A. | Searches a portion of the array specified by array for the value specified by value |
B. | The search begins at the index specified by index and is restricted to length elements. Returns the index of the first match. |
C. | If value is not found, returns a zero value |
D. | Both a and b |
Answer» E. | |
1063. |
What will be the output of given code snippet? static void Main() { int[] nums = { 1, 2, 3, 4, 5 }; Console.Write("Original order: "); foreach(int i in nums) Console.Write(i + " "); Array.Reverse(nums); Console.Write("Reversed order: "); foreach(int i in nums) Console.Write(i + " "); Console.WriteLine(); } |
A. | Run time error |
B. | 5, 4, 3, 2, 1 |
C. | Compile time error |
D. | None of the mentioned |
Answer» C. Compile time error | |
1064. |
What does the following code signify? expr is type |
A. | Determines the type of an object |
B. | A simple deceleration |
C. | Both a & b |
D. | None of the mentioned |
Answer» B. A simple deceleration | |
1065. |
Which of the following are correct ways to pass a parameter to an attribute? 1. By value 2. By reference 3. By address 4. By position 5. By name |
A. | 1, 2 |
B. | 1, 2, 3 |
C. | 4, 5 |
D. | All of the above |
Answer» D. All of the above | |
1066. |
Which of the following statements are correct about inspecting an attribute in C#.NET? 1. An attribute can be inspected at link-time. 2. An attribute can be inspected at compile-time. 3. An attribute can be inspected at run-time. 4. An attribute can be inspected at design-time. |
A. | 1, 2 |
B. | 3, 4 |
C. | 1, 3, 4 |
D. | All of the above |
Answer» B. 3, 4 | |
1067. |
Which of the following is the correct way of applying the custom attribute called Tested which receives two-arguments name of the tester and the testgrade?1. Custom attribute cannot be applied to an assembly.2. [assembly: Tested( Sachin , testgrade.Good)]3. [Tested( Virat , testgrade.Excellent)] class customer { /* . */ }4. Custom attribute cannot be applied to a method.5. Custom attribute cannot be applied to a class. |
A. | 1 only |
B. | 1, 5 |
C. | 2, 3 |
D. | 4, 5 |
Answer» D. 4, 5 | |
1068. |
Which of the following statements are correct about Attributes in C#.NET? 1. On compiling a C#.NET program the attibutes applied are recorded in the metadata of the assembly. 2. On compilation all the attribute s tags are deleted from the program. 3. It is not possible to create custom attributes.. 4. The attributes applied can be read from an assembly using Reflection class. 5. An attribute can have parameters. |
A. | 1 and 2 only |
B. | 2 and 4 only |
C. | 1, 4 and 5 only |
D. | All of the above |
Answer» D. All of the above | |
1069. |
Which of the following statements is correct about the C#.NET code snippet given below? struct Book { private String name; private int noofpages; private Single price; } Book b = new Book(); |
A. | The structure variable b will be created on the heap. |
B. | We can add a zero-argument constructor to the above structure. |
C. | When the program terminates, variable b will get garbage collected. |
D. | The structure variable b will be created on the stack. |
Answer» E. | |
1070. |
Which of the following will be the correct output for the C#.NET program given below? namespace McqsMentorConsoleApplication { struct Sample { public int i; } class MyProgram { static void Main(string[] args) { Sample x = new Sample(); x.i = 10; fun(ref x); Console.Write(x.i + " "); } public static void fun(ref Sample y) { y.i = 20; Console.Write(y.i + " "); } } } |
A. | 20 10 |
B. | 10 20 |
C. | 10 10 |
D. | 20 20 |
Answer» E. | |
1071. |
Which of the following statements are correct about the structure declaration given below? 1. We cannot declare the access modifier of totalpages as protected. 2. We cannot declare the access modifier of name as private. 3. We cannot define a zero-argument constructor inside a structure. 4. We cannot declare the access modifier of price as public. 5. We can define a Showdata() method inside a structure. struct Book { private String name; protected int totalpages; public Single price; public void Showdata() { Console.WriteLine(name + " " + totalpages + " " + price); } Book() { name = " "; totalpages = 0; price = 0.0f; } } Book b = new Book(); |
A. | 1, 2 |
B. | 1, 3, 5 |
C. | 2, 4 |
D. | 3, 4, 5 |
Answer» C. 2, 4 | |
1072. |
Which of the following are true about classes and struct? 1. A class is a reference type, whereas a struct is a value type. 2. Objects are created using new, whereas structure variables can be created either using new or without using new. 3. A structure variable will always be created slower than an object. 4. A structure variable will die when it goes out of scope. 5. An object will die when it goes out of scope. |
A. | 1, 2, 4 |
B. | 3, 5 |
C. | 2, 4 |
D. | 3, 4, 5 |
Answer» B. 3, 5 | |
1073. |
Which of the following will be the correct output for the program given below? namespace McqsMentorConsoleApplication { struct Sample { public int i; } class MyProgram { static void Main(string[] args) { Sample x = new Sample(); Sample y; x.i = 9; y = x; y.i = 5; Console.WriteLine(x.i + " " + y.i); } } } |
A. | 9 9 |
B. | 9 5 |
C. | 5 5 |
D. | 5 9 |
Answer» C. 5 5 | |
1074. |
Which of the following statements are correct about Structures used in C#.NET? 1. A Structure can be declared within a procedure. 2. Structs can implement an interface but they cannot inherit from another struct. 3. struct members cannot be declared as protected. 4. A Structure can be empty. 5. It is an error to initialize an instance field in a struct. |
A. | 1, 2, 4 |
B. | 2, 3, 5 |
C. | 2, 4 |
D. | 1, 3 |
Answer» C. 2, 4 | |
1075. |
If a class Student has an indexer, then which of the following is the correct way to declare this indexer to make the C#.NET code snippet given below work successfully? Student s = new Student(); s[1, 2] = 35; |
A. | class Student { int[ ] a = new int[5, 5]; public property WriteOnly int this[int i, int j] { set { a[i, j] = value; } } } |
B. | class Student { int[ , ] a = new int[5, 5]; public int property WriteOnly { set { a[i, j] = value; } } } |
C. | class Student { int[ , ] a = new int[5, 5]; public int this[int i, int j] { set { a[i, j] = value; } } } |
D. | class Student { int[ , ] a = new int[5, 5]; int i, j; public int this { set { a[i, j] = value; } } } |
Answer» D. class Student { int[ , ] a = new int[5, 5]; int i, j; public int this { set { a[i, j] = value; } } } | |
1076. |
Which of the following statements are correct? 1. The signature of an indexer consists of the number and types of its formal parameters. 2. Indexers are similar to properties except that their accessors take parameters. 3. Accessors of interface indexers use modifiers. 4. The type of an indexer and the type of its parameters must be at least as accessible as the indexer itself. 5. An interface accessor contains a body. |
A. | 1, 3, 5 |
B. | 1, 2, 4 |
C. | 3, 5 |
D. | 2, 4 |
Answer» C. 3, 5 | |
1077. |
If Sample class has a Length property with get and set accessors then which of the following statements will work correctly? 1. Sample.Length = 20; 2. Sample m = new Sample(); m.Length = 10; 3. Console.WriteLine(Sample.Length); 4. Sample m = new Sample(); int len; len = m.Length; 5. Sample m = new Sample(); m.Length = m.Length + 20; |
A. | 1, 3 |
B. | 2, 4, 5 |
C. | 4 only |
D. | 3, 5 |
Answer» C. 4 only | |
1078. |
If a Student class has an indexed property which is used to store or retrieve values to/from an array of 5 integers, then which of the following are the correct ways to use this indexed property? 1.Student[3] = 34; 2. Student s = new Student(); s[3] = 34; 3. Student s = new Student(); Console.WriteLine(s[3]); 4. Console.WriteLine(Student[3]); 5. Student.this s = new Student.this(); s[3] = 34; |
A. | 1, 2 |
B. | 2, 3 |
C. | 3, 4 |
D. | 3, 5 |
Answer» C. 3, 4 | |
1079. |
Which of the following statements is correct about the C#.NET program given below? using System; namespace McqsMentorConsoleApplication { class MyProgram { static void Main(string[] args) { int index = 6; int val = 44; int[] a = new int[5]; try { a[index] = val ; } catch(IndexOutOfRangeException e) { Console.Write("Index out of bounds "); } Console.Write("Remaining program"); } } } |
A. | Value 44 will get assigned to a[6]. |
B. | It will output: Index out of bounds |
C. | It will output: Remaining program |
D. | It will output: Index out of bounds Remaining program |
Answer» E. | |
1080. |
Which of the following statements are correct about exception handling in C#.NET? 1. If an exception occurs then the program terminates abruptly without getting any chance to recover from the exception. 2. No matter whether an exception occurs or not, the statements in the finally clause (if present) will get executed. 3. A program can contain multiple finally clauses. 4. A finally clause is written outside the try block. 5. finally clause is used to perform clean up operations like closing the network/database connections. |
A. | 1 only |
B. | 2 only |
C. | 2 and 5 only |
D. | 3 and 4 only |
Answer» D. 3 and 4 only | |
1081. |
Which of the following statements are correct about exception handling in C#.NET? 1. If our program does not catch an exception then the .NET CLR catches it. 2. It is possible to create user-defined exceptions. 3. All types of exceptions can be caught using the Exception class. 4. CLRExceptions is the base class for all exception classes. 5. For every try block there must be a corresponding finally block. |
A. | 1 and 2 only |
B. | 1, 2 and 3 only |
C. | 4 and 5 only |
D. | All of the above |
Answer» C. 4 and 5 only | |
1082. |
For a class student consisting of indexer,which among the following declaration of indexers runs the code successfully ? student a = new student();a[1,2] = 20; a) class student { int[,] p = new int[6, 6]; public property WriteOnly int this[int i, int j] { set { a[i, j] = value; } } } b) class student { int[,] a = new int[6, 6]; public int this[int i, int j] { set { a[i, j] = value; } } } c) class student { int[,] a = new int[6, 6]; public int property WriteOnly { set { a[i, j] = value; } } } |
A. | A |
B. | B |
C. | C |
D. | None of the mentioned |
Answer» C. C | |
1083. |
Choose the output for the given set of code? class list { ArrayList array = new ArrayList(); public object this[int index] { get { if (index < 0 || index >= array.Count) { return null; } else { return (array[index]); } } set { array[index] = value; } } public int Count { get; set; } } class Program { static void Main(string[] args) { list list1 = new list(); list1[0] = "123"; list1[1] = " abc "; list1[2] = "xyz"; for (int i = 0; i<=list1.Count; i++) Console.WriteLine(list1[i]); Console.ReadLine(); } } |
A. | Compile time error |
B. | Run time error |
C. | 123, abc, xyz |
D. | 0 |
Answer» C. 123, abc, xyz | |
1084. |
Consider a class maths and we had a property called as sum.b is a reference to a maths object and we want the statement b.sum = 10 to fail.Which of the follwing is the correct |
A. | Declare sum property with both get and set accessors |
B. | Declare sum property with only get accessor |
C. | Declare sum property with get, set and normal accessors |
D. | None of the mentioned |
Answer» D. None of the mentioned | |
1085. |
Which of the following statements are correct about the exception reported below? Unhandled Exception: System.lndexOutOfRangeException: Index was outside the bounds of the array: at MyConsoleApplication.MyProgram.SetVal(Int32 index, Int32 val) in D:SampleConsoleApplicationMyProgram.cs:line 26 at MyConsoleApplication.MyProgram.Main(String[] args) in D:SampleMyConsoleApplicationMyProgram.cs:line 20 1. The CLR failed to handle the exception. 2. The class MyProgram belongs to the namespace MyProgram. 3. The function SetVal() was called from Main() in line number 20. 4. The exception occurred in line number 26 in the function SetVal() 5. The runtime exception occurred in the project MyConsoleApplication. |
A. | 1 only |
B. | 1 and 2 only |
C. | 3, 4 and 5 only |
D. | All of the above |
Answer» D. All of the above | |
1086. |
Which of the following statements is correct about the C#.NET program given below if a value 6 is input to it? using System; namespace McqsMentorConsoleApplication { class MyProgram { static void Main(string[] args) { int index; int val = 44; int[] a = new int[5]; try { Console.Write("Enter a number:"); index = Convert.Tolnt32(Console.ReadLine()); a[index] = val; } catch(FormatException e) { Console.Write("Bad Format"); } catch(IndexOutOfRangeException e) { Console.Write("Index out of bounds"); } Console.Write("Remaining program"); } } } |
A. | It will output: Index out of bounds Remaining program |
B. | It will output: Bad Format Remaining program |
C. | It will output: Bad Format |
D. | It will output: Remaining program |
Answer» B. It will output: Bad Format Remaining program | |
1087. |
Which of the following statements are correct about the exception reported below? Unhandled Exception: System.lndexOutOfRangeException: Index was outside the bounds of the array. at McqsMentorConsoleApplication.Program.Main(String[] args) in D:ConsoleApplicationProgram.cs:line 14 1.The program did not handle an exception called IndexOutOfRangeException. 2. The program execution continued after the exception occurred. 3. The exception occurred in line number 14. 4. In line number 14, the program attempted to access an array element which was beyond the bounds of the array. 5. The CLR could not handle the exception. |
A. | 1 only |
B. | 1, 2 and 3 only |
C. | 2 and 5 only |
D. | 1, 3 and 4 only |
Answer» E. | |
1088. |
Which of the following statements are correct about exception handling in C#.NET? 1. try blocks cannot be nested. 2. In one function, there can be only one try block. 3. An exception must be caught in the same function in which it is thrown. 4. All values set up in the exception object are available in the catch block. 5. While throwing a user-defined exception multiple values can be set in the exception, object. |
A. | 1 only |
B. | 1 and 2 only |
C. | 3 only |
D. | 4 and 5 only |
Answer» E. | |
1089. |
Which of the following statements is correct about the C#.NET program given below if a value 6 is input to it? using System; namespace McqsMentorConsoleApplication { class MyProgram { static void Main (string[] args) { int index; int val = 66; int[] a = new int[5]; try { Consote.Write("Enter a number: "); index = Convert.ToInt32(Console.ReadLine()); a[index] = val; } catch(Exception e) { Console.Write("Exception occurred "); } Console.Write("Remaining program "); } } } |
A. | It will output: Exception occurred |
B. | It will output: Remaining program |
C. | It will output: Exception occurred Remaining program |
D. | It will output: Remaining program Exception occurred |
Answer» D. It will output: Remaining program Exception occurred | |
1090. |
Which of the following statements is correct about the C#.NET program given below if a value ABCD is input to it? using System; namespace McqsMentorConsoleApplication { class MyProgram { static void Main(string[] args) { int index; int val = 55; int[] a = new int[5]; try { Console.Write("Enter a number: "); index = Convert.ToInt32(Console.ReadLine()); a[index] = val; } catch(FormatException e) { Console.Write("Bad Format "); } catch(IndexOutOfRangeException e) { Console.Write("Index out of bounds "); } Console.Write("Remaining program "); } } } |
A. | It will output: Bad Format |
B. | It will output: Remaining program |
C. | It will output: Index out of bounds |
D. | It will output: Bad Format Remaining program |
Answer» E. | |
1091. |
Which of the following statements is correct about the C#.NET program given below if a value ABCD is input to it? using System; namespace McqsMentorConsoleApplication { class MyProgram { static void Main(string[] args) { int index; int vat = 88; int[] a = new int(5]; try { Console.Write("Enter a number: "); index = Convert.Toint32(Console.ReadLine()); a[index] = val; } catch(Exception e) { Console.Write("Exception occurred"); } Console.Write("Remaining program"); } } } |
A. | It will output: Exception occurred |
B. | It will output: Remaining program |
C. | It will output: Remaining program Exception occurred |
D. | It will output: Exception occurred Remaining program |
Answer» E. | |
1092. |
What is the output of this program? class Output { public static void main(String args[]) { try { int a = 9; int b = 5; int c = a / b - 5; Console.WriteLine("Hello"); } catch(Exception e) { Console.WriteLine("C"); } finally { Console.WriteLine("sharp"); } } } |
A. | Hello |
B. | C |
C. | Hellosharp |
D. | Csharp |
Answer» E. | |
1093. |
Choose the correct output for the given set of code: static void Main(string[] args) { try { Console.WriteLine("csharp" + " " + 1/Convert.ToInt32(0)); } catch(ArithmeticException e) { Console.WriteLine("Java"); } Console.ReadLine(); } |
A. | Csharp |
B. | Java |
C. | Run time error |
D. | Csharp 0 |
Answer» C. Run time error | |
1094. |
Choose the correct output for given set of code: class Program { static void Main(string[] args) { try { Console.WriteLine("csharp" + " " + 1/0); } finally { Console.WriteLine("Java"); } Console.ReadLine(); } } |
A. | Csharp 0 |
B. | Run time Exception generation |
C. | Compile time error |
D. | Java |
Answer» C. Compile time error | |
1095. |
What will be the output of the following set of code? { int sum = 10; try { int i; for (i = -1; i < 3; ++i) sum = (sum / i); } catch (ArithmeticException e) { Console.WriteLine("0"); } Console.WriteLine(sum); Console.ReadLine(); } |
A. | 0 |
B. | 0 5 |
C. | 0 -10 |
D. | Compile time error |
Answer» D. Compile time error | |
1096. |
What will be the output of the following set of code? { try { int []a = {1, 2, 3, 4, 5}; for (int i = 0; i < 5; ++i) Console.WriteLine(a[i]); int x = (1 / Convert.ToInt32(0)); } catch(IndexOutOfRangeException e) { Console.WriteLine("A"); } catch(ArithmeticException e) { Console.WriteLine("B"); } Console.ReadLine(); } |
A. | 1234 |
B. | 12345 |
C. | Run time error |
D. | 12345B |
Answer» E. | |
1097. |
What will be the output of given code snippet? { try { int []a = {1, 2, 3, 4, 5}; for (int i = 0; i < 7; ++i) Console.WriteLine(a[i]); } catch(IndexOutOfRangeException e) { Console.WriteLine("0"); } Console.ReadLine(); } |
A. | 12345 |
B. | 123450 |
C. | 1234500 |
D. | Compile time error |
Answer» C. 1234500 | |
1098. |
What would be the output of following code snippet? { try { int i, sum; sum = 10; for (i = -1 ;i < 3 ;++i) { sum = (sum / i); Console.WriteLine(i); } } catch(ArithmeticException e) { Console.WriteLine("0"); } Console.ReadLine(); } |
A. | -1 |
B. | 0 |
C. | -1 0 |
D. | -1 0 -1 |
Answer» D. -1 0 -1 | |
1099. |
What would be the output of following code snippet? { try { int a, b; b = 0; a = 5 / b; Console.WriteLine("A"); } catch(ArithmeticException e) { Console.WriteLine("B"); } finally { Console.WriteLine("C"); } Console.ReadLine(); } |
A. | A |
B. | B |
C. | B C |
D. | Run time error |
Answer» D. Run time error | |
1100. |
When no exception is thrown at runtime then who will catch it? |
A. | CLR |
B. | Operating System |
C. | Loader |
D. | Compiler |
Answer» B. Operating System | |