Exam 1 Flashcards
(38 cards)
Abstraction
Provide high-level model of activity or data
Don’t worry about the details; What does it do, not how
Procedural Abstraction
Specify what actions should be performed
Hide algorithms
Data Abstraction
Specify data objects for problem
Hide Representation
Abstract Data Type (ADT)
Implementation independent of interfaces
Encapsulation
A design technique that calls for hiding implementation details while providing an interface (methods) for data access
Allows us to code without having to know its implementation
Change the internals all you want, but just keep the interface constant
Interfaces
Allows us to express an ADT
Provides abstract methods
Defines an IS-A relationship
Class
Blueprint for an object
a.compareTo(b) returns?
Negative if a < b
0 if a == b
Positive if a > b
Inheritance
The process by which one new class, called the derived class (subclass/child class), is created from another class, called the base class (superclass/parent class)
extends
Specifies that a class is a derived class of another class
super()
refers to the parent class object calls the constructor of the parent class Must be the first line in the child class' constructor
Overriding
A derived class redefines existing methods of the parent class
Overloading
When two or more methods have the same name but different parameters
this
refers to the current object
Protected
a class element that is only accessible to any derived class or any class in the same package
Early (static) binding
method that is called depends on the declared type of the referring variable, and not the object’s actual type
Late (dynamic) binding
method that is called depends on an object’s actual type, and not the declared type of the referring variable
Does java use early or late binding
Late binding
Polymorphism
When a single reference variable refers to objects of many different types
Upcasting
Casting a reference to a parent class This is done automatically and is always safe
Downcasting
casting a reference to a child class May not be legal depending on the actual object type You can force it by performing an explicit cast
What does a ClassCastException mean?
Illegal downcasting occurred
what is the stack
makes possible method execution
makes recursion possible
what is the heap
where objects are created