Note that there are some explanatory texts on larger screens.

plurals
  1. POWhen to only abstract class but not interface
    primarykey
    data
    text
    <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/1221512/when-to-use-abstract-class-or-interface">When to use abstract class or interface?</a> </p> </blockquote> <p>I know about abstract classes and interfaces. But I wish to know a real time scenario in which we need to use only abstract class but not interface and only interface but not an abstract class.. Can any one suggest me some example like that.</p> <p>I guess the second one is used when multiple inheritance need arises i.e. A class is already inheriting some class and so we cant use an abstract class here .. We need to use only interface. In the same way I need an example In which we use only abstract but not interface.</p> <p>EDITED</p> <p>Just to add some more points for interface.</p> <p>Consider the java library collections</p> <pre><code> Collections List Set </code></pre> <p>All 3 are interfaces but the major thing , though they have functions which are common that is add , addAll, contains,containsAll etc. List implements in its own and set implements in another way ( telling about duplication ). Set does not allow duplicates list allows duplicates. </p> <p>So what I am trying to say is when ever there is no common features for sub-interface of super-interface we have to go for interface</p> <p>But if there is some common functionality which both has then keep it as to be abstract class. </p> <p>I need a practical example done in java api. Thanks. Sindhu</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload