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


Please Help Members By Posting Answers For Below Questions

Explain the difference between runnable and callable interface in java?

834


What is reflexive association?

1380


Tell me the latest versions in java related areas?

857


What do you mean by exception handling in Java?

1013


What are the different types of java?

781


What is locale in java?

805


Why hashset is used in java?

774


Why is singleton instance static?

755


What is predicate in java?

830


What is diamond operator in java?

728


What are three ways in which a thread can enter the waiting state in java programming?

924


What is the use of arrays tostring () in java?

755


What is difference between == and === in js?

806


What is a map? What are the implementations of map?

837


How to sort an array in java without using sort method?

736