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/overridegives runtime dispatch.newonly *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
- Which statement about interfaces in modern C# (C# 8 and later) is true?Multiple choiceEasy
- What does this program print?What does this code output?Medium
- Which statements about struct types in C# are true? Select all that apply.Select all that applyMedium
- Explain the difference between method overloading and method overriding in C#. Give a short example of each.Interview answerMedium