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

Can we override constructors?

742


What are disadvantages of java?

723


How do you add an element to a set in java?

740


Can we have 2 main methods in java class?

728


What is set string?

762






which pattern is default in scanner package?

1982


What is the purpose of skeleton and stub?

791


How does linkedlist work in java?

685


What is the difference between C++ and Java and your preferences?

816


What is scope & storage allocation of static, local and register variables? Explain with an example.

770


Why do we need hashset in java?

690


What are the pillars of java?

649


Hi all, I am dng a mini project on FileSplitter application which splits the GBs of logfile into Smaller chunks(mbs) depending on the split size." How to handle GBs file? I am getting OutOfMemoryException, when I input such GB sized file. Thx

1806


When is the arraystoreexception thrown?

747


How does arrays sort work in java?

781