When we r go to abstract class and when we go to Interface?
i have confusion this question while in interview plz clarify
Answer Posted / nani
If we want share some common features with all we can go for
abstract otherwise we can prefer interface .
i will give good example to understand easily.
Ex: wholesaler has books and stationary(pens & papers)
supplier1 ask for X class books and Pens
Supplier2 ask for X class books and papers.
here both suppliers asking same standard books and different
stationary items.suppose we can take it as by methods, here
here books methods are common to shared by both suppliers.so
book method is non abstract class. so here we can prefer
abstract.
supplier1 ask for X class books and Pens
Supplier2 ask for V class books and papers.
here both suppliers asking different standard books and
different stationary items.
Is This Answer Correct ? | 5 Yes | 0 No |
Post New Answer View All Answers
How to restrict a member of a class from inheriting by its sub classes?
Differences between traditional programming language and object oriented programming language?
what is the significance of listiterator in java?
What do you understand by access specifiers in Java?
What are the ways to instantiate the class class?
What is the difference between equals() and == in java?
Does unicode support all languages?
How many unicode characters are there?
How will you initialize an Applet?
Explain about sets?
When do we use synchronized methods in java?
What is the flag in java?
What is the final access modifier in java?
what is instanceof operator used in java?
What is a native method in java programming?