One of hundreds of answers available with our premium content service.
A: An example of inheritance using the extends keyword would be the java.util.Stack class that extends the Vector class to provide a last-in-first-out stack of Objects. The Stack class uses the same underlying storage facilities provided by the superclass and adds its own, so it “is a” type of Vector and behaves like a specialised “wrapper” around the Vector class. The Stack class adds a boolean empty() method, peek(), pop() and push() methods to manage the stack contents and a search() method to find the index of a given object. All the original methods of the Vector class remain and the Stack can be cast to a Vector as necessary.
… full answer hidden
Premium members click below for full answer
Can you show examples of Java inheritance?
Your premium content subscription is a single payment that gives you: