Frequently asked questions and answers of C# in Programming Technologies of Computer Science to enhance your skills, knowledge on the selected topic. We have compiled the best C# Interview question and answer, trivia quiz, mcq questions, viva question, quizzes to prepare. Download C# FAQs in PDF form online for academic course, jobs preparations and for certification exams .
Intervew Quizz is an online portal with frequently asked interview, viva and trivia questions and answers on various subjects, topics of kids, school, engineering students, medical aspirants, business management academics and software professionals.
Question-1. What is C#?
Answer-1: C# is a modern, object-oriented programming language developed by Microsoft as part of the .NET platform.
Question-2. What are the main features of C#?
Answer-2: Key features include object-oriented programming, strong typing, garbage collection, and support for LINQ.
Question-3. What is the Common Language Runtime (CLR)?
Answer-3: The CLR is the runtime environment in the .NET Framework that handles code execution, memory management, and security.
Question-4. What is the difference between struct and class in C#?
Answer-4: struct is a value type stored in the stack; class is a reference type stored in the heap.
Question-5. What is a managed code in C#?
Answer-5: Managed code is executed under the supervision of the CLR, which provides memory management and security.
Question-6. What is an assembly in C#?
Answer-6: An assembly is a compiled code library used in .NET, consisting of DLL or EXE files.
Question-7. What is the difference between Array and ArrayList?
Answer-7: Array is fixed in size and type-safe; ArrayList can grow dynamically and holds objects of any type.
Question-8. What are value types and reference types in C#?
Answer-8: Value types store data directly, while reference types store references to the data's memory location.
Question-9. What is the difference between == and .Equals() in C#?
Answer-9: == compares object references or values; .Equals() checks for content equality.
Question-10. What is the purpose of the using keyword in C#?
Answer-10: The using keyword manages namespaces and ensures proper disposal of unmanaged resources.
Question-11. What is a delegate in C#?
Answer-11: A delegate is a type-safe function pointer used for callback methods and event handling.
Question-12. What are events in C#?
Answer-12: Events are notifications sent by an object to signal that something has occurred.
Question-13. What is the difference between abstract class and interface?
Answer-13: An abstract class can have implemented methods; an interface cannot have any implementation (until C# 8.0).
Question-14. What is polymorphism in C#?
Answer-14: Polymorphism allows methods to have different implementations based on the context (overriding and overloading).
Question-15. What is encapsulation in C#?
Answer-15: Encapsulation is bundling data and methods in a class and restricting access to its details.
Question-16. What is inheritance in C#?
Answer-16: Inheritance allows a class to acquire properties and methods from another class.
Question-17. What is the purpose of the static keyword in C#?
Answer-17: The static keyword makes members belong to the class rather than an instance of the class.
Question-18. What is the sealed keyword in C#?
Answer-18: sealed prevents a class from being inherited.
Question-19. What is the difference between const and readonly in C#?
Answer-19: const is a compile-time constant; readonly is a runtime constant.
Question-20. What is a nullable type in C#?
Answer-20: Nullable types allow value types to hold null. Example: int? x = null;.
Question-21. What are generics in C#?
Answer-21: Generics allow the creation of type-safe data structures and methods without committing to a specific data type.
Question-22. What is LINQ in C#?
Answer-22: LINQ (Language Integrated Query) allows querying collections and databases in a consistent way.
Question-23. What is the difference between IEnumerable and IQueryable?
Answer-23: IEnumerable is for in-memory queries; IQueryable allows remote queries like databases.
Question-24. What is a try-catch block in C#?
Answer-24: try-catch is used to handle exceptions by executing alternative code when an error occurs.
Question-25. What is the finally block in C#?
Answer-25: The finally block executes code after a try-catch block, regardless of whether an exception was thrown.
Question-26. What is the difference between throw and throw ex in C#?
Answer-26: throw preserves the original exception stack trace; throw ex overwrites it.
Question-27. What is garbage collection in C#?
Answer-27: Garbage collection automatically manages memory by removing objects no longer in use.
Question-28. What is the difference between Dispose() and Finalize()?
Answer-28: Dispose() is called explicitly; Finalize() is called by the garbage collector.
Question-29. What is a thread in C#?
Answer-29: A thread is a lightweight process that allows concurrent execution of code.
Question-30. What is the async and await keywords in C#?
Answer-30: async marks a method as asynchronous, and await pauses the execution until the task completes.
Question-31. What are extension methods in C#?
Answer-31: Extension methods allow adding new methods to existing types without modifying them.
Question-32. What is the difference between ref and out in C#?
Answer-32: ref requires initialization before use; out does not.
Question-33. What are C# properties?
Answer-33: Properties are special methods that encapsulate data access (getters and setters).
Question-34. What is the purpose of the is and as keywords in C#?
Answer-34: is checks type compatibility; as performs type conversion and returns null if it fails.
Question-35. What is a partial class in C#?
Answer-35: A partial class allows splitting a class's implementation across multiple files.
Question-36. What is a tuple in C#?
Answer-36: A tuple is a data structure for storing multiple values of different types.
Question-37. What are indexers in C#?
Answer-37: Indexers allow objects to be indexed like arrays.
Question-38. What is the difference between stack and heap memory?
Answer-38: The stack is for static memory allocation; the heap is for dynamic memory allocation.
Question-39. What is the lock keyword in C#?
Answer-39: The lock keyword ensures that a block of code is executed by only one thread at a time.
Question-40. What are C# attributes?
Answer-40: Attributes provide metadata about types, methods, and properties.
Question-41. What is reflection in C#?
Answer-41: Reflection is used to inspect and manipulate metadata at runtime.
Question-42. What is the difference between shallow copy and deep copy?
Answer-42: Shallow copy duplicates references; deep copy duplicates the actual objects.
Question-43. What is a Nullable type in C#?
Answer-43: Nullable types allow variables to hold null values. Example: int? num = null;.
Question-44. What is the difference between String and StringBuilder?
Answer-44: String is immutable; StringBuilder is mutable and allows modifying strings efficiently.
Question-45. What are access modifiers in C#?
Answer-45: Access modifiers include public, private, protected, internal, and combinations like protected internal.
Question-46. What is the difference between interface and abstract class?
Answer-46: An abstract class can have implemented methods; interfaces cannot until C# 8.0.
Question-47. What is a singleton pattern in C#?
Answer-47: The singleton pattern restricts a class to a single instance and provides a global access point.
Question-48. What is the purpose of the base keyword in C#?
Answer-48: The base keyword accesses methods and properties of a parent class from a child class.
Question-49. What is the difference between early binding and late binding?
Answer-49: Early binding happens at compile time; late binding happens at runtime.
Question-50. How do you handle exceptions in C#?
Answer-50: Use try-catch blocks and optionally finally to handle exceptions.
Frequently Asked Question and Answer on C#
C# Interview Questions and Answers in PDF form Online
C# Questions with Answers
C# Trivia MCQ Quiz