Pick a pair of concrete classes in the JDK in a parent-child relationship and discuss a few polymorphic and/or overloaded methods.
Do not use Object as the parent class - it is too trivial to address the issues to be addressed here, and in any case, Object is the final parent of all classes in Java.
One of the examples of parent child relationship in JDK is given as:
The parent class is AbstractSet.java and it is extended by a lot of child classes. Some of them are given as:
Some of the methods overridden by the child classes are given as:
public Iterator<E> iterator() -> Returns an iterator over the elements in this set. The elements are returned in no particular order.
public int size() -> Returns the number of elements in this set (its cardinality).
public boolean isEmpty() -> Returns true if this set contains no elements.
public boolean contains(Object o) -> Returns true if this set contains the specified element.
Get Answers For Free
Most questions answered within 1 hours.