FlashKeepers

Computer Science · College

Object-Oriented Programming, Unit 5: Abstract Classes and Interfaces

Object-Oriented Programming, unit: Abstract Classes and Interfaces. Core concepts, terminology, and worked-example cues a college student meets for this unit, building on prior units without repeating them. Front: a term, concept, or short problem cue. Back: the definition, explanation, or answer.

13 cards · basic cards · AI-written, checked twice. Edit anything.

Study this set free Look inside first Get FlashKeepers for iPhone
What is an abstract class?
A class that cannot be instantiated directly and may contain unimplemented methods
What is an abstract method?
A method declared without an implementation, requiring subclasses to define it
Why would a class be declared abstract?
To define a common structure while forcing subclasses to provide specific behavior
What is an interface, in OOP?
A contract defining method signatures that implementing classes must provide
What is the main difference between an abstract class and an interface?
An abstract class can include shared implementation; an interface traditionally only declares method signatures
Can a class implement multiple interfaces?
Yes, a class can implement any number of interfaces
Can a class extend multiple abstract classes (in most single-inheritance languages)?
No, typically only one class can be extended, but multiple interfaces can be implemented
What is a default method in an interface?
A method with a provided implementation that implementing classes may optionally override
What is a marker interface?
An interface with no methods, used to tag a class with a particular property
Why use an interface instead of a concrete class as a type?
It allows code to depend on behavior rather than a specific implementation, improving flexibility
What is programming to an interface, as a design principle?
Writing code that depends on abstract behavior rather than concrete implementations
What happens if a class fails to implement all abstract methods of an interface?
The class must itself be declared abstract, or a compile error occurs
What is an abstract class's constructor used for, even though it cannot be instantiated?
Initializing shared state that subclasses inherit when they are instantiated