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
Is array serializable java?
Why string is immutable or final in java
What is a byte array?
Can you override static methods?
What is java used for?
How does hashmap work in java ?
What are the types of arrays in java?
What is thread safe java?
What is difference between fileinputstream and filereader in java?
What is the default value of local and global variables?
Where are register variables stored?
What is the difference between this() and super() in java?
Difference between this() and super() in java ?
What is the latest java version?
what are the states associated in the thread? : Java thread