what is the difference between abstract class and
Interface?where we can use it in realtime projects?

Answer Posted / abilash

1)If we r having 2 classes, both classes need a method with
same business logic(definition). Then we can go for an
abstract class. In this abstract class we can define the
method with functionality. And the two classes will extend
this abstract class.
2)In other case if two different classes wants two different
functionalities with same method name , then we go for an
interface with abstract declaration of method.And the two
classes will implement the interface and override the method
with different business logic

Is This Answer Correct ?    31 Yes 12 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is static variable with example?

569


Explain the difference between an object-oriented programming language and object-based programming language?

551


Can memory leak happen java?

600


What are java annotations?

652


What are the benefits of operations in java?

495






What classes of exceptions may be caught by a catch clause in java programming?

709


Explain the use of volatile field modifier?

642


What is the difference between call by reference and call by pointer?

507


What is an immutable object?

587


How can we access some class in another class in java?

555


What is not object oriented programming?

513


Is call by reference possible in java?

542


Is hashset sorted in java?

670


What is java lang object?

531


What is java reflection?

541