FlashKeepers

Computer Science · College · College and University

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.

About this set

37 basic cards for College Computer Science. Set 5 of 7 in Object-Oriented Programming. It opens with "What is an abstract class?" and "What is an abstract method?". Study it alongside the other College sets below.

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

Study this set free Look inside first Get FlashKeepers for iPhone

Opens in your browser, no account. Get the iPhone and iPad app · Android app

What is an abstract class?
Show answerA class that cannot be instantiated directly and may contain unimplemented methods
What is an abstract method?
Show answerA method declared without an implementation, requiring subclasses to define it
Why would a class be declared abstract?
Show answerTo define a common structure while forcing subclasses to provide specific behavior
What is an interface, in OOP?
Show answerA contract defining method signatures that implementing classes must provide
What is the main difference between an abstract class and an interface?
Show answerAn abstract class can include shared implementation; an interface traditionally only declares method signatures
Can a class implement multiple interfaces?
Show answerYes, a class can implement any number of interfaces
Can a class extend multiple abstract classes (in most single-inheritance languages)?
Show answerNo, typically only one class can be extended, but multiple interfaces can be implemented
What is a default method in an interface?
Show answerA method with a provided implementation that implementing classes may optionally override
What is a marker interface?
Show answerAn 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?
Show answerIt allows code to depend on behavior rather than a specific implementation, improving flexibility
What is programming to an interface, as a design principle?
Show answerWriting code that depends on abstract behavior rather than concrete implementations
What happens if a class fails to implement all abstract methods of an interface?
Show answerThe 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?
Show answerInitializing shared state that subclasses inherit when they are instantiated
What is a pure virtual function, in C++?
Show answerA virtual function declared with "= 0" and no implementation in the base class, forcing derived classes to override it.
In C++, what makes a class abstract?
Show answerContaining at least one pure virtual function.

22 more cards in the app

Study this set free