Interfaces & Abstract Classes

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/14

flashcard set

Earn XP

Description and Tags

15 Terms

1
New cards

What does an abstraction focus on?

  • What behavior is available

  • What can a client rely on

  • What must remain stable


2
New cards

What does abstraction hide?

  • What data structure is used

  • Which algorithm is used

  • Which service does the work


3
New cards

What can an abstract class contain?

  • Instance fields

  • Constructors

  • Concrete methods

  • Abstract methods

  • Private/protected helpers


4
New cards

What can an abstract class cannot contain/do?

  • Cannot be instantiated directly with new (cannot make objects)

  • A concrete subclass must finish the missing pieces


5
New cards

When should an abstract class be used?

Used when related implementation truly share code, state, invariants, or an algorithm skeleton

6
New cards

Extends vs implements

  • A class extends at most one class

  • A class can implement many interfaces

  • An interface can extend another interface

  • Every runtime object is still a concrete class


7
New cards

What is the common pattern for interfaces and abstract classes?

  • Interfaces for the public role

  • Abstract class for shared code

  • Concrete subclasses for the representation-specific details


8
New cards

Implements make a _____

promise

9
New cards

Extends inherits ______

From a parent type

10
New cards

Primary methods

core capability that depends on implementation details. Often abstract in an interface

11
New cards

Secondary methods

Behavior built from existing public operations. Often a default method

12
New cards

Declared type

Type of a variable from its declaration. Compile time: Which methods can be called

13
New cards

Dynamic type

Class of the reference object. Runtime: Which instance-method implementation runs?

14
New cards

What does the declared type determine?

Determines which methods can be called

15
New cards

What does the dynamic type determine?

Determines how the method runs