

MCQOPTIONS
Saved Bookmarks
This section includes 299 Mcqs, each offering curated multiple-choice questions to sharpen your Engineering knowledge and support exam preparation. Choose a topic below to get started.
101. |
An enum that is declared inside a class, struct, namespace or interface is treated as public. |
A. | True |
B. | False |
Answer» B. False | |
102. |
Which of the following is the correct way to find out the index of the second 's' in the string "She sells sea shells on the sea-shore"? |
A. | <pre><code class="csharp">String str = "She sells sea shells on the sea-shore"; int i; i = str.SecondIndexOf("s");</code></pre> |
B. | <pre><code class="csharp">String str = "She sells sea shells on the sea-shore"; int i, j; i = str.FirstIndexOf("s"); j = str.IndexOf("s", i + 1);</code></pre> |
C. | <pre><code class="csharp">String str = "She sells sea shells on the sea-shore"; int i, j; i = str.IndexOf("s"); j = str.IndexOf("s", i + 1);</code></pre> |
D. | <pre><code class="csharp">String str = "She sells sea shells on the sea-shore"; int i, j; i = str.LastIndexOf("s"); j = str.IndexOf("s", i - 1);</code></pre> |
E. | <pre><code class="csharp">String str = "She sells sea shells on the sea-shore"; int i, j; i = str.IndexOf("S"); j = str.IndexOf("s", i);</code></pre> |
Answer» D. <pre><code class="csharp">String str = "She sells sea shells on the sea-shore"; int i, j; i = str.LastIndexOf("s"); j = str.IndexOf("s", i - 1);</code></pre> | |
103. |
Which of the following statements are correct about an enum used in C#.NET? An enum can be declared inside a class. An enum can take Single, Double or Decimal values. An enum can be declared outside a class. An enum can be declared inside/outside a namespace. An object can be assigned to an enum variable. |
A. | 1, 3, 4 |
B. | 2, 5 |
C. | 3, 4 |
D. | 2, 4, 5 |
Answer» B. 2, 5 | |
104. |
Which of the following is the correct output for the C#.NET code snippet given below? enum color { red, green, blue } color c = color.red; Type t; t = c.GetType(); string[ ]str; str = Enum.GetNames(t); Console.WriteLine(str[ 0 ]); |
A. | red |
B. | 0 |
C. | 1 |
D. | -1 |
E. | color.red |
Answer» B. 0 | |
105. |
An enum can be declared inside a class, struct, namespace or interface. |
A. | True |
B. | False |
Answer» B. False | |
106. |
Which of the following statements are correct about datatypes in C#.NET? Every datatype is either a value type or a reference type. Value types are always created on the heap. Reference types are always created on the stack. Mapping of every value type to a type in Common Type System facilitates Interoperability in C#.NET. Every reference type gets mapped to a type in Common Type System. |
A. | 1, 3 |
B. | 2, 5 |
C. | 1, 4 |
D. | 3, 4 |
Answer» D. 3, 4 | |
107. |
Which of the following statements are correct about data types? Each value type has an implicit default constructor that initializes the default value of that type. It is possible for a value type to contain the null value. All value types are derived implicitly from System.ValueType class. It is not essential that local variables in C# must be initialized before being used. Variables of reference types referred to as objects and store references to the actual data. |
A. | 1, 3, 5 |
B. | 2, 4 |
C. | 3, 5 |
D. | 2, 3, 4 |
Answer» B. 2, 4 | |
108. |
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 | |
109. |
Which of the following statements are correct about the following code snippet? int a = 10; int b = 20; bool c; c = !(a > b); There is no error in the code snippet. An error will be reported since ! can work only with an int. A value 1 will be assigned to c. A value True will be assigned to c. A value False will be assigned to c. |
A. | 1, 3 |
B. | 2, 4 |
C. | 4, 5 |
D. | 1, 4 |
E. | None of these |
Answer» E. None of these | |
110. |
Which of the following is the correct way to access all elements of the Queue collection created using the C#.NET code snippet given below? Queue q = new Queue(); q.Enqueue("Sachin"); q.Enqueue('A'); q.Enqueue(false); q.Enqueue(38); q.Enqueue(5.4); |
A. | <pre><code class="csharp">IEnumerator e; e = q.GetEnumerator(); while (e.MoveNext()) Console.WriteLine(e.Current);</code></pre> |
B. | <pre><code class="csharp">IEnumerable e; e = q.GetEnumerator(); while (e.MoveNext()) Console.WriteLine(e.Current);</code></pre> |
C. | <pre><code class="csharp">IEnumerator e; e = q.GetEnumerable(); while (e.MoveNext()) Console.WriteLine(e.Current);</code></pre> |
D. | <pre><code class="csharp">IEnumerator e; e = Queue.GetEnumerator(); while (e.MoveNext()) Console.WriteLine(e.Current);</code></pre> |
Answer» B. <pre><code class="csharp">IEnumerable e; e = q.GetEnumerator(); while (e.MoveNext()) Console.WriteLine(e.Current);</code></pre> | |
111. |
Suppose a Generic class called SortObjects is to be made capable of sorting objects of any type (Integer, Single, Byte etc.). Which of the following programming constructs should be used to implement the comparision function? |
A. | Namespace |
B. | Interface |
C. | Encapsulation |
D. | Delegate |
E. | Attribute |
Answer» E. Attribute | |
112. |
Which of the following is NOT an interface declared in System.Collections namespace? |
A. | <i class="csharp-code">IComparer</i> |
B. | <i class="csharp-code">IEnumerable</i> |
C. | <i class="csharp-code">IEnumerator</i> |
D. | <i class="csharp-code">IDictionaryComparer</i> |
E. | <i class="csharp-code">IDictionaryEnumerator</i> |
Answer» E. <i class="csharp-code">IDictionaryEnumerator</i> | |
113. |
Which of the following statements are correct about the Collection Classes available in Framework Class Library? |
A. | Elements of a collection cannot be transmitted over a network. |
B. | Elements stored in a collection can be retrieved but cannot be modified. |
C. | It is not easy to adopt the existing Collection classes for newtype of objects. |
D. | Elements stored in a collection can be modified only if allelements are of similar types. |
E. | They use efficient algorithms to manage the collection, thereby improving the performance of the program. |
Answer» F. | |
114. |
Suppose value of the Capacity property of ArrayList Collection is set to 4. What will be the capacity of the Collection on adding fifth element to it? |
A. | 4 |
B. | 8 |
C. | 16 |
D. | 32 |
Answer» C. 16 | |
115. |
Which of the following is an ordered collection class? Map Stack Queue BitArray HashTable |
A. | 1 only |
B. | 2 and 3 only |
C. | 4 and 5 only |
D. | All of the above |
E. | None of the above |
Answer» C. 4 and 5 only | |
116. |
Which of the following statements are correct? The conditional operator (?:) returns one of two values depending on the value of a Boolean expression. The as operator in C#.NET is used to perform conversions between compatible reference types. The &* operator is also used to declare pointer types and to dereference pointers. The -> operator combines pointer dereferencing and member access. In addition to being used to specify the order of operations in an expression, brackets [ ] are used to specify casts or type conversions. |
A. | 1, 2, 4 |
B. | 2, 3, 5 |
C. | 3, 4, 5 |
D. | 1, 3, 5 |
E. | None of these |
Answer» B. 2, 3, 5 | |
117. |
Which of the following statements are correct? We can assign values of any type to variables of type object. When a variable of a value type is converted to object, it is said to be unboxed. When a variable of type object is converted to a value type, it is said to be boxed. Boolean variable cannot have a value of null. When a value type is boxed, an entirely new object must be allocated and constructed. |
A. | 2, 5 |
B. | 1, 5 |
C. | 3, 4 |
D. | 2, 3 |
Answer» C. 3, 4 | |
118. |
Which of the following is the correct size of a Decimal datatype? |
A. | 8 Bytes |
B. | 4 Bytes |
C. | 10 Bytes |
D. | 16 Bytes |
E. | None of the above. |
Answer» E. None of the above. | |
119. |
What is the size of a Decimal? |
A. | 4 byte |
B. | 8 byte |
C. | 16 byte |
D. | 32 byte |
Answer» D. 32 byte | |
120. |
Which of the following is the correct default value of a Boolean type? |
A. | 0 |
B. | 1 |
C. | True |
D. | False |
E. | -1 |
Answer» E. -1 | |
121. |
Which of the following statements are correct about the String Class in C#.NET? Two strings can be concatenated by using an expression of the form s3 = s1 + s2; String is a primitive in C#.NET. A string built using StringBuilder Class is Mutable. A string built using String Class is Immutable. 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 | |
122. |
Which of the following snippets are the correct way to convert a Single into a String? Single f = 9.8f; String s; s = (String) (f); Single f = 9.8f; String s; s = Convert.ToString(f); Single f = 9.8f; String s; s = f.ToString(); Single f = 9.8f; String s; s = Clnt(f); 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 | |
123. |
What will be the output of the C#.NET code snippet given below? namespace IndiabixConsoleApplication { 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. | Hello World? |
E. | System.Int32 |
Answer» F. | |
124. |
Which of the following is correct way to convert a String to an int? String s = "123"; int i; i = (int)s; String s = "123"; int i; i = int.Parse(s); String s = "123"; int i; i = Int32.Parse(s); String s = "123"; int i; i = Convert.ToInt32(s); String s = "123"; int i; i = CInt(s); |
A. | 1, 3, 5 |
B. | 2, 4 |
C. | 3, 5 |
D. | 2, 3, 4 |
Answer» E. | |
125. |
How many enumerators will exist if four threads are simultaneously working on an ArrayList object? |
A. | 1 |
B. | 3 |
C. | 2 |
D. | 4 |
E. | Depends upon the Project Setting made in Visual Studio.NET. |
Answer» E. Depends upon the Project Setting made in Visual Studio.NET. | |
126. |
In which of the following collections is the Input/Output index-based? Stack Queue BitArray ArrayList HashTable |
A. | 1 and 2 only |
B. | 3 and 4 only |
C. | 5 only |
D. | 1, 2 and 5 only |
E. | All of the above |
Answer» C. 5 only | |
127. |
Which of the following is NOT an Integer? |
A. | <i class="csharp-code">Char</i> |
B. | <i class="csharp-code">Byte</i> |
C. | <i class="csharp-code">Integer</i> |
D. | <i class="csharp-code">Short</i> |
E. | <i class="csharp-code">Long</i> |
Answer» B. <i class="csharp-code">Byte</i> | |
128. |
The string built using the String class are immutable (unchangeable), whereas, the ones built- using the StringBuilder class are mutable. |
A. | True |
B. | False |
Answer» B. False | |
129. |
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. | Nagpur |
E. | NagpurMumbai |
Answer» F. | |
130. |
Which of the following utilities can be used to compile managed assemblies into processor-specific native code? |
A. | gacutil |
B. | ngen |
C. | sn |
D. | dumpbin |
E. | ildasm |
Answer» C. sn | |
131. |
Which of the following are value types? Integer Array Single String Long |
A. | 1, 2, 5 |
B. | 1, 3, 5 |
C. | 2, 4 |
D. | 3, 5 |
Answer» C. 2, 4 | |
132. |
Which of the following are the correct way to initialise the variables i and j to a value 10 each? int i = 10; int j = 10; int i, j; i = 10 : j = 10; int i = 10, j = 10; int i, j = 10; int i = j = 10; |
A. | 2, 4 |
B. | 1, 3 |
C. | 3, 5 |
D. | 4, 5 |
Answer» C. 3, 5 | |
133. |
What is the output of the C#.NET code snippet given below? namespace IndiabixConsoleApplication { 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 |
E. | 2 |
Answer» C. 0 | |
134. |
Which of the following statements is correct about Managed Code? |
A. | Managed code is the code that is compiled by the JIT compilers. |
B. | Managed code is the code where resources are Garbage Collected. |
C. | Managed code is the code that runs on top of Windows. |
D. | Managed code is the code that is written to target the services of the CLR. |
E. | Managed code is the code that can run on top of Linux. |
Answer» E. Managed code is the code that can run on top of Linux. | |
135. |
Which of the following is the root of the .NET type hierarchy? |
A. | <i class="csharp-code">System.Object</i> |
B. | <i class="csharp-code">System.Type</i> |
C. | <i class="csharp-code">System.Base</i> |
D. | <i class="csharp-code">System.Parent</i> |
E. | <i class="csharp-code">System.Root</i> |
Answer» B. <i class="csharp-code">System.Type</i> | |
136. |
Which of the following code snippets are the correct way to determine whether a is Odd or Even? int a; String res; if (a % 2 == 0) res = "Even"; else res = "Odd"; int a; String res; if (a Mod 2 == 0) res = "Even"; else res = "Odd"; int a; Console.WriteLine(a Mod 2 == 0 ? "Even": "Odd"); 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 |
E. | None of these |
Answer» C. 2, 3 | |
137. |
Which of the following statements are correct about the C#.NET code snippet given below? if (age > 18 || no < 11) a = 25; The condition no < 11 will get evaluated only if age > 18 evaluates to False. The condition no < 11 will get evaluated if age > 18 evaluates to True. The statement a = 25 will get evaluated if any one one of the two conditions is True. || is known as a short circuiting logical operator. 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 |
E. | None of these |
Answer» D. 2, 3, 5 | |
138. |
What will be the output of the C#.NET code snippet given below? byte b1 = 0xAB; byte b2 = 0x99; byte temp; temp = (byte)~b2; Console.Write(temp + " "); temp = (byte)(b1 << b2); Console.Write (temp + " "); temp = (byte) (b2 >> 2); Console.WriteLine(temp); |
A. | 102 1 38 |
B. | 108 0 32 |
C. | 102 0 38 |
D. | 1 0 1 |
Answer» D. 1 0 1 | |
139. |
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 | |
140. |
Suppose n is a variable of the type Byte and we wish to put OFF its fourth bit (from right) without disturbing any other bits. Which of the following statements will do this correctly? |
A. | <i class="csharp-code">n = n && HF7</i> |
B. | <i class="csharp-code">n = n & 16</i> |
C. | <i class="csharp-code">n = n & 0xF7</i> |
D. | <i class="csharp-code">n = n & HexF7</i> |
E. | <i class="csharp-code">n = n & 8</i> |
Answer» D. <i class="csharp-code">n = n & HexF7</i> | |
141. |
In which of the following should the methods of a class differ if they are to be treated as overloaded methods? Type of arguments Return type of methods Number of arguments Names of methods Order of arguments |
A. | 2, 4 |
B. | 3, 5 |
C. | 1, 3, 5 |
D. | 3, 4, 5 |
Answer» D. 3, 4, 5 | |
142. |
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? if(s1 = s2) if(s1 == s2) int c; c = s1.CompareTo(s2); if( strcmp(s1, s2) ) if (s1 is s2) |
A. | 1, 2 |
B. | 2, 3 |
C. | 4, 5 |
D. | 3, 5 |
Answer» C. 4, 5 | |
143. |
Which of the following statements are correct about delegates? |
A. | Delegates cannot be used to call a static method of a class. |
B. | Delegates cannot be used to call procedures that receive variable number of arguments. |
C. | If signatures of two methods are same they can be called through the same delegate object. |
D. | Delegates cannot be used to call an instance function. Delegates cannot be used to call an instance subroutine. |
Answer» C. If signatures of two methods are same they can be called through the same delegate object. | |
144. |
Which of the following forms of applying an attribute is correct? |
A. | <pre><code class="csharp">< Serializable() > class sample { /* ... */ }</code></pre> |
B. | <pre><code class="csharp">(Serializable()) class sample { /* ... */ }</code></pre> |
C. | <pre><code class="csharp">[ Serializable() ] class sample { /* ... */ }</code></pre> |
D. | <pre><code class="csharp">Serializablef) class sample { /* ... */ }</code></pre> |
E. | None of the above |
Answer» D. <pre><code class="csharp">Serializablef) class sample { /* ... */ }</code></pre> | |
145. |
Once applied which of the following CANNOT inspect the applied attribute? |
A. | CLR |
B. | Linker |
C. | ASP.NET Runtime |
D. | Visual Studio.NET |
E. | Language compilers |
Answer» C. ASP.NET Runtime | |
146. |
Which of the following is the correct output for the C#.NET code snippet given below? enum color: int { red, green, blue = 5, cyan, magenta = 10, yellow } Console.Write( (int) color.green + ", " ); Console.Write( (int) color.yellow ); |
A. | 2, 11 |
B. | 1, 11 |
C. | 2, 6 |
D. | 1, 5 |
E. | None of the above |
Answer» C. 2, 6 | |
147. |
Which of the following is the correct way to implement a read only property Length in a Sample class? |
A. | <pre><code class="csharp">class Sample { int len; public int Length { get { return len; } } }</code></pre> |
B. | <pre><code class="csharp">class Sample { public int Length { get { return Length; } } }</code></pre> |
C. | <pre><code class="csharp">class Sample { int len; public int Length { get { return len; } set { len = value; } } }</code></pre> |
D. | <pre><code class="csharp">class Sample { int len; public int Length { Readonly get { return len; } } }</code></pre> |
Answer» B. <pre><code class="csharp">class Sample { public int Length { get { return Length; } } }</code></pre> | |
148. |
Which of the following unary operators can be overloaded? true false + new is |
A. | 1, 2, 3 |
B. | 3, 4, 5 |
C. | 3 only |
D. | 5 only |
Answer» B. 3, 4, 5 | |
149. |
All code inside finally block is guaranteed to execute irrespective of whether an exception occurs in the protected block or not. |
A. | True |
B. | False |
Answer» B. False | |
150. |
In C#.NET if we do not catch the exception thrown at runtime then which of the following will catch it? |
A. | Compiler |
B. | CLR |
C. | Linker |
D. | Loader |
E. | Operating system |
Answer» C. Linker | |