Skip to content
Sharp

Object-oriented programming interview questions

Classes, inheritance, polymorphism, interfaces and structs.

4 questions with answers and explanations · 2 flashcards

Key ideas

  • Encapsulation hides state behind members; inheritance reuses behavior; polymorphism lets a base reference call the most-derived override.
  • virtual/override gives runtime dispatch. new only *hides* a member, so the call depends on the reference type.
  • Interfaces define contracts (and since C# 8 can carry default implementations). A class has one base class but many interfaces.
  • structs are value types: copied on assignment, can implement interfaces, can't inherit.

Questions

  1. Which statement about interfaces in modern C# (C# 8 and later) is true?Multiple choiceEasy
  2. What does this program print?What does this code output?Medium
  3. Which statements about struct types in C# are true? Select all that apply.Select all that applyMedium
  4. Explain the difference between method overloading and method overriding in C#. Give a short example of each.Interview answerMedium