Top 50+ DotNet Interview MCQS for 2024

 

 1. Which of the following is the correct syntax for declaring a delegate in .NET?

    A. public delegate int MyDelegate(int x);

    B. delegate public int MyDelegate(int x);

    C. public MyDelegate delegate int(int x);

    D. delegate int MyDelegate(int x);

    Answer: A. public delegate int MyDelegate(int x);

 

 2. What is the base class for all exceptions in .NET?

    A. Exception

    B. BaseException

    C. SystemException

    D. RuntimeException

    Answer: A. Exception

 

 3. Which of the following is not a value type in .NET?

    A. int

    B. float

    C. string

    D. double

    Answer: C. string

 

 4. What is the main entry point of a .NET application?

    A. Main()

    B. main()

    C. Start()

    D. Run()

    Answer: A. Main()

 

 5. Which of the following is true about C?

    A. It is a functional programming language.

    B. It is an objectoriented programming language.

    C. It is a procedural programming language.

    D. It is a scripting language.

    Answer: B. It is an objectoriented programming language.

 

 6. Which of the following namespaces is used for file input/output operations in .NET?

    A. System.IO

    B. System.Text

    C. System.Data

    D. System.Net

    Answer: A. System.IO

 

 7. Which of the following methods is used to retrieve data from a database in ADO.NET?

    A. ExecuteReader()

    B. ReadData()

    C. FetchData()

    D. RetrieveData()

    Answer: A. ExecuteReader()

 

 8. Which of the following is not a feature of .NET Core?

    A. Crossplatform support

    B. Unified API

    C. Closedsource

    D. High performance

    Answer: C. Closedsource

 

 9. Which class in .NET is used to represent an immutable string?

    A. String

    B. StringBuilder

    C. StringBuffer

    D. ImmutableString

    Answer: A. String

 

 10. Which of the following is used to create an instance of a class in C?

    A. new

    B. create

    C. instantiate

    D. generate

    Answer: A. new

 

 11. Which method is used to start a thread in .NET?

    A. run()

    B. execute()

    C. start()

    D. begin()

    Answer: C. start()

 

 12. What is the purpose of the using statement in C?

    A. To define a namespace.

    B. To include a library.

    C. To ensure the disposal of resources.

    D. To create an alias for a namespace.

    Answer: C. To ensure the disposal of resources.

 

 13. Which of the following types is a reference type in .NET?

    A. int

    B. double

    C. object

    D. bool

    Answer: C. object

 

 14. What does the override keyword indicate in C?

    A. The method is hiding a method in the base class.

    B. The method is implementing an interface method.

    C. The method is replacing a virtual method in the base class.

    D. The method is extending a sealed method in the base class.

    Answer: C. The method is replacing a virtual method in the base class.

 

 15. Which of the following is not an access modifier in C?

    A. public

    B. private

    C. protected

    D. internal

    Answer: D. internal

 

 16. What is the default return type of the Main method in C?

    A. int

    B. void

    C. bool

    D. string

    Answer: B. void

 

 17. Which of the following is used to handle multiple exceptions in C?

    A. catch

    B. try

    C. finally

    D. catch with multiple parameters

    Answer: A. catch

 

 18. What is the purpose of the sealed keyword in C?

    A. To prevent a class from being instantiated.

    B. To prevent a class from being inherited.

    C. To prevent a method from being overridden.

    D. To prevent a variable from being modified.

    Answer: B. To prevent a class from being inherited.

 

 19. Which of the following is a characteristic of an abstract class in C?

    A. It cannot have constructors.

    B. It cannot contain implemented methods.

    C. It can be instantiated.

    D. It cannot be instantiated.

    Answer: D. It cannot be instantiated.

 

 20. Which keyword is used to inherit a class in C?

    A. implements

    B. inherits

    C. extends

    D. :

    Answer: D. :

 

 21. What is the purpose of the is keyword in C?

    A. To check if two objects are equal.

    B. To check if an object is of a specific type.

    C. To compare two values.

    D. To assign a value to a variable.

    Answer: B. To check if an object is of a specific type.

 

 22. Which of the following is not a .NET data provider?

    A. SQL Server

    B. OLE DB

    C. ODBC

    D. MySQL

    Answer: D. MySQL

 

 23. What is the purpose of the yield keyword in C?

    A. To return a value from a method.

    B. To create an iterator block.

    C. To pause the execution of a thread.

    D. To declare a delegate.

    Answer: B. To create an iterator block.

 

 24. Which of the following is not a type of JIT compiler in .NET?

    A. PreJIT

    B. EconoJIT

    C. FullJIT

    D. PartialJIT

    Answer: D. PartialJIT

 

 25. Which of the following is used to execute a stored procedure in ADO.NET?

    A. CommandType.StoredProcedure

    B. CommandType.Text

    C. CommandType.TableDirect

    D. CommandType.StoredCommand

    Answer: A. CommandType.StoredProcedure

 

 26. Which of the following is a valid statement for creating a readonly property in C?

    A. public int MyProperty { get; }

    B. public int MyProperty { get; set; }

    C. public int MyProperty { set; }

    D. public int MyProperty { get; private set; }

    Answer: A. public int MyProperty { get; }

 

 27. Which of the following is true about extension methods in C?

    A. They must be defined in the same class.

    B. They cannot be static methods.

    C. They can extend sealed classes.

    D. They must be defined in a nonstatic class.

    Answer: C. They can extend sealed classes.

 

 28. What is the purpose of the params keyword in C?

    A. To pass a variable number of arguments to a method.

    B. To pass parameters by reference.

    C. To pass parameters by value.

    D. To pass an array as a parameter.

    Answer: A. To pass a variable number of arguments to a method.

 

 29. Which of the following is not a type of collection in .NET?

    A. ArrayList

    B. Queue

    C. Stack

    D. HashMap

    Answer: D. HashMap

 

 30. What is the purpose of the readonly keyword in C?

    A. To declare a constant value.

  

 

 B. To create a readonly property.

    C. To declare a variable that can be assigned only once.

    D. To prevent a class from being inherited.

    Answer: C. To declare a variable that can be assigned only once.

 

 31. Which of the following methods is used to register a route in ASP.NET Core?

    A. MapRoute()

    B. RegisterRoute()

    C. AddRoute()

    D. CreateRoute()

    Answer: A. MapRoute()

 

 32. Which of the following is not a lifecycle event in ASP.NET?

    A. Init

    B. Load

    C. Render

    D. Dispose

    Answer: D. Dispose

 

 33. What is the purpose of the ViewState in ASP.NET?

    A. To manage state across multiple requests.

    B. To maintain the state of controls between postbacks.

    C. To store data on the client side.

    D. To manage authentication state.

    Answer: B. To maintain the state of controls between postbacks.

 

 34. Which of the following is not a .NET Framework class library?

    A. System

    B. System.Collections

    C. System.Threading

    D. System.GarbageCollection

    Answer: D. System.GarbageCollection

 

 35. What is the purpose of the HttpContext class in ASP.NET?

    A. To manage HTTP response.

    B. To manage HTTP request.

    C. To store information about the current HTTP request and response.

    D. To handle HTTP errors.

    Answer: C. To store information about the current HTTP request and response.

 

 36. Which of the following is not an ASP.NET control?

    A. Label

    B. Button

    C. Table

    D. Text

    Answer: D. Text

 

 37. What is the purpose of the Global.asax file in ASP.NET?

    A. To define applicationlevel events.

    B. To manage session state.

    C. To configure routing.

    D. To define pagelevel events.

    Answer: A. To define applicationlevel events.

 

 38. Which of the following is not a data binding technique in ASP.NET?

    A. Simple Data Binding

    B. Complex Data Binding

    C. Automatic Data Binding

    D. Declarative Data Binding

    Answer: C. Automatic Data Binding

 

 39. What is the purpose of the Web.config file in ASP.NET?

    A. To store application settings and configuration data.

    B. To manage user authentication.

    C. To define applicationlevel events.

    D. To manage session state.

    Answer: A. To store application settings and configuration data.

 

 40. Which of the following is not a valid state management technique in ASP.NET?

    A. Session State

    B. Application State

    C. View State

    D. Global State

    Answer: D. Global State

 

 41. Which of the following is used to handle errors in ASP.NET?

    A. trycatch block

    B. HandleError attribute

    C. Error event in Global.asax

    D. All of the above

    Answer: D. All of the above

 

 42. Which of the following is not a builtin data type in C?

    A. decimal

    B. int

    C. char

    D. str

    Answer: D. str

 

 43. What is the purpose of the LINQ in .NET?

    A. To perform database operations.

    B. To perform query operations on collections.

    C. To handle exceptions.

    D. To manage memory.

    Answer: B. To perform query operations on collections.

 

 44. Which of the following is not a valid method for querying data using LINQ?

    A. Where()

    B. Select()

    C. OrderBy()

    D. Fetch()

    Answer: D. Fetch()

 

 45. What is the purpose of the async keyword in C?

    A. To create a new thread.

    B. To define an asynchronous method.

    C. To perform asynchronous operations.

    D. To handle exceptions asynchronously.

    Answer: B. To define an asynchronous method.

 

 46. Which of the following is used to convert a value type to a reference type in C?

    A. Casting

    B. Type Conversion

    C. Boxing

    D. Unboxing

    Answer: C. Boxing

 

 47. Which of the following is true about the readonly keyword in C?

    A. It can be used for variables that can be changed only within the class.

    B. It can be used for variables that can be changed only once.

    C. It can be used for variables that cannot be changed.

    D. It can be used for methods that cannot be overridden.

    Answer: B. It can be used for variables that can be changed only once.

 

 48. What is the purpose of the Task class in .NET?

    A. To manage background tasks.

    B. To represent an asynchronous operation.

    C. To perform threading operations.

    D. To manage memory.

    Answer: B. To represent an asynchronous operation.

 

 49. Which of the following is used to declare a nullable type in C?

    A. Nullable<int>

    B. int?

    C. nullable int

    D. nullable<int>

    Answer: B. int?

 

 50. Which of the following is true about the base keyword in C?

    A. It is used to call the base class constructor.

    B. It is used to call a base class method.

    C. It is used to access a base class field.

    D. All of the above

    Answer: D. All of the above

 



0 Comments:

Post a Comment