can u give one sinario when you use Abstract Class and When
you use Interface.
Answer Posted / srinivasa
If we have more than two classes with same method names but
their implementation is different.we can go for interface.
Example: JDBC API Interfaces. Every data base vender
implements these interfaces with thier implementation code.
If we want to use some common method implementaions for
multiple classes along with their own implementation we can
go for abstract class.
Example:Servlet API:
HttpServlet is an abstract class in which init() is
implemented used by every servlet that extends.Every
servlet implement their own service method.
| Is This Answer Correct ? | 10 Yes | 0 No |
Post New Answer View All Answers
How to use string tokenizer class.
how to create daemon thread in java?
What is exception propagation?
What are advantages of exception handling in java?
whar are the draw backs of programming lang step by step in Clang and next in C++ and next and in Java nad in .Net
Explain the difference between collection api and stream api in java8?
I want to persist data of objects for later use. What is the best approach to do so?
What are anonymous inner classes?
How to do encapsulation in java?
What two classes are used to read data only?
explain autoboxing in java?
How does linkedlist work in java?
What is lambda programming?
Is integer immutable in java?
What are variable arguments or varargs?