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

please send me hr interview questions in it industry

1659


Can a top level class be private or protected?

570


What is the size of string?

556


Can we override final method?

567


What are implicit objects in java?

549






Can we define constructor in inner class?

535


How dead lock situation occurs in java and how you can identify it?

540


What is independent and dependent variables in research?

466


What is an argument java?

532


What are serialization and deserialization?

723


What are the limitations of procedural programming approach?

525


does java support pointers?

560


What is predicate in java?

557


What is the difference between synchronized and synchronized block?

499


What are the steps that are followed when two computers connect through tcp?

516