All fields

“Interfaces & Abstract Classes” in Information Technology

78 questions across 4 technologies.

Information Technology

78 questions in 4 technologies

#QuestionTechnologyTopicLevel
1Can an interface extend multiple other interfaces simultaneously, and how does this differ from a class's single-inheritance restriction for abstract/concrete classes? Java › Interfaces & Abstract ClassesJavaInterfaces & Abstract ClassesIntermediate
2How does the Liskov Substitution Principle relate to properly designing interfaces and abstract classes so that subclasses can genuinely be substituted for their parent type without breaking expected behavior? PHP › Interfaces & Abstract ClassesPHPInterfaces & Abstract ClassesAdvanced
3How would you use an abstract class to implement the Template Method pattern, defining a fixed algorithm skeleton with some steps left abstract for subclasses to fill in? Java › Interfaces & Abstract ClassesJavaInterfaces & Abstract ClassesIntermediate
4How do you decide whether to use an interface or an abstract class when designing a set of related classes that share common behavior? PHP › Interfaces & Abstract ClassesPHPInterfaces & Abstract ClassesIntermediate
5How does PHP's type system use interfaces to enable polymorphism, allowing different concrete classes to be used interchangeably wherever the interface type is expected? PHP › Interfaces & Abstract ClassesPHPInterfaces & Abstract ClassesIntermediate
6How would you design a class hierarchy combining an abstract base class WITH multiple interfaces to model both shared implementation AND multiple independent capabilities? C# › Interfaces & Abstract ClassesC#Interfaces & Abstract ClassesAdvanced
7How does the 'sealed' modifier interact with abstract classes and interface method overrides to control further extensibility? C# › Interfaces & Abstract ClassesC#Interfaces & Abstract ClassesAdvanced
8How would you use an abstract class combined with the Non-Virtual Interface (NVI) idiom to enforce that certain methods are always called in a specific pattern, even when subclasses override customizable parts? Java › Interfaces & Abstract ClassesJavaInterfaces & Abstract ClassesAdvanced
9How can PHP's interface based type hinting combined with abstract classes support building a genuinely extensible plugin architecture within an application? PHP › Interfaces & Abstract ClassesPHPInterfaces & Abstract ClassesAdvanced
10What is the difference between an interface and an abstract class in C#, and when should you choose one over the other? C# › Interfaces & Abstract ClassesC#Interfaces & Abstract ClassesBeginner
11What is the fundamental difference between an interface and an abstract class in Java, and when would you choose one over the other? Java › Interfaces & Abstract ClassesJavaInterfaces & Abstract ClassesBeginner
12What is the purpose of declaring an abstract class with a protected constructor, and how does this pattern communicate the class's intended usage to other developers? Java › Interfaces & Abstract ClassesJavaInterfaces & Abstract ClassesIntermediate
13How would you use an abstract class's constructor to enforce that certain validation or initialization logic always runs for every subclass, something an interface (lacking constructors entirely) cannot provide? Java › Interfaces & Abstract ClassesJavaInterfaces & Abstract ClassesIntermediate
14How is the 'diamond problem' (a class implementing two interfaces with conflicting default methods) resolved in Java, and what rule determines which default method 'wins' or whether the compiler requires explicit resolution? Java › Interfaces & Abstract ClassesJavaInterfaces & Abstract ClassesAdvanced
15How would you design a sealed interface (Java 17+) to restrict which classes are permitted to implement it, and what benefit does this provide over a traditional open (unrestricted) interface for exhaustiveness checking? Java › Interfaces & Abstract ClassesJavaInterfaces & Abstract ClassesAdvanced
16How would you use an interface with only static and default methods (no abstract methods at all) to build a fluent, extensible utility API, and what's a real JDK example of this pattern? Java › Interfaces & Abstract ClassesJavaInterfaces & Abstract ClassesAdvanced
17What is the difference between an interface and an abstract class? C# › Interfaces & Abstract ClassesC#Interfaces & Abstract ClassesBeginner
18What is an abstract class, and how does it differ from a fully concrete base class? C# › Interfaces & Abstract ClassesC#Interfaces & Abstract ClassesBeginner
19What is an interface in PHP, and what purpose does it serve in defining a contract for classes to follow? PHP › Interfaces & Abstract ClassesPHPInterfaces & Abstract ClassesBeginner
20What is an abstract class in PHP, and how does it differ from a regular class and from an interface? PHP › Interfaces & Abstract ClassesPHPInterfaces & Abstract ClassesBeginner
21Can a class implement two interfaces with the same method? How is it resolved? C# › Interfaces & Abstract ClassesC#Interfaces & Abstract ClassesIntermediate
22How do you decide between using an interface versus an abstract class for a given design? C# › Interfaces & Abstract ClassesC#Interfaces & Abstract ClassesIntermediate
23When would you choose an abstract class over an interface for extensibility? C# › Interfaces & Abstract ClassesC#Interfaces & Abstract ClassesAdvanced
24How do static abstract interface members (C# 11+) enable generic math and other 'static polymorphism' patterns? C# › Interfaces & Abstract ClassesC#Interfaces & Abstract ClassesAdvanced
25How would you implement the 'Liskov Substitution Principle' correctly when designing an abstract class hierarchy, and what's a classic violation example? C# › Interfaces & Abstract ClassesC#Interfaces & Abstract ClassesAdvanced
26Can an interface declare instance fields, and if so, what implicit modifiers are automatically applied to any field declared in an interface? Java › Interfaces & Abstract ClassesJavaInterfaces & Abstract ClassesBeginner
27How do default methods (introduced in Java 8) let an interface provide a method implementation, and what problem were they specifically introduced to solve? Java › Interfaces & Abstract ClassesJavaInterfaces & Abstract ClassesIntermediate
28How would you implement the 'mixin' pattern in Java using default methods on an interface, letting a class gain reusable behavior without traditional inheritance? Java › Interfaces & Abstract ClassesJavaInterfaces & Abstract ClassesIntermediate
29What are private methods on an interface (introduced in Java 9), and what specific problem do they solve regarding code duplication between multiple default methods? Java › Interfaces & Abstract ClassesJavaInterfaces & Abstract ClassesAdvanced
30Why program to an interface rather than a concrete type? C# › Interfaces & Abstract ClassesC#Interfaces & Abstract ClassesBeginner
31What is an interface, and what can (and can't) it contain in its most basic form? C# › Interfaces & Abstract ClassesC#Interfaces & Abstract ClassesBeginner
32What are default interface methods and when are they useful? C# › Interfaces & Abstract ClassesC#Interfaces & Abstract ClassesIntermediate
33How do default interface methods (C# 8+) let an interface provide implementation, and what backward-compatibility problem do they solve? C# › Interfaces & Abstract ClassesC#Interfaces & Abstract ClassesIntermediate
34How does explicit interface implementation work, and when would you use it instead of a normal (implicit) implementation? C# › Interfaces & Abstract ClassesC#Interfaces & Abstract ClassesIntermediate
35What are static methods on an interface, and how do they differ from default methods in terms of inheritance and typical use case? Java › Interfaces & Abstract ClassesJavaInterfaces & Abstract ClassesIntermediate
36Can an interface extend another interface in PHP, and how does this let you build more specific contracts on top of a more general one? PHP › Interfaces & Abstract ClassesPHPInterfaces & Abstract ClassesIntermediate
37What is the Interface Segregation Principle and how does it apply in C#? C# › Interfaces & Abstract ClassesC#Interfaces & Abstract ClassesAdvanced
38How does interface segregation (the 'I' in SOLID) guide splitting a large, monolithic interface into several smaller, more focused ones? C# › Interfaces & Abstract ClassesC#Interfaces & Abstract ClassesAdvanced
39How does a marker interface (an interface with no methods at all, like Serializable or Cloneable) work, and what's the modern alternative approach (annotations) for achieving similar 'tagging' purposes? Java › Interfaces & Abstract ClassesJavaInterfaces & Abstract ClassesAdvanced
40How would you implement a custom functional interface with generic type parameters, and what considerations apply when designing one instead of reusing a built-in java.util.function interface? Java › Functional Interfaces & Method ReferencesJavaFunctional Interfaces & Method ReferencesAdvanced
41What is a trait in PHP, and how does it let you share a set of methods across multiple unrelated classes without using traditional inheritance? PHP › TraitsPHPTraitsBeginner
42What is covariance ('out T') and contravariance ('in T') in generic interfaces, and how does IEnumerable<out T> demonstrate covariance? C# › GenericsC#GenericsIntermediate
43Can a trait define abstract methods, and how does this let a trait enforce that any class using it must provide its own specific implementation of certain behavior? PHP › TraitsPHPTraitsIntermediate
44How would you implement generic operator constraints using .NET's generic math interfaces (like INumber<T>) to write a single Sum<T>() method working across int, double, and decimal? C# › GenericsC#GenericsAdvanced
45How does structural typing handle two interfaces that are 'shape-identical' but declared completely independently? TypeScript › Structural Typing & Duck TypingTypeScriptStructural Typing & Duck TypingIntermediate
46What is a delegate in C#, and what does it represent conceptually? C# › Delegates, Events & LambdasC#Delegates, Events & LambdasBeginner
47What is dependency injection, and what problem does it solve compared to a class creating its own dependencies directly? C# › Dependency Injection & IoC PrinciplesC#Dependency Injection & IoC PrinciplesBeginner
48How do you register and resolve a service using ASP.NET Core's built-in dependency injection container? C# › Dependency Injection & IoC PrinciplesC#Dependency Injection & IoC PrinciplesBeginner
49How does the Factory Method pattern work in C#, and what problem does it solve? C# › Design Patterns in C#C#Design Patterns in C#Beginner
50What do the built-in @Override, @Deprecated, and @SuppressWarnings annotations do? Java › AnnotationsJavaAnnotationsBeginner
51What is the Factory Method pattern's simplest form -- a basic static factory returning different subtype instances based on input -- and why might you prefer it over exposing constructors directly? Java › Design Patterns in JavaJavaDesign Patterns in JavaBeginner
52What is the Iterator interface in PHP, and how does it relate to how a foreach loop actually works behind the scenes? PHP › Generators & IteratorsPHPGenerators & IteratorsBeginner
53What are the four core principles of object oriented programming, and how does PHP support each of them? PHP › OOPPHPOOPBeginner
54What are the three visibility modifiers in PHP, public, protected, and private, and how do they control access to a class's properties and methods? PHP › OOPPHPOOPBeginner
55What is the difference between IEnumerable<T>, ICollection<T>, and IList<T> in the collection interface hierarchy? C# › CollectionsC#CollectionsIntermediate
56What is an event, and how does it differ from a plain public delegate field? C# › Delegates, Events & LambdasC#Delegates, Events & LambdasIntermediate
57How would you implement the Decorator pattern in C# to add behavior to an object without modifying its original class? C# › Design Patterns in C#C#Design Patterns in C#Intermediate
58How do generic type constraints ('where T : ...') restrict what types can be used, and what are the common constraint kinds? C# › GenericsC#GenericsIntermediate
59How would you implement a custom IEnumerable<T> on your own class using yield return, letting it support foreach? C# › Iterators & yield returnC#Iterators & yield returnIntermediate
60What is the purpose of the @FunctionalInterface annotation, and is it required for an interface to actually be treated as a functional interface? Java › AnnotationsJavaAnnotationsIntermediate
61What is the Factory Method pattern, and how does it differ from the simpler Static Factory Method idiom (like List.of() or Optional.of())? Java › Design Patterns in JavaJavaDesign Patterns in JavaIntermediate
62What is the Adapter pattern, and when would you use it to make an existing class compatible with an interface it wasn't originally designed to implement? Java › Design Patterns in JavaJavaDesign Patterns in JavaIntermediate
63What is the difference between composition and inheritance as ways to reuse code, and why does the design principle "favor composition over inheritance" generally guide modern Java design (including many design patterns themselves)? Java › Design Patterns in JavaJavaDesign Patterns in JavaIntermediate
64How would you implement the Composite pattern to treat individual objects and groups of objects uniformly, such as a file system with files and directories? Java › Design Patterns in JavaJavaDesign Patterns in JavaIntermediate
65How would you implement an enum that also implements an interface, and what's the benefit of having different enum constants provide different behavior through a shared interface contract? Java › EnumsJavaEnumsIntermediate
66How would you write a generic interface (like a custom Repository<T, ID> pattern common in data-access layers) and implement it for a specific entity type? Java › GenericsJavaGenericsIntermediate
67What are extension methods in C#, and how do they let you add functionality to a type you can't modify? C# › Extension MethodsC#Extension MethodsIntermediate
68What is the IteratorAggregate interface, and how does it provide a simpler alternative to implementing the full Iterator interface directly? PHP › Generators & IteratorsPHPGenerators & IteratorsIntermediate
69How does inheritance work in PHP using the extends keyword, and how do you call a parent class's constructor or method from within a child class? PHP › OOPPHPOOPIntermediate
70How do you use reflection to discover all types in an assembly that implement a specific interface, useful for plugin discovery? C# › Attributes & ReflectionC#Attributes & ReflectionAdvanced
71How would you implement a custom, strongly-typed, read-only wrapper around a mutable collection to safely expose it from a class's public API? C# › CollectionsC#CollectionsAdvanced
72How would you implement the Chain of Responsibility pattern in C# to process a request through a series of independent handlers? C# › Design Patterns in C#C#Design Patterns in C#Advanced
73How should Equals() be implemented differently for a class designed to support INHERITANCE, to correctly handle equality between a base type and derived types? C# › Equality: Equals, GetHashCode & IEquatableC#Equality: Equals, GetHashCode & IEquatableAdvanced
74How would you write an extension method on an interface (like IEnumerable<T>) that provides a default implementation shared across EVERY concrete implementing type? C# › Extension MethodsC#Extension MethodsAdvanced
75How would you implement a custom Stream subclass to wrap another stream with additional behavior, like counting bytes read? C# › File I/O & StreamsC#File I/O & StreamsAdvanced
76How would you implement a generic method with MULTIPLE type parameters and constraints that reference EACH OTHER, like a generic mapping function? C# › GenericsC#GenericsAdvanced
77How does PHP handle multiple inheritance limitations, and how do traits provide a mechanism for sharing reusable code across multiple unrelated class hierarchies? PHP › OOPPHPOOPAdvanced
78How does PHP's type variance, specifically covariance and contravariance, affect how return types and parameter types can be safely changed when overriding a method in a child class? PHP › Type Declarations & Strict TypesPHPType Declarations & Strict TypesAdvanced