MOTOSHARE 🚗🏍️

Rent Bikes & Cars Directly from Owners

Motoshare connects vehicle owners with people who need bikes and cars on rent. Owners earn from idle vehicles, and renters get flexible ride options.

Visit Motoshare

Top 50 .net Interview Questions with Answers

Uncategorized
.net Interview Questions with Answers

1. What is .NET Framework?

a) A programming language
b) A set of libraries and runtime
c) A database management system
d) None of the above

Answer: b

2. What is CLR?

a) Common Language Runtime
b) Common Library Runtime
c) Common Line Runtime
d) None of the above

Answer: a

3. What is the use of the ‘using’ statement in C#?

a) to declare a variable
b) to include using directive
c) to denote the start of a namespace
d) to release resources

Answer: d

4. What is the difference between Value Types and Reference Types?

a) Value types store values directly in memory
b) Reference types store reference to the value in memory
c) Value types use stack to store data
d) All of the above

Answer: d

5. What is the difference between ArrayList and List in C#?

a) ArrayList can store any type of data
b) List can only store generic data
c) ArrayList can store null values
d) All of the above

Answer: b

6. What is the difference between String and StringBuilder?

a) String is immutable while StringBuilder is mutable
b) StringBuilder is faster than String for concatenation
c) String is thread-safe while StringBuilder is not
d) All of the above

Answer: a

7. What is the difference between Boxing and Unboxing in C#?

a) Boxing is converting a value type to a reference type
b) Unboxing is converting a reference type to a value type
c) Boxing and unboxing are the same
d) None of the above

Answer: a

8. What is the use of the ‘static’ keyword in C#?

a) to create static variables
b) to create static methods
c) to create a static class
d) All of the above

Answer: d

9. What is the difference between an interface and an abstract class in C#?

a) Interfaces cannot have implementation while Abstract classes can
b) A class can implement multiple interfaces but can inherit only one Abstract class
c) Both interfaces and abstract classes prevent multiple inheritance
d) All of the above

Answer: d

10. What is the use of the ‘sealed’ keyword in C#?

a) to prevent inheritance
b) to prevent overriding
c) to prevent both inheritance and overriding
d) All of the above

Answer: c

11. What is the use of the ‘finally’ block in a try-catch-finally statement?

a) to execute code when an exception is caught
b) to execute code whether an exception is caught or not
c) to prevent code from executing when an exception is caught
d) None of the above

Answer: b

12. What is the difference between a private and a protected access modifier in C#?

a) Private members can only be accessed within the same class while protected members can be accessed within the same class and its derived classes
b) Private members can only be accessed within the same assembly while protected members can be accessed within the same assembly and its derived assemblies
c) Private members can only be accessed within the same namespace while protected members can be accessed within the same namespace and its derived namespaces
d) All of the above

Answer: a

13. What is the use of the ‘yield’ keyword in C#?

a) to create an iterator
b) to break out of a loop
c) to throw an exception
d) None of the above

Answer: a

14. What is a delegate in C#?

a) a reference to a method
b) a class
c) an interface
d) None of the above

Answer: a

15. What is the use of the ‘async’ and ‘await’ keywords in C#?

a) to create asynchronous methods
b) to create synchronous methods
c) to create parallel code
d) None of the above

Answer: a

16. What is a lambda expression in C#?

a) a way to define an anonymous function
b) a way to define constants
c) a way to define classes
d) a way to define interfaces

Answer: a

17. What is the difference between an event and a delegate in C#?

a) Events are built on top of delegates
b) Delegates are methods while events are actions
c) Delegates can be invoked directly while events cannot
d) All of the above

Answer: a

18. What is a LINQ in C#?

a) Language Integrated Query
b) LINQ is a programming language
c) LINQ is a database management system
d) None of the above

Answer: a

19. What is the use of the ‘var’ keyword in C#?

a) to declare a variable
b) to declare a constant
c) to declare a property
d) None of the above

Answer: a

20. What is the difference between a try-catch statement and a try-finally statement?

a) A try-catch statement catches exceptions while a try-finally statement does not
b) A try-finally statement executes code whether or not an exception is caught
c) Both try-catch and try-finally can catch exceptions
d) All of the above

Answer: b

21. What is the difference between a ‘ref’ parameter and an ‘out’ parameter in C#?

a) ‘ref’ parameters must be initialized before being passed while ‘out’ parameters do not
b) ‘out’ parameters must be initialized before being passed while ‘ref’ parameters do not
c) Both ‘ref’ and ‘out’ parameters must be initialized before being passed
d) All of the above

Answer: b

22. What is the use of the ‘as’ operator in C#?

a) to cast objects
b) to check if an object is a certain type
c) to compare two objects for equality
d) None of the above

Answer: a

23. What is a static constructor in C#?

a) a method that is called when an instance of a class is created
b) a method that is called when a class is loaded into memory
c) a method that is called when a class is unloaded from memory
d) None of the above

Answer: b

24. What is the use of the ‘base’ keyword in C#?

a) to access the base class’ properties and methods
b) to access the derived class’ properties and methods
c) to access the base class’ constructor
d) All of the above

Answer: a

25. What is the difference between an abstract method and a virtual method in C#?

a) Abstract methods cannot have implementation while virtual methods can
b) A class must implement all abstract methods while it can choose to override virtual methods
c) Both abstract and virtual methods can have implementation
d) None of the above

Answer: b

26. What is the use of the ‘protected internal’ access modifier in C#?

a) to mark a member as protected and internal
b) to mark a member as protected or internal
c) to mark a class as protected and internal
d) None of the above

Answer: a

27. What is the use of the ‘finally’ keyword in C#?

a) to indicate the end of a try-catch-finally block
b) to indicate the start of a try-catch-finally block
c) to indicate the end of a while loop
d) None of the above

Answer: a

28. What is the use of the ‘stack’ class in C#?

a) to manage a collection of elements in a last-in, first-out manner
b) to manage a collection of elements in a first-in, first-out manner
c) to manage a collection of elements in an ordered manner
d) None of the above

Answer: a

29. What is the difference between a field and a property in C#?

a) Fields are like variables while properties are like methods
b) Properties are like variables while fields are like methods
c) Both fields and properties are like variables
d) All of the above

Answer: a

30. What is the use of the ‘using’ directive in C#?

a) to include namespace in the current file
b) to declare a variable
c) to create a namespace
d) None of the above

Answer: a

31. What is the difference between a string and a StringBuilder in C#?

a) String is immutable while StringBuilder is mutable
b) StringBuilder is faster than String for concatenation
c) String is thread-safe while StringBuilder is not
d) All of the above

Answer: a

32. What is the difference between an abstract class and an interface in C#?

a) Interfaces cannot have implementation while Abstract classes can
b) A class can implement multiple interfaces but can inherit only one Abstract class
c) Both interfaces and abstract classes prevent multiple inheritance
d) All of the above

Answer: d

33. What is the use of the ‘static’ keyword in C#?

a) to create static variables
b) to create static methods
c) to create a static class
d) All of the above

Answer: d

34. What is the use of the ‘sealed’ keyword in C#?

a) to prevent inheritance
b) to prevent overriding
c) to prevent both inheritance and overriding
d) All of the above

Answer: c

35. Which of the following is a value type in C#?

a) int
b) string
c) object
d) None of the above

Answer: a

36. What is the difference between an array and a List in C#?

a) Arrays have a fixed size while Lists can grow and shrink dynamically
b) Arrays can store only a single type of element while Lists can store any type of element
c) Arrays use index while Lists use iterators
d) All of the above

Answer: a

37. What is the difference between a private and a protected access modifier in C#?

a) Private members can only be accessed within the same class while protected members can be accessed within the same class and its derived classes
b) Private members can only be accessed within the same assembly while protected members can be accessed within the same assembly and its derived assemblies
c) Private members can only be accessed within the same namespace while protected members can be accessed within the same namespace and its derived namespaces
d) All of the above

Answer: a

38. What is the use of the ‘finally’ block in a try-catch-finally statement?

a) to execute code when an exception is caught
b) to execute code whether an exception is caught or not
c) to prevent code from executing when an exception is caught
d) None of the above

Answer: b

39. What is the use of the ‘yield’ keyword in C#?

a) to create an iterator
b) to break out of a loop
c) to throw an exception
d) None of the above

Answer: a

40. What is a delegate in C#?

a) a reference to a method
b) a class
c) an interface
d) None of the above

Answer: a

41. What is the use of the ‘async’ and ‘await’ keywords in C#?

a) to create asynchronous methods
b) to create synchronous methods
c) to create parallel code
d) None of the above

Answer: a

42. What is a lambda expression in C#?

a) a way to define an anonymous function
b) a way to define constants
c) a way to define classes
d) a way to define interfaces

Answer: a

43. What is the difference between an event and a delegate in C#?

a) Events are built on top of delegates
b) Delegates are methods while events are actions
c) Delegates can be invoked directly while events cannot
d) All of the above

Answer: a

44. What is the use of the ‘var’ keyword in C#?

a) to declare a variable
b) to declare a constant
c) to declare a property
d) None of the above

Answer: a

45. What is the use of the ‘base’ keyword in C#?

a) to access the base class’ properties and methods
b) to access the derived class’ properties and methods
c) to access the base class’ constructor
d) All of the above

Answer: a

46. What is the use of the ‘protected internal’ access modifier in C#?

a) to mark a member as protected and internal
b) to mark a member as protected or internal
c) to mark a class as protected and internal
d) None of the above

Answer: a

47. What is the use of the ‘stack’ class in C#?

a) to manage a collection of elements in a last-in, first-out manner
b) to manage a collection of elements in a first-in, first-out manner
c) to manage a collection of elements in an ordered manner
d) None of the above

Answer: a

48. What is the use of the ‘using’ directive in C#?

a) to include namespace in the current file
b) to declare a variable
c) to create a namespace
d) None of the above

Answer: a

49. What is the difference between a string and a StringBuilder in C#?

a) String is immutable while StringBuilder is mutable
b) StringBuilder is faster than String for concatenation
c) String is thread-safe while StringBuilder is not
d) All of the above

Answer: a

50. What is the difference between an abstract class and an interface in C#?

a) Interfaces cannot have implementation while Abstract classes can
b) A class can implement multiple interfaces but can inherit only one Abstract class
c) Both interfaces and abstract classes prevent multiple inheritance
d) All of the above

Answer: d

Ashwani Kumar
Latest posts by Ashwani Kumar (see all)
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
0
Would love your thoughts, please comment.x
()
x