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

Answer Posted / priyanjan

The core diffrence between abstract class and interface is
that interface does not allow implementation of method but
abstract class allows.

Interface is a bunch of declaration of relevant functions.
In real time projects, interface can used if we have to
implement any framework.for eg, if want to implement the
framework of stack,we can do it by defining the prototypes
of push(),pop(),peek() methods in an interface and then
implementing it by any class.
Abstract classes is useful when we are not
required to implement all methods in our class.for eg,we
have Vehicle class, we want to implement classes for two
wheelars in which hand brake is given and in some vehicles
foot brake are given, then Vehicle class abstract class can
be defined as abstract class and implemention of brake()
can be done in applicable classes.

Is This Answer Correct ?    84 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between a checked and an unchecked exception?

551


Explain spliterator in java8?

601


What is difference overloading and overriding?

579


What are the 7 types of characters?

566


What is runtime polymorphism or dynamic method dispatch?

524






How many days will it take to learn java?

519


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

544


What are controls and their different types in awt?

606


What is meant by final class?

566


What is the use of volatile in java?

601


Can you call one constructor from another if a class has multiple constructors?

589


What is difference between static and abstract class?

521


Can you give names of Container classes?

1857


What is 16 bits called?

501


When should we create our own custom exception classes?

585