Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Oscar Montgomery   on Jan 23 In Java Category.

  
Question Answered By: Julia Flores   on Jan 23

The following statement is not true:

"As super  classes provide abstract  methods only"

Super classes  can include implementation code as well as abstract
methods. You may be referring to interfaces so I will respond as such.
Interfaces let you define a contract which the implementing  class is
guaranteed to implement. As an example, let's say there is an interface
Storable with a single method store() and two classes Person and
Product. If both Person and Product implement Storable then you can
have a method such as the save method below and both Person and Product
instances can be passed to this method.

public void save(Storable s) {
s.store();
}

In the method you could then call the Storable.store() method as shown
in the example above and each object can implement the store()
functionality in whatever manner it wants. This is just one of the many
uses of interfaces.

Share: 

 
 
Didn't find what you were looking for? Find more on Java Inheritance Or get search suggestion and latest updates.


Tagged: