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

Answer Posted / anshul verma

* Major diffrence :- Interfaces are fully implementation of
abstraction

Abstract classes are Partially implementation of abstraction

that's a very important diffrence....

and

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 ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which is better stringbuilder or stringbuffer?

533


Why main method is static in java?

600


What is difference between static class and singleton pattern?

484


What is autoboxing in java?

618


How do generics work in java?

526






What are the differences between path and classpath variables?

511


What is the importance of main method in Java?

579


Why do we override tostring method in java?

519


Java is Pass by Value or Pass by Reference?

624


What does nextint () do in java?

559


Is it possible to compare various strings with the help of == operator? What are the risks involved?

632


What are the procedures?

618


Why are variables important in research?

560


What is a substitution variable?

571


What is the purpose of sizeof operator?

540