MCQs > IT & Programming > C# MCQs > Basic C# MCQs

Basic C# MCQ

1. When you copy data from a file on a storage device into ram, you are ____ from the file.

Answer

Correct Answer: Reading

Note: This Question is unanswered, help us to find answer for this one

2. A(n) ____ is client software that displays web page elements and handles links between pages.

Answer

Correct Answer: Browser

Note: This Question is unanswered, help us to find answer for this one

3. What is true about thread multitasking?

Answer

Correct Answer: Thread multitasking allows code to be executed concurrently

Note: This Question is unanswered, help us to find answer for this one

4. When can anonymous types be created?

Answer

Correct Answer: At compile time

Note: This Question is unanswered, help us to find answer for this one

5. Do you need to declare an out variable before you use it?

Answer

Correct Answer: No, you can declare it the parameter list.

Note: This Question is unanswered, help us to find answer for this one

6. How do you indicate that a string might be null?

Answer

Correct Answer: String? myVariable

Note: This Question is unanswered, help us to find answer for this one

7. What is true about virtual methods?

Answer

Correct Answer: Virtual methods always need a default implementation.

Note: This Question is unanswered, help us to find answer for this one

8. Which code snippet correctly declares a variable named userId with a public get and private set?

Answer

Correct Answer: Public int userID { get; private set; }

Note: This Question is unanswered, help us to find answer for this one

9. What is the difference between the break and continue keywords?

Answer

Correct Answer: The break keyword literally breaks out of a control flow statement, while continue ignores the rest of the control statement or iteration and starts the next one.

Note: This Question is unanswered, help us to find answer for this one

10. What is the main difference between a value type and a reference type?

Answer

Correct Answer: A value type stores an actual value, while a reference type is a pointer to a value.

Note: This Question is unanswered, help us to find answer for this one

11. How would you write an enum variable called AppState with values for Offline, Loading, and Ready?

Answer

Correct Answer: Enum AppState {Offline, Loading, Ready}

Note: This Question is unanswered, help us to find answer for this one

12. Which code snippet correctly declares a custom exception named InvalidResponse?

Answer

Correct Answer: Class InvalidResponse: Exception {}

Note: This Question is unanswered, help us to find answer for this one

13. Your application has a value type called username that needs to be able to accept null values, but this is generating compile-time errors. How would you fix this in code?

Answer

Correct Answer: String? username = null;

Note: This Question is unanswered, help us to find answer for this one

14. What is the difference between finally and finalize blocks?

Answer

Correct Answer: The finally block is called after the execution of a try and catch block, while the finalize method is called just before garbage collection.

Note: This Question is unanswered, help us to find answer for this one

15. What are the four keywords associated with exception handling in C#?

Answer

Correct Answer: Try, catch, finally, throw

Note: This Question is unanswered, help us to find answer for this one

16. What is a delegate

Answer

Correct Answer: A type that holds a reference to a method with a particular parameter list and return type

Note: This Question is unanswered, help us to find answer for this one

17. When an object in C# is serialized, what is it converted to?

Answer

Correct Answer: Byte stream

Note: This Question is unanswered, help us to find answer for this one

18. What is the most accurate description of a regular expression?

Answer

Correct Answer: A regular expression is a special text string for describing a search pattern

Note: This Question is unanswered, help us to find answer for this one

19. What is a thread pool?

Answer

Correct Answer: A collection of threads created during initialization that can be reused

Note: This Question is unanswered, help us to find answer for this one

20. What function do namespaces perform?

Answer

Correct Answer: Namespaces separate code into groupings, control access, and void naming collisions.

Note: This Question is unanswered, help us to find answer for this one

21. How are C# classses limited?

Answer

Correct Answer: They do not support multiple inheritance.

Note: This Question is unanswered, help us to find answer for this one

22. What method correctly extends the string class?

Answer

Correct Answer: Public static string IsvalidName(this string i, string value) {}

Note: This Question is unanswered, help us to find answer for this one

23. When will the code inside finally block be executed in a try-catch statement?

Answer

Correct Answer: After the try and catch blocks

Note: This Question is unanswered, help us to find answer for this one

24. What is the correct way to write an event named apiResult based on a delegate named ResultCallback?

Answer

Correct Answer: Public event ResultCallback apiResult;

Note: This Question is unanswered, help us to find answer for this one

25. What is the difference between a static and non-static method?

Answer

Correct Answer: Static methods do not have to instantiate an instance of the class to call the method

Note: This Question is unanswered, help us to find answer for this one

26. How would you write a delegate named ResultCallback with an int parameter named responseCode?

Answer

Correct Answer: Public delegate void ResultCallback(int responseCode);

Note: This Question is unanswered, help us to find answer for this one

27. How would you serialize this class? public class User {}

Answer

Correct Answer: Mark the User class with the SerializableAttribute attribute.

Note: This Question is unanswered, help us to find answer for this one

28. Which characteristic prevents this code from compiling? public int age="28"

Answer

Correct Answer: Type safety

Note: This Question is unanswered, help us to find answer for this one

29. What is the difference between non-static and static classes?

Answer

Correct Answer: Non-static classes need to be initialized before use, while static classes do not

Note: This Question is unanswered, help us to find answer for this one

30. What is the correct syntax for a new generic list of strings named contacts? (similar to Q26)

Answer

Correct Answer: Var contacts = new List();

Note: This Question is unanswered, help us to find answer for this one

31. How would you declare a sealed class named User?

Answer

Correct Answer: Sealed class User {}

Note: This Question is unanswered, help us to find answer for this one

32. When would you use generics in your code?

Answer

Correct Answer: All of these answers

Note: This Question is unanswered, help us to find answer for this one

33. Why would you use a class field in C#

Answer

Correct Answer: To hold information and data contained in the class object

Note: This Question is unanswered, help us to find answer for this one

34. What is most accurate description of a regular expression?

Answer

Correct Answer: A regular expression is a special text string for describing a search patters.

Note: This Question is unanswered, help us to find answer for this one

35. You're dealing with multiple assemblies in your program, but are worried about memory allocation. At what point in the program life cycle are assemblies loaded into memory?

Answer

Correct Answer: Only when required

Note: This Question is unanswered, help us to find answer for this one

36. What character would you use to start a regular expression pattern at a word boundary?

Answer

Correct Answer: \b

Note: This Question is unanswered, help us to find answer for this one

37. Given this enumeration, how would you access the integer-type value of 'AppState.Loading'? enum AppState { OffLine, Loading, Ready }

Answer

Correct Answer: Int currentState = (int)AppState.Loading;

Note: This Question is unanswered, help us to find answer for this one

38. What kind of values can arrays store?

Answer

Correct Answer: Multiple variables, or collections, of the same type

Note: This Question is unanswered, help us to find answer for this one

39. What are C# events?

Answer

Correct Answer: Actions that generate notifications, which are sent to their registered listeners

Note: This Question is unanswered, help us to find answer for this one

40. When an asynchronous method is executed, the code runs but nothing happens other than a compiler warning. What is most likely causing the method to not return anything?

Answer

Correct Answer: The method is missing an await keyword in its body.

Note: This Question is unanswered, help us to find answer for this one

41. What is the difference between throw exceptions and throw clauses?

Answer

Correct Answer: Throw exceptions overwrite the stack trace, while throw clauses retain the stack information.

Note: This Question is unanswered, help us to find answer for this one

42. What is the correct syntax for a new generic list of strings named contacts?

Answer

Correct Answer: Var contacts = new List();

Note: This Question is unanswered, help us to find answer for this one

43. What it the main purpose of LINQ?

Answer

Correct Answer: To query and transform data

Note: This Question is unanswered, help us to find answer for this one

44. What does operator overloading allow you to do?

Answer

Correct Answer: Define custom functionality for common operators like addition and equality

Note: This Question is unanswered, help us to find answer for this one

45. Which choice represents a class that inherits behavior from a base class?

Answer

Correct Answer: A derived class

Note: This Question is unanswered, help us to find answer for this one

46. When using a thread pool what happens to a given thread after it finishes its task?

Answer

Correct Answer: The thread returns to the pool for reuse.

Note: This Question is unanswered, help us to find answer for this one

47. What is an abstract class?

Answer

Correct Answer: A class that can be used only as base class

Note: This Question is unanswered, help us to find answer for this one

48. How would you write code for an integer property called Age with a getter and setter?

Answer

Correct Answer: Public int Age { get; set; }

Note: This Question is unanswered, help us to find answer for this one

49. How do you make a method in an abstract class overridable?

Answer

Correct Answer: Make it virtual

Note: This Question is unanswered, help us to find answer for this one

50. What is the correct formatting for single line and multiline comments?

Answer

Correct Answer: // Single Line /_ Multiline _/

Note: This Question is unanswered, help us to find answer for this one

51. Lambda expressions are often used in tandem with which of the following?

Answer

Correct Answer: LINQ

Note: This Question is unanswered, help us to find answer for this one

52. What will be returned when this method is executed? public void userInput(string charParamters) { }

Answer

Correct Answer: Nothing

Note: This Question is unanswered, help us to find answer for this one

53. Which code snippet declares an anonymous type named userData?

Answer

Correct Answer: var userData = new { name = "John", age = 32 };

Note: This Question is unanswered, help us to find answer for this one

54. What is an object in C#?

Answer

Correct Answer: An instance of a class or struct that includes fields, properties, and/or methods

Note: This Question is unanswered, help us to find answer for this one

55. How does the async keyword work?

Answer

Correct Answer: It allows the await keyword to be used in a method

Note: This Question is unanswered, help us to find answer for this one

56. Which choice best describes a deadlock situation?

Answer

Correct Answer: When simultaneous instructions are waiting on each other to finish before executing

Note: This Question is unanswered, help us to find answer for this one

57. What is the difference between a.Equals(b) and a == b?

Answer

Correct Answer: The .Equals method compares contents while == compares references reference identity.

Note: This Question is unanswered, help us to find answer for this one

58. When would you use a Dictionary rather that an Array type in your application?

Answer

Correct Answer: When you need to store key-value pairs rather than single values

Note: This Question is unanswered, help us to find answer for this one

59. What is the difference between an anonymous type and a regular data type?

Answer

Correct Answer: Anonymous types don't have type names

Note: This Question is unanswered, help us to find answer for this one

60. How could you retrieve information about a class, as well as create an instance at runtime?

Answer

Correct Answer: Reflection

Note: This Question is unanswered, help us to find answer for this one

61. What is the difference between the ref and out keywords?

Answer

Correct Answer: Variables passed to out can be passed to a function without being initialized, while ref specifies that the value is a reference value that can be changed inside the calling method.

Note: This Question is unanswered, help us to find answer for this one

62. Which choice best defines C#'s asynchronous programming model?

Answer

Correct Answer: Task-based

Note: This Question is unanswered, help us to find answer for this one

63. Which statement is true of delegates?

Answer

Correct Answer: They can be chained together.

Note: This Question is unanswered, help us to find answer for this one

64. In which of these situations are interfaces better than abstract classes?

Answer

Correct Answer: When you need a list of capabilities and data that are classes-agnostic, use an interface. When you need a certain object type to share characteristics, use an abstract class.

Note: This Question is unanswered, help us to find answer for this one

65. A(n) ____ is associated with every running program.

Answer

Correct Answer: Task

Note: This Question is unanswered, help us to find answer for this one

66. A(n) ____ constructor will never take any parameters.

Answer

Correct Answer: Default

Note: This Question is unanswered, help us to find answer for this one

67. An array is a(n) ____ of values in computer memory.

Answer

Correct Answer: List

Note: This Question is unanswered, help us to find answer for this one

68. The ____ class provides the definitions for gui objects.

Answer

Correct Answer: Control

Note: This Question is unanswered, help us to find answer for this one

69. A(n) ____ is another name for a subscript.

Answer

Correct Answer: Index

Note: This Question is unanswered, help us to find answer for this one

70. A variable that holds the accumulated result of a sum is called a(n) __________.

Answer

Correct Answer: Accumulator

Note: This Question is unanswered, help us to find answer for this one

71. A method’s name and a list of argument types together are its ____.

Answer

Correct Answer: Signature

Note: This Question is unanswered, help us to find answer for this one

72. The ____ class access modifier means that access to the class is not limited.

Answer

Correct Answer: Internal

Note: This Question is unanswered, help us to find answer for this one

73. A string variable can be declared as an array with elements that are of __________ type.

Answer

Correct Answer: Character

Note: This Question is unanswered, help us to find answer for this one

74. The starting point of a c# program is the _____ method.

Answer

Correct Answer: Main

Note: This Question is unanswered, help us to find answer for this one

75. The ____ control allows you to retrieve date information.

Answer

Correct Answer: MonthCalendar

Note: This Question is unanswered, help us to find answer for this one

76. you can use the ____ method to accept user input from the keyboard.

Answer

Correct Answer: ReadLine()

Note: This Question is unanswered, help us to find answer for this one

77. Predefined types such as int, double, and char are ____ types.

Answer

Correct Answer: Value

Note: This Question is unanswered, help us to find answer for this one

78. Object attributes are often called ____ to help distinguish them from other variables you might use

Answer

Correct Answer: Fields

Note: This Question is unanswered, help us to find answer for this one

79. In c#, parameters can be mandatory or ____.

Answer

Correct Answer: Optional

Note: This Question is unanswered, help us to find answer for this one

80. If you do not provide an access specifier for a class field, its access is ____ by default.

Answer

Correct Answer: Private

Note: This Question is unanswered, help us to find answer for this one

81. An example of a floating point data type is ____.

Answer

Correct Answer: Double

Note: This Question is unanswered, help us to find answer for this one

82. A generic class is defined ____ on the class definition line.

Answer

Correct Answer: By inserting an identifier between left and right parentheses

Note: This Question is unanswered, help us to find answer for this one

83. Which of the following components of the .Net framework provide an extensible set of classes that can be used by any .Net compliant programming language?

Answer

Correct Answer: .Net class libraries

Note: This Question is unanswered, help us to find answer for this one

84.

Consider the following C# code. What would be the value of d?

int? a = 10;
int? b = 11;
int? c = 12;
a = null;
int? d = a ?? b ?? c;

Answer

Correct Answer:

11


Note: This Question is unanswered, help us to find answer for this one

85.

What is the output of the following code?



static void Main(string[] args)

    int a = 5;
    if (Convert.ToBoolean((.002f) -(0.1f)))
        Console.WriteLine("Hello");
    else if (a == 5)
        Console.WriteLine("World");
    else
        Console.WriteLine("Bye");
    Console.ReadLine();
}

Answer

Correct Answer: Hello


Note: This Question is unanswered, help us to find answer for this one

86. At what times can a readonly field of a class be initialized? (Choose all that apply)

Answer

Correct Answer: At the time of field's declaration
At the time of instantiating the class, in any constructor of the class

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

87. Which of the following benefits do we get on running managed code under CLR? 1. Type safety of the code running under CLR is assured. 2. It is ensured that an application would not access the memory that it is not authorized to access. 3. It launches separate process for every application running under it. 4. The resources are Garbage collected.

Answer

Correct Answer: All of the above

Note: This Question is unanswered, help us to find answer for this one

88. What is the default type of a number without a decimal in C#?

Answer

Correct Answer: Int

Note: This Question is unanswered, help us to find answer for this one

89. Which of the following statements is false about virtual and abstract methods?

Answer

Correct Answer: A virtual method is permitted in a sealed class

Note: This Question is unanswered, help us to find answer for this one

90. Which of the following are not ordered collection classes? (choose all that apply)

Answer

Correct Answer: Map
BitArray
HashTable

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

91. Disadvantages of Explicit Conversion are ? (Choose all that apply)

Answer

Correct Answer: Can result in loss of data.
Is potentially unsafe.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

92. Which statement about a String is correct?

Answer

Correct Answer: A String is created on the heap.

Note: This Question is unanswered, help us to find answer for this one

93. Choose the incorrect statement among the following about the delegate?

Answer

Correct Answer: None of the above

Note: This Question is unanswered, help us to find answer for this one

94. Choose the class from which the namespace ‘System.Type’ is derived:

Answer

Correct Answer: System.Reflection.MemberInfo

Note: This Question is unanswered, help us to find answer for this one

95. Which of the following are jobs not performed by the Garbage Collector? 1. Freeing stack memory. 2. Avoiding memory leakage. 3. Freeing memory occupied by unreferenced objects. 4. Closing unclosed database collections. 5. Closing unclosed files.

Answer

Correct Answer: 1, 4, 5

Note: This Question is unanswered, help us to find answer for this one

96. Choose the method defined by MemberInfo:

Answer

Correct Answer: All of the above

Note: This Question is unanswered, help us to find answer for this one

97. What is the purpose of the Open XML SDK 2.0?

Answer

Correct Answer: To do Microsoft Office-related tasks

Note: This Question is unanswered, help us to find answer for this one

98. Which is the correct way to find out the number of elements currently present in an ArrayListCollection called arr?

Answer

Correct Answer: arr.Count

Note: This Question is unanswered, help us to find answer for this one

99. Choose the namespace in which the interface IEnumerable is declared?

Answer

Correct Answer: System.Collections.Generic

Note: This Question is unanswered, help us to find answer for this one

100.

Which of the following is the correct way to call method Jobs() of the UpWork class given below? class UpWork { public void Jobs(inti, Single j) { Console.Writeline('UpWork'); } }

Answer

Correct Answer: delegate void del(inti, Single j); del d; UpWork u = new UpWork(); d = new del(ref u.Jobs); d(10, 1.1f);


Note: This Question is unanswered, help us to find answer for this one

101. What is true about a sealed class in C#?

Answer

Correct Answer: A sealed class cannot be inherited by any other class and sealed classes are primarily used to prevent derivation

Note: This Question is unanswered, help us to find answer for this one

102.

What would be the output of following code snippet?

Namespace Outer

{

Using System;

Class Math

{

}

}

Namespace Outer.Inner

{

Class Foo

{

Public static double Bar()

{

Return Math.PI;

}

}

Class program

{

Public static void Main()

{

Console.WriteLine(“Value of PI is; “ + Foo.Bar() .ToString());

}

}

}

Answer

Correct Answer: It will give a compile time error.


Note: This Question is unanswered, help us to find answer for this one

103.

Which of the following is the correct way to convert a Byte Array to a Hexadecimal String, and vice versa?

Answer

Correct Answer: static readonly char[] _hexDigits = "0123456789abcdef".ToCharArray(); public static string ToHexString(this byte[] bytes) { char[] digits = new char[bytes.Length * 2]; for (inti = 0; i<bytes.Length; i++) { int d1, d2; d1 = Math.DivRem(bytes[i], 16, out d2); digits[2 * i] = _hexDigits[d1]; digits[2 * i + 1] = _hexDigits[d2]; } return new string(digits); }


Note: This Question is unanswered, help us to find answer for this one

104.

Consider the following code:

class Program {

static void Main(string[] args) {

     float f =

     double d =

     decimal dc = 0;

     PrintDouble(f); // Statement 1

     PrintDouble(d); // Statement 2

     PrintDouble(dc);   // Statement 3

}

static private void PrintDouble(double d) {

     Console.WriteLine(d.ToString());

}

}

Which of the following are true?

Answer

Correct Answer: Statement 3 will generate a compilation error.


Note: This Question is unanswered, help us to find answer for this one

105.

Which of the following predefined attributes in C# ?

 

Answer

Correct Answer: All of the above

Note: This Question is unanswered, help us to find answer for this one

106.

Where should auto implemented properties be initialized to a Default value? 

Answer

Correct Answer: In the constructor

Note: This Question is unanswered, help us to find answer for this one

107.

Select the type argument of an open constructed type. 

Answer

Correct Answer: Gen<>

Note: This Question is unanswered, help us to find answer for this one

108.

Which of the following interfaces are declared in the System.Collections namespace? (Choose all that apply)

Answer

Correct Answer: ICollection
IComparer
IDictionary
IList
IEnumerator
IDictionaryEnumerator

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

109.

Choose the advantages of using generics? 

Answer

Correct Answer: All of the mentioned

Note: This Question is unanswered, help us to find answer for this one

110.

Which statement is correct about an Exception? 

Answer

Correct Answer: It occurs at run-time.

Note: This Question is unanswered, help us to find answer for this one

111.

Which String method is used to compare two strings? 

Answer

Correct Answer: Compare()

Note: This Question is unanswered, help us to find answer for this one

112.

Which of the following is NOT a .NET Exception class? 

Answer

Correct Answer: StackMemoryException

Note: This Question is unanswered, help us to find answer for this one

113.

Verbatim string literal is better used for ? 

Answer

Correct Answer: All of the above

Note: This Question is unanswered, help us to find answer for this one

114.

Which datatype should be used for storing a simple number like 35 to improve execution speed of a program? 

Answer

Correct Answer: sbyte

Note: This Question is unanswered, help us to find answer for this one

115.

Which of the following is not an interface declared in System.Collection namespace? 

Answer

Correct Answer: IDictionaryComparer

Note: This Question is unanswered, help us to find answer for this one

116.

Which operator is used to access member function of a class? 

Answer

Correct Answer: .

Note: This Question is unanswered, help us to find answer for this one

117.

Select the error in the given program : public static void Main() { const int m = 100; int n = 10; const int k = n / 5 * 100 * n ; Console.WriteLine(m * k); Console.ReadLine(); } 

Answer

Correct Answer: Expression assigned to ‘k’ should be constant in nature.

Note: This Question is unanswered, help us to find answer for this one

118.

Assume 2 columns are named Product and Category. How can they be sorted based on first by category and then by product name? 

Answer

Correct Answer: var sortedProds = _db.Products.Orderby(c => c.Category) . ThenBy(n => n.Name)

Note: This Question is unanswered, help us to find answer for this one

119.

The ‘ref’ keyword can be used as: (Check all that apply)

Answer

Correct Answer: Static function/subroutine
Instance function/subroutine

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

120.

In C#.NET, if we do not catch the exception thrown at runtime then which of the following will catch it? 

Answer

Correct Answer: CLR

Note: This Question is unanswered, help us to find answer for this one

121.

Which feature allows you to obtain information about the use and capabilities of types at runtime? 

Answer

Correct Answer: Reflection

Note: This Question is unanswered, help us to find answer for this one

122.

What is the problem with the following function? (The code is supposed to convert a Stream into byte array) public static byte[] ReadFully(Stream input) { using (MemoryStream ms = new MemoryStream()) { input.CopyTo(ms); return ms.ToArray(); } } 

Answer

Correct Answer: It will work only in .NET Framework 4 or above, as the CopyTo function of the memory stream is available only in .NET Framework 4 or later versions.

Note: This Question is unanswered, help us to find answer for this one

123.

How many Bytes are stored by ‘Long’ Datatype in C# .net?

Answer

Correct Answer: a) 8

Note: This Question is unanswered, help us to find answer for this one

124.

Which of the following statements is true about the .Net framework and DCOM?

Answer

Correct Answer: .Net framwork uses DCOM for making transition between managed and unmanaged code.

Note: This Question is unanswered, help us to find answer for this one

125.

Consider an ArrayList collection that implements the IEnumerable interface. Which of the following statements are true?

Answer

Correct Answer: The ArrayList class contains an inner class that implements the IEnumberable interface.
The inner class of ArrayList can access ArrayList class's members.
To access members of ArrayList from the inner class, it is necessary to pass ArrayList class's reference to it.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

126.

Among the given collections which one is I/O index based? (Choose all that apply).

Answer

Correct Answer: a) ArrayList

Note: This Question is unanswered, help us to find answer for this one

127.

Among the given collections which one is I/O index based? (Check all that apply)

Answer

Correct Answer: a) ArrayList
b) BitArray

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

128.

Which of the following constitute the .Net framework?

Answer

Correct Answer: CLR
Framework Class Library

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

129.

Which of the following keywords is used to manually throw an exception handling?

Answer

Correct Answer: throw

Note: This Question is unanswered, help us to find answer for this one

130.

What is Semaphore?

Answer

Correct Answer: a) Grant more than one thread access to a shared resource at the same time.
b) Useful when a collection of resources is being synchronized
c) Make use of a counter to control access to a shared resource

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

131.

A generic type with arguments provided, like KeyValuePair, is called?

Answer

Correct Answer: A constructed type

Note: This Question is unanswered, help us to find answer for this one

132.

Which of the following statements are correct about a HashTable collection? (Choose all that apply)

Answer

Correct Answer: a) It is a keyed collection
d) It implements a IDictionaryEnumerator interface in its inner class

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

133.

Which is the correct way to enumerate an Enum in C#?

Answer

Correct Answer: foreach (Suit suit in Enum.GetValues(typeof(Suit))) { }

Note: This Question is unanswered, help us to find answer for this one

134.

Identifier is a name which can be used to identify a __, __, __?

Answer

Correct Answer: class, variable, function

Note: This Question is unanswered, help us to find answer for this one

135.

The expression of a lock statement must denote a value of a type known to be a?

Answer

Correct Answer: reference-type

Note: This Question is unanswered, help us to find answer for this one

136.

Which statement is correct about the C#.NET code snippet given below? Stack st = new Stack(); st.Push("Csharp"); st.Push(7.3); st.Push(8); st.Push('b'); st.Push(true);

Answer

Correct Answer: c) Perfectly workable code

Note: This Question is unanswered, help us to find answer for this one

137.

What is the difference between const and readonly?

Answer

Correct Answer: A const is a compile-time constant whereas read-only allows a value to be calculated at run-time and set in the constructor or field initializer. So, a 'const' is always constant but 'read-only' is read-only once it is assigned.

Note: This Question is unanswered, help us to find answer for this one

138.

Which of the following properties related to network errors is generated by WebException?

Answer

Correct Answer: Response
Status

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

139.

What is the output if following code executed? static void Main(string[] args){ String obj = "sample"; String obj1 = "program"; String obj2 = obj; Console.WriteLine(obj + " " + obj1); string s = obj + " " + obj1; Console.WriteLine(s.Length); Console.ReadLine(); }

Answer

Correct Answer: Sample program

Note: This Question is unanswered, help us to find answer for this one

140.

Which among the following is the ordered collection class? (Check all that apply)

Answer

Correct Answer: Queue
Stack

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

141.

Which of the following is an ordered collection class? (choose all that apply)

Answer

Correct Answer: Stack
Queue

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

142.

What kind of exception is being thrown if Wait(),Pulse() or PulseAll() iscalled from code that is not within synchronized code?

Answer

Correct Answer: c) SynchronizationLockException

Note: This Question is unanswered, help us to find answer for this one

143.

Structures can have methods, , , _____, operator methods, and events?

Answer

Correct Answer: fields, indexers, properties

Note: This Question is unanswered, help us to find answer for this one

144.

A class consists of two __ with each interface consisting of __ , __ and class had no instance data?

Answer

Correct Answer: interfaces, three, methods

Note: This Question is unanswered, help us to find answer for this one

145.

C# has support for strongly-typed function pointers via the keyword?

Answer

Correct Answer: delegate

Note: This Question is unanswered, help us to find answer for this one

146.

Which of the following keywords must be used to monitor exceptions handling?

Answer

Correct Answer: try

Note: This Question is unanswered, help us to find answer for this one

147.

Choose the namespace in which Expression trees are encapsulated?

Answer

Correct Answer: b) System.Linq.Expressions

Note: This Question is unanswered, help us to find answer for this one

148.

Which of the following is the correct syntax to group query results using LINQ?

Answer

Correct Answer: var query = from student in students group student by student.LastName into newGroup orderby newGroup.Key select newGroup;

Note: This Question is unanswered, help us to find answer for this one

149.

Which of the following types of LINQ?

Answer

Correct Answer: All of the above

Note: This Question is unanswered, help us to find answer for this one

150.

What is the difference between “throw ex” and “throw” in C#?

Answer

Correct Answer: “throw ex” will replace the stack trace of the exception with stack trace info of re throw point and “throw” will preserve the original stack trace info

Note: This Question is unanswered, help us to find answer for this one

151.

Choose the correct statement about System.Type namespace?

Answer

Correct Answer: c) Both of the above

Note: This Question is unanswered, help us to find answer for this one

152.

Recursion is a process of defining a ___ that calls itself repeatedly in C#?

Answer

Correct Answer: Method

Note: This Question is unanswered, help us to find answer for this one

153.

What are the types of children does object element can have in XAML?

Answer

Correct Answer: a) Collection Items
b) A value for the content property
c) The value that can be type-converted to the object element

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

154.

Which of the following right syntax for declaration and initialization of data variable?

Answer

Correct Answer: data type><var_name> = <Value>;

Note: This Question is unanswered, help us to find answer for this one

155.

Which of the following how you can use retrieve a single row with LINQ?

Answer

Correct Answer: Public User GetUser (string userName){ DBNameDataContext myDB = new DBNameDataContext ( ) ; User user = myDB. Users. Single ( u, u.UserName => userName ); Return user; }

Note: This Question is unanswered, help us to find answer for this one

156.

Which of the following statements are correct about delegates?

Answer

Correct Answer: Delegates are reference types.
Delegates are object oriented.
Delegates are type-safe.
Delegates serve the same purpose as function pointers in C and pointers to member function operators in C++.
Delegates are secure.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

157.

Which of the following statements about deleagtes are UNTRUE?

Answer

Correct Answer: Delegates are not type-safe.
Only one method can be bound with one delegate object.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

158.

Consider the following delegate declaration,Which of the following are TRUE? delegate void del(int i);

Answer

Correct Answer: On declaring the delegate, a class called del will get created.
The del class will be derived from the MulticastDelegate class.
The del class will contain a one-argument constructor and an Invoke() method.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

159.

DataContext class acts as a bridge between SQL Server database and the _____ to SQL?

Answer

Correct Answer: LINQ

Note: This Question is unanswered, help us to find answer for this one

160.

Which of the following code samples will read an integer from a byte[]?

Answer

Correct Answer: byte[] bytes = { 0, 0, 0, 25 }; if (BitConverter.IsLittleEndian) Array.Reverse(bytes); int i = BitConverter.ToInt32(bytes, 0); Console.WriteLine("int: {0}", i);

Note: This Question is unanswered, help us to find answer for this one

161.

How can extension methods be added to an existing static class?

Answer

Correct Answer: Extension methods cannot be added to a static class.

Note: This Question is unanswered, help us to find answer for this one

162.

Which of the following is not a keyword in C#?

Answer

Correct Answer: jump

Note: This Question is unanswered, help us to find answer for this one

163.

Which of the following statements is true about the System.Environment.NewLine property?

Answer

Correct Answer: It's a string containing "\r\n" for non-Unix platforms.

Note: This Question is unanswered, help us to find answer for this one

164.

What does the following code block define? Check all that apply. class Gen { T ob; }

Answer

Correct Answer: Generics class declaration
Declaration of variable

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

165.

Which of the following is a correct way to convert a String to an int in C#?

Answer

Correct Answer: String s = "456"; int i; i = int.Parse(s);
String s = "456"; int i; i = Int32.Parse(s);
String s = "456"; int i; i = Convert.ToInt32(s);

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

166.

Which of the following is not a valid .NET Framework Attribute?

Answer

Correct Answer: [ClassMethod]

Note: This Question is unanswered, help us to find answer for this one

167.

What will be the output of the following Main program in a C# console application (Assume required namespaces are included)? private static void TestSwitch(int iValue) { switch (iValue) { case 1: case 2: case 3: case 4: Console.WriteLine("I am less than 5."); break; case 6: case 7: case 8: Console.WriteLine("I am greater than 5."); break; default: Console.WriteLine("I handle rest."); break; } } static void Main(string[] args) { TestSwitch(2); TestSwitch(8); TestSwitch(5); Console.ReadLine(); }

Answer

Correct Answer: I am less than 5. I am greater than 5. I handle rest.

Note: This Question is unanswered, help us to find answer for this one

168.

What is the output of the following code? class Test { static void Main() { string s = @"Joe said\t ""Hello"" to me!"; System.Console.WriteLine(s); } }

Answer

Correct Answer: Joe said\t "Hello" to me!

Note: This Question is unanswered, help us to find answer for this one

169.

What is the following code correct output for the C# code snippet shown below? String s1 = "UpWork Skills Test"; String s2; s2 = s1.Substring(12, 3); Console.WriteLine(s2);

Answer

Correct Answer: s T

Note: This Question is unanswered, help us to find answer for this one

170.

What would be the output of following code snippet? { try { int a, b; b = 0; a = 10 / b; Console.WriteLine("A"); } catch(ArithmeticException e) { Console.WriteLine("B"); } Console.ReadLine(); }

Answer

Correct Answer: b) B

Note: This Question is unanswered, help us to find answer for this one

171.

What will be the output of given code snippet? class Program { static void Main(string[] args) { int[] nums = { 1, -2, 3, 0, -4, 5}; var posNums = from n in nums where n >= 0 select n; foreach (int i in posNums) Console.Write(i + " "); Console.WriteLine(); Console.ReadLine(); } }

Answer

Correct Answer: b) "1 3 0 5"

Note: This Question is unanswered, help us to find answer for this one

172.

Select the result of the given code snippet: class Program { static void Main(string[] args) { int[] nums = { 16, 9, 25}; var posNums = from n in nums where n > 0 select Math.Sqrt(n); Console.Write("The positive values in nums: "); foreach (int i in posNums) Console.Write(i + " "); Console.WriteLine(); Console.ReadLine(); } }

Answer

Correct Answer: b) Code runs successfully and prints required output.

Note: This Question is unanswered, help us to find answer for this one

173.

What is the best way to copy the contents of one stream to another in .NET 4?

Answer

Correct Answer: input.CopyTo(output);

Note: This Question is unanswered, help us to find answer for this one

174.

How is Math.Pow() implemented in the .NET Framework?

Answer

Correct Answer: Math.Pow operates on type doubles. Doubles are 64-bit floating point and have about 15-16 digits of precision in C#. Func<long, int, long> power = null; power = (i, p) => p == 1 ? i : i*power(i, p - 1); Console.WriteLine(power(15, 14));

Note: This Question is unanswered, help us to find answer for this one

175.

Which of the following statements are true about Struct in C#?

Answer

Correct Answer: It logically represents a single value, similar to primitive types.
Struct is Immutable.
It has an instance size smaller than 16 bytes.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

176.

Which of the following statements is incorrect regarding the Dictionary and Hashtable data types in the .NET Framework?

Answer

Correct Answer: Dictionary is faster than Hashtable for value types as Boxing and Unboxing does not take place.

Note: This Question is unanswered, help us to find answer for this one

177.

Which of the following can be used to expose a method as a field to the outside world?

Answer

Correct Answer: property

Note: This Question is unanswered, help us to find answer for this one

178.

Which statement(s) is/are incorrect in relation to the two functions below? 1. public static byte[] ReadFully(Stream input) { byte[] buffer = new byte[16*1024]; using (MemoryStream ms = new MemoryStream()) { int read; while ((read = input.Read(buffer, 0, buffer.Length)) > 0) { ms.Write(buffer, 0, read); } return ms.ToArray(); } } 2. public static byte[] ReadFully(Stream input) { using (MemoryStream ms = new MemoryStream()) { input.CopyTo(ms); return ms.ToArray(); } }

Answer

Correct Answer: #1 can be used in all versions of the .NET Framework, while #2 is only supported in the .NET Framework 4.0 and above.

Note: This Question is unanswered, help us to find answer for this one

179.

Which of the following will return the absolute URL (ie. http://www.something.com/index.aspx) of the requested page (ASP.NET)?

Answer

Correct Answer: HttpContext.Current.Request.Url.AbsoluteUri;

Note: This Question is unanswered, help us to find answer for this one

180.

When should the "as" keyword be used in C# ?

Answer

Correct Answer: A "As" means one of two things: - Know for sure that this object actually is of this other type. Make it so, and if wrong, crash the program. - Know for sure that this object is not of this other type, but that there is a well-known way of converting the value of the current type to the desired type

Note: This Question is unanswered, help us to find answer for this one

181.

What is the fundamental difference between double and decimal variable types?

Answer

Correct Answer: Double is a base 2 fraction, whereas a decimal is a base 10 fraction.

Note: This Question is unanswered, help us to find answer for this one

182.

Which of the following statements are correct?

Answer

Correct Answer: If two objects are equal, then they must return the same value for GetHashCode().

Note: This Question is unanswered, help us to find answer for this one

183.

Which of the following code snippets are the correct way to convert a Single into a String in C#? (Choose all that apply.)

Answer

Correct Answer: Single f = 7.5f; String s; s = Convert.ToString(f);
Single f = 7.5f; String s; s = f.ToString();

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

184.

What is the purpose of the yield keyword in C#?

Answer

Correct Answer: It's used in an iterator block to provide a value to the enumerator object or to signal the end of iteration.

Note: This Question is unanswered, help us to find answer for this one

185.

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(); }

Answer

Correct Answer: c) 0 -10

Note: This Question is unanswered, help us to find answer for this one

186.

If 's1' and 's2' are references to two strings, then which of the following is the correct way to compare the two references?

Answer

Correct Answer: s1.Equals(s2)

Note: This Question is unanswered, help us to find answer for this one

187.

Which of the following statements is correct about the difference between Static readonly and const?

Answer

Correct Answer: Read only static are evaluated when code execution hits class reference (i.e.: new instance is created or static method is executed), and must have evaluated value by the time static constructor is done. Const is static by default and must have compilation-time value.

Note: This Question is unanswered, help us to find answer for this one

188.

Which of the following is the object oriented way to handle run time errors? (Choose all that apply)

Answer

Correct Answer: d) Exceptions

Note: This Question is unanswered, help us to find answer for this one

189.

How you can display different data at run time and design time?

Answer

Correct Answer: c) All of the above

Note: This Question is unanswered, help us to find answer for this one

190.

Which of the following stream class method you can use for the close connection?

Answer

Correct Answer: void close()

Note: This Question is unanswered, help us to find answer for this one

191.

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(); }

Answer

Correct Answer: b) 8

Note: This Question is unanswered, help us to find answer for this one

192.

Choose the incorrect statement about delegates?

Answer

Correct Answer: a) delegates are not type safe
b) delegates cannot be used to implement callback notification

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

193.

Which of the following best describes the correct usage of exception handling over conventional error handling approaches? a) Errors can be ignored but exceptions cannot be ignored. b) Exception handling allows separation of the program’s logic from the error handling logic, making software more reliable and maintainable. c) try – catch – finally structure allows guaranteed clean up in event of errors under all circumstances.

Answer

Correct Answer: a, b and c

Note: This Question is unanswered, help us to find answer for this one

194.

Strings built using the String class are immutable, whereas those built using the StringBuilder class are mutable?

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

195.

Which of the following C# code snippets correctly copies the contents of one string into another?

Answer

Correct Answer: String s1 = "UpWork"; String s2; s2 = String.Copy(s1);

Note: This Question is unanswered, help us to find answer for this one

196.

Which of the following are true? 1) Int32.Parse() can only convert strings. 2) Convert.ToInt32() can take any class that implements IConvertible , and returns 0 when the argument is null.

Answer

Correct Answer: b) Both 1,2

Note: This Question is unanswered, help us to find answer for this one

197.

To implement delegates, the necessary condition is?

Answer

Correct Answer: a) class declaration

Note: This Question is unanswered, help us to find answer for this one

198.

In C#, an interface cannot contain which signature?

Answer

Correct Answer: Constructors

Note: This Question is unanswered, help us to find answer for this one

199.

What does the given code snippet specify? public Thread(ThreadStart start) = = = = = a) Initialization of a new instance of the Thread class. b) Declaration of a thread constructor.

Answer

Correct Answer: a and b.

Note: This Question is unanswered, help us to find answer for this one

200.

Which statement(s) is/are correct?

Answer

Correct Answer: When we use Debug class for tracing, it will work in builds which have the debug symbol defined.
When we use Trace class for tracing, it will work in builds which have the Trace symbol defined.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

201.

Which construct is used to do a left outer join in LINQ?

Answer

Correct Answer: DefaultIfEmpty method

Note: This Question is unanswered, help us to find answer for this one

202.

Correct way to define a value 6.28 in a variable ‘a’ where value cannot be modified ? (Choose all that apply)

Answer

Correct Answer: c) const float a = 6.28F;

Note: This Question is unanswered, help us to find answer for this one

203.

How can we use COM components in .Net?

Answer

Correct Answer: e) All of the above

Note: This Question is unanswered, help us to find answer for this one

204.

What is OCP?

Answer

Correct Answer: OCP,means that a class should be open for extension, but closed for modification
OCP,means consumers of your class should be able to customize its usage

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

205.

Which of the following keyword you can used for correct implementation of an interface in C#.NET?

Answer

Correct Answer: Interface

Note: This Question is unanswered, help us to find answer for this one

206.

Number of threads that exists for each of the processes that occurs in the program?

Answer

Correct Answer: atmost 1
only 1

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

207.

Which of the following exceptions cannot be thrown by the Delete() method of the FileInfo class? 

Answer

Correct Answer: InvalidOperationException

Note: This Question is unanswered, help us to find answer for this one

208.

Which statement below is correct? 

Answer

Correct Answer: ( opens a group.

Note: This Question is unanswered, help us to find answer for this one

209.

Suppose a HashTable named "upwork" maintains a collection of project areas and the name of the best freelancer in each area. Which of the following is the correct way to find out whether the project area "C# programming" is present in the collection or not? 

Answer

Correct Answer: upwork.ContainsKey("C# programming");

Note: This Question is unanswered, help us to find answer for this one

210.
Which of the following is not true about interfaces in C#?
 

 

Answer

Correct Answer: An interface can be instantiated as a reference type

Note: This Question is unanswered, help us to find answer for this one

211.
Which of the following are correct in relation to the above C#.Net code? Stack st = new Stack(); st.Push("UpWork"); st.Push(9.2); st.Push(6); st.Push('i'); st.Push(false);

Answer

Correct Answer: The same Stack collection cannot be used to store dissimilar elements like "UpWork", 9.2, and 6.

Note: This Question is unanswered, help us to find answer for this one

212.
Consider the following C# code, What output will be printed on the console? enum Color: int { Blue, Red, Green, Yellow, Orange } int color = (int)Color.Green; Console.WriteLine("{0} and {1}", color, Color.Yellow);

 

Answer

Correct Answer: 2 and Yellow

Note: This Question is unanswered, help us to find answer for this one

213.
What will be the output of the given code snippet below? static void Main(string[] args) { int i = 15 ; for( ; ; ) { Console.Write(i + " "); if (i >= -10) i -= 3; else break; } }

Answer

Correct Answer: 15 12 9 6 3 0 -3 -6 -9 -12

Note: This Question is unanswered, help us to find answer for this one

214.
What is the output when following statement is executed? static void Main(string[] args){ int i = 1, j; do { for (j = 1; ; j++) { if (i == j) continue; Console.WriteLine(i + " " + j); } i++; } while (i < 3); Console.ReadLine(); }
 

 

Answer

Correct Answer: 11 , 12 , 21,13

Note: This Question is unanswered, help us to find answer for this one

215.
What is the output when following code is executed? using System; using StringBuilder; namespace Text { class Program { public static void Main(string[] args) { StringBuilder sb = new StringBuilder("hello world in c#"); sb.Insert(4, "example"); Console.WriteLine(sb); Console.ReadLine(); } } }

 

Answer

Correct Answer: Compile time error

Note: This Question is unanswered, help us to find answer for this one

216.
In Constructor overloading, n number of __ can be created for the same class?
 

 

Answer

Correct Answer: Constructors

Note: This Question is unanswered, help us to find answer for this one

217.
Consider the following code output? static void Main(string[] args){ int i, j = 1, k; for (i = 0; i < 3; i++) { k = j++ - ++j; Console.Write(k + " "); } }

 

Answer

Correct Answer: Infinity

Note: This Question is unanswered, help us to find answer for this one

218.

Which of the following is the correct way to call the function Jobs(int i) of the UpWork class given below? class UpWork { public int Jobs(int i) { Console.Writeline("UpWork!"); return 0; } }

Answer

Correct Answer: delegate int del(int i); del d; UpWork u = new UpWork(); d = new del(ref u.Jobs); d(10);

Note: This Question is unanswered, help us to find answer for this one

219.

Which of the following statements is correct about implementing interfaces explicitly? interface I1 { void example(); }

Answer

Correct Answer: class C : I1 { void example(){} }

Note: This Question is unanswered, help us to find answer for this one

220.

What will be the output of the following Main program in a C# console application (Assume required namespaces are included): static void Main(string[] args) { Guid g = new Guid("iamnotguid"); Console.WriteLine(g); Console.ReadLine(); }

Answer

Correct Answer: It will throw an error at runtime.

Note: This Question is unanswered, help us to find answer for this one

221.

What will be the output of the following Main program in a C# console application (Assume required namespaces are included): static void Main(string[] args) { string s = null + true; Console.WriteLine(s); Console.ReadLine(); }

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

222.

Which of the following code snippets returns the type of T, based on the code below? List< T > myList = new List< T >;

Answer

Correct Answer: Type type = typeof(T);

Note: This Question is unanswered, help us to find answer for this one

223.

Which of the following statements are true about the following C#.Net code? String s1, s2; s1 = "UpWork"; s2 = "UpWork";

Answer

Correct Answer: Only one variable will be created.
's1' and 's2' both will refer to the same variable.
's1' and 's2' are references to the same variable.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

224.

Which of the following is the correct way to calculate "Age" from date of birth? Example : DateTime bday= DateTime((1990, 10, 3));

Answer

Correct Answer: DateTime today = DateTime.Today; int age = today.Year - bday.Year;

Note: This Question is unanswered, help us to find answer for this one

225.

Which of the following are ways of ensuring that a user enters an integer value in a WinForms application?

Answer

Correct Answer: All of these.

Note: This Question is unanswered, help us to find answer for this one

226.

How can you code to display “This is XAML” in XAML?

Answer

Correct Answer: c) Page xmlns= "" ""> <TextBlock> This is XAML </TextBlock> </Page>

Note: This Question is unanswered, help us to find answer for this one

227.

Four threads are working simultanmeously on an ArrayList object. How many enumerators will exit in this case?

 

Answer

Correct Answer: 4

Note: This Question is unanswered, help us to find answer for this one

228.

Which of the following statements is false in relation to following method? static byte[] GetBytes(string str) { byte[] bytes = new byte[str.Length * sizeof(char)]; System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length); return bytes; }

Answer

Correct Answer: None of these.

Note: This Question is unanswered, help us to find answer for this one

229.

Which of the following is the correct output for the C# code snippet? String s1 = "UpWork"; String s2; s2 = s1.Insert(4, "Project"); Console.WriteLine(s2);

Answer

Correct Answer: UpWorProjectk

Note: This Question is unanswered, help us to find answer for this one

230.

Which of the following is a valid C# statement?

Answer

Correct Answer: int counter=0; checked { counter++; }

Note: This Question is unanswered, help us to find answer for this one

231.

What will happen if the value of nNum is 2 and the following code is compiled and executed? switch(nNum) { case 1: Console.WriteLine("nNum = 1"); break; case 2: Console.WriteLine("nNum = 2"); default: Console.WriteLine("nNum is not 1 nor 2"); break; }

Answer

Correct Answer: Compiler error

Note: This Question is unanswered, help us to find answer for this one

232.

Consider the following declaration in C#, Which statement is true about this declaration? int[][] array;

Answer

Correct Answer: It declares a a single-dimensional array of single-dimensional arrays of type int

Note: This Question is unanswered, help us to find answer for this one

233.

What is multithreaded programming?

Answer

Correct Answer: b) It’s a process in which two or more parts of same process run simultaneously

Note: This Question is unanswered, help us to find answer for this one

234.

Which of the following is not a relational operator in C#?

Answer

Correct Answer: <<

Note: This Question is unanswered, help us to find answer for this one

235.

Select the type of multitasking methods that exist?

Answer

Correct Answer: d) Both a & b

Note: This Question is unanswered, help us to find answer for this one

236.

What does the following declaration specify? MethodInfo[] GetMethods()

Answer

Correct Answer: c) Both a & b

Note: This Question is unanswered, help us to find answer for this one

237.

Choose the correct statement about process-based multitasking?

Answer

Correct Answer: d) Both a & b

Note: This Question is unanswered, help us to find answer for this one

238.

Choose the correct statements about the LINQ?

Answer

Correct Answer: The main concept behind the linq is query
linq makes use of foreach loop to execute the query

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

239.

What are the general kinds of XAML elements?

Answer

Correct Answer: All of the above

Note: This Question is unanswered, help us to find answer for this one

240.

Which of the following is the best way of creating a generic method constraining T to an Enum?

Answer

Correct Answer: public static class EnumUtils { public static T ParseEnum<T>(string value, T defaultValue) where T : struct, IConvertible { if (!typeof(T).IsEnum) throw new ArgumentException("T must be an enumerated type"); if (string.IsNullOrEmpty(value)) return defaultValue; foreach (T item in Enum.GetValues(typeof(T))) { if (item.ToString().ToLower().Equals(value.Trim().ToLower())) return item; } return defaultValue; } }

Note: This Question is unanswered, help us to find answer for this one

241.

Which of the following statements is correct about the ref and out keywords?

Answer

Correct Answer: ref tells the compiler that the object is initialized before entering the function, while out tells the compiler that the object will be initialized inside the function.

Note: This Question is unanswered, help us to find answer for this one

242.

Which of the following statements are false regarding the 3 timer classes provided by the .NET framework? a) System.Windows.Forms.Timer b) System.Timers.Timer c) System.Threading.Timer

Answer

Correct Answer: The event handler of all of the three Timers call the timer event handler on a worker thread obtained from the Common Language Runtime (CLR) thread pool.

Note: This Question is unanswered, help us to find answer for this one

243.

How can a function be defined in a derived class having the same name as a non-virtual function in the base class?

Answer

Correct Answer: By using the override keyword

Note: This Question is unanswered, help us to find answer for this one

244.

Consider the following statements and pick the most appropriate option: Statement 1: Value type variables store their data on the heap. Statement 2: Reference type variables store their data on the stack.

Answer

Correct Answer: Both Statements 1 and 2 are false.

Note: This Question is unanswered, help us to find answer for this one

245.

What is the purpose of ?? (Two question mark) in C#? Example : Class object ??= new Class();

Answer

Correct Answer: It is the null coalescing operator, similar to the ternary (immediate-if) operator.

Note: This Question is unanswered, help us to find answer for this one

246.

What does the following function signature denote? public static intCharLength(this string inputStr)

Answer

Correct Answer: CharLength is an Extension method which can be used with string variables.

Note: This Question is unanswered, help us to find answer for this one

247.

What is the output of the following code snippet?

public class MyClass { public int X { get; set; } }

public struct MyStruct { public int X { get; set; } }

class Program { static void Main(string[] args) { MyClass classObj1 = new MyClass(); classObj1.X=12; MyClass classObj2 = classObj1; classObj2.X = 15; Console.WriteLine(classObj1.X); Console.WriteLine(classObj2.X); MyStruct structObj1 = new MyStruct(); structObj1.X = 12; MyStruct structObj2 = structObj1; structObj2.X=15; Console.WriteLine(structObj1.X); Console.WriteLine(structObj2.X); Console.ReadLine(); } }

Answer

Correct Answer: 15 15 12 15

Note: This Question is unanswered, help us to find answer for this one

248.

What will be the value of the result variable after these two statements? int num1 = 10, num2 = 9; int result = num1 & num2;

Answer

Correct Answer: 8

Note: This Question is unanswered, help us to find answer for this one

249.

In the .NET framework, what are the options available for packaging?

Answer

Correct Answer: All of these

Note: This Question is unanswered, help us to find answer for this one

250.

Two users, Monique and James are using an MIS system implemented using ADO.NET. The data refresh time in the system is set to 15 minutes. James changed the mailing address of a customer named Majda, and updated the database. Before the database refresh, Monique also updated the same customer's address as per her pending requests folder. What will happen when Monique saves the changes?

Answer

Correct Answer: Changes made by Monique will be saved by the database.

Note: This Question is unanswered, help us to find answer for this one

251.

Which of the following is the best way to measure the performance of a function?

Answer

Correct Answer: Stopwatch.StartNew(); PerformWork Stopwatch sw = (); sw.Stop();

Note: This Question is unanswered, help us to find answer for this one

252.

If i == 0, why is (i += i++) == 0 in C#?

Answer

Correct Answer: inti = 0; i = i + i; i + 1;

Note: This Question is unanswered, help us to find answer for this one

253.

Which of the following is the correct statement to combine two URL(s)?

Answer

Correct Answer: UribaseUri = new Uri(http://DomainName.com.com); UrimyUri = new Uri(, “folder/page.htm:”);

Note: This Question is unanswered, help us to find answer for this one

254.

Which is the following is the correct way to convert a Byte Array to a Hexadecimal string, and vice versa?

Answer

Correct Answer: String. Join(string. Empty,Array.ConvertAll(bytes, x => x. ToString(“x2”)));

Note: This Question is unanswered, help us to find answer for this one

255.

Can a function be overload with the same number and types of arguments (parameters), but with a different return type?

Answer

Correct Answer: No

Note: This Question is unanswered, help us to find answer for this one

256.

Which of the following can be used to expose a method as a filed to the outside world?

Answer

Correct Answer: Property

Note: This Question is unanswered, help us to find answer for this one

257.

Which of the following  is the best way to iterate over a Dictionary in c#?