object oriented programming Flashcards
class abstraction
the separation of class implementation from the use of the class
implementation
declaration of methods and attributes and code
class encapsulation
hide the details of class implementation from the user
hide the details, focus on whats important
class contract
pretty much what the API is. what methods and attributes are availible and what are their descriptions. user should only look at this, no further details
class inheritance usage
public class extends
public
class can be seen everywhere in java
protected
only package members and subclasses can see it
no modifier
only package members can see it, no subclasses
private
member can only be seen in its own class
polymorphism
variable of a superclass can refer to a subclass/more specialized class
area of 2dfigure can be circle or square
opposite of super()?
overloading
same method name can have different parameter list
overriding
subclass methods can override superclasses definitions. use @override modifier. so when you want to use polymorphism, this may be useful
concrete class
class can be used to create objects
abstract class
class CANNOT be used to create objects. they are allowed to have constructors that subclasses can use. concreate subclasses must implement all abstract methods or be abstract itself.
static
do not need an instance to be called. alot of core java functions/libraries are this
interface
class like construct that only has constants and abstract methods
- cannot have constructors
- all variables must be public, static, or final
- all methods must be public abstract
- interface can be used with extends keyword, and interface can extend multiple other interfaces
- class can extend multiple interfaces
- can be used as data type
when to use interface
interfaces model pure behavior. ANSWER WHAT CLASS CAN DO.
abstracts can save duplicate code
remember that you implement multiple interfaces but only extend from one superclass