C# - Interfaces Questions and Answers

Take Exam

C# Interfaces programming questions and answers are frequently asked in technical interviews and placement exams conducted by top companies like Tech Mahindra, Infosys, and Wipro. Interfaces in C# define a contract that classes and structs can implement, ensuring consistency and abstraction in code design. Understanding interfaces helps programmers achieve loose coupling and multiple inheritance in an object-oriented way. Practicing programming interview questions with answers based on interfaces improves one’s ability to design modular, scalable software systems. Candidates should explore interface inheritance, explicit implementation, and default methods introduced in modern C# to excel in interview coding rounds.

Questions on interfaces and abstraction in C. Complement with C++ polymorphism and encapsulation
 

C# - Interfaces

Showing 10 of 38 questions

31. Which of the following cannot be declared in an interface

  • Events
  • Indexers
  • Constants
  • Explanation: Interfaces cannot contain instance variables.
Show Answer Report

32. Can interfaces be used for dependency injection

  • No
  • Explanation: Interfaces are commonly used in dependency injection to reduce tight coupling.
  • Only with structs
  • Only with abstract classes
Show Answer Report

33. What symbol separates multiple interfaces in implementation

  • Explanation: Multiple interfaces are separated using commas.
  • Semicolon
  • Dot
  • Pipe
Show Answer Report

34. Can an interface extend multiple interfaces

  • No
  • Explanation: An interface can inherit multiple interfaces.
  • Only two interfaces
  • Only abstract interfaces
Show Answer Report

35. Which access modifier is not allowed in interface members

  • public
  • Explanation: Interface members cannot be private.
  • protected
  • internal
Show Answer Report

36. What is the main difference between interface and abstract class

  • Interface supports constructors
  • Abstract class supports multiple inheritance
  • Explanation: Interfaces support multiple inheritance, whereas abstract classes do not.
  • Abstract class cannot have methods
Show Answer Report

37. Can an interface contain static methods

  • No
  • Explanation: Static methods in interfaces are allowed starting from C# 8.0.
  • Only in classes
  • Only in structs
Show Answer Report

38. When should an interface be preferred over an abstract class

  • When common code is required
  • Explanation: Interfaces are preferred when multiple inheritance is required.
  • When data members are needed
  • When constructors are required
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test