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 method overloading in java ?

733


How static variable work in java?

798


what is the difference between a threads start() and run() methods? : Java thread

741


What is variable argument in java?

749


How do you do descending order in java?

728


Define a package.

748


What is the meaning of flag day?

722


What are different types of states exist for a thread?

762


What are class types in java?

778


How do you identify if jvm is 32-bit or 64-bit from java program?

710


How do you achieve polymorphism in java?

701


Name few java util classes introduced with java 8 ?

690


What is parsing a string?

797


What are namespaces in java?

713


Is string pool garbage collected?

746