Week 6 Part 2 Flashcards
Hiding complexity and only displaying relevant features of an object. Implementation details hidden, user only sees functionality
Abstraction
How do we implement abstraction in Java?
Interfaces to define expected behaviour
and the abstract class - gives incomplete functionality
Can an abstract class be instantiated into an object?
No, it’s just a template. Needs to be extended to a concrete class.
T/F - Both classes and methods can be made abstract
True
T/F - Abstract methods have a body, classes are just templates
False. Abstract methods do not have a body.
T/F - if a method is abstract, the class must be abstract
True
An abstract method is used to specify a _________
behaviour
T/F - an abstract method is an instance method with they keyword abstract in its declaration
True, it’s just a line
An abstract class can force all of its derived classes to define their own implementation of a behaviour by defining it as an abstract method
?okay
T/F - You should not create objects of an abstract class
True
This class can be defined as an abstract class, even if it does not define any abstract method
Base class (where other classes are derived)
What happens if a derived class does not implement all the abstract metods of its base class?
It must also be defined as an abstract class
Class abstraction means to separate class ______________ from the ___ of the class
The creator of the class provides a description
of the class and let the user know how the class
can be used.
The user of the class does not need to know
how the class is implemented.
The detail of implementation is _______________
and hidden from the user
implementation from the use
encapsulated
3 advantages of abstract methods
- To make code more concise
- To enforce inheritance
- To ensure that the subclasses do not override the abstract method
Abstract methods help to ensure that any
object that ______s from an abstract class
must have implemented ________
methods that can be used by clients.
extends, concrete