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
what are the high-level thread states? : Java thread
What are the types of literals?
What are the differences between c++ and java?
Can we write any code after throw statement?
How many bits are in a sentence?
What are different access specifiers in java? Explain
Explain about anonymous inner classes ?
What is the difference between overriding and overloading in OOPS.
Define reflection.
Why is java so important?
Why do I need to declare the type of a variable in java?
What is a variable in java?
Can a class with private constructor be extended?
Which are different kinds of source code?
How can we make sure main() is the last thread to finish in java program?