Abstract class
It cannot create any concrete objects and usually has one or more empty abstract methods
Unique characteristic of abstract class
Abstract method
no body, no curly braces, no method statements
Subclass of abstract class
inherits abstract method from parent
- the subclass will code to override empty superclass method
Dynamic Method Binding
Every subclass object “is a” superclass member
- it converts subclass objects into superclass objects
A.k.a. late binding; the ability to select correct subclass method to make programs flexible
Dynamic Method Binding
Using Superclass as a Parameter Type
Using the superclass as method argument
Arrays of Subclass Objects
Create array of different objects but share the same ancestry. This is to reserve memory for multiple object references.
Using Object Class
Every Java class is an extension of Object class
* imported automatically
* includes method to use or override
Creates and returns a copy of this object
Object clone()
Indicates if an object is equal to the parameter object
boolean equals(Object obj)
garbage collector on an object when there are no more references to the object
void finalize()
Returns the class to which this object belongs in runtime
Class<?> getClass()
returns the hash code value for the object
int hashCode()
wakes a single thread that is waiting on this object’s monitor
void notify()
wakes all threads that are waiting on this object’s monitor
void notifyAll()
Returns a string representation of the object
String toString()
causes current thread to wait until either another thread invokes notify() ot the notifyAll() method, or a specified amoint of time has passed
void wait(long timeout)
causes to current thread to wait until another thread invokes notify() or notifyAll() or other thread interrupts the current thread, or a certain amount of real time has elapsed
void wait(long timeout, int nanos)
Converts an Object into String, and it contains information about the Object
toString() method
Output of toString() method
It displays some or all data field values for object and can be very useful when debugging
Overloaded version of toString() method
it returns a boolean value that indicates whether objects are equal or have the smae hash code
equals() method
It returns integer representing the hash code and when equals() is overriden, it is overriden too.
hashCode()