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

when a request is generated from apache tomcat 5.5 and goes to oracle 10g or mysql,,, how the oracle or mysql reads the request as apache is a web server and oracle 10g is application server? when the oracle 10g provides response, how the apche tomcat reads it???

1891


Is a class an object?

776


How does a cookie work in Servlets?

571


Why is boolean important?

790


How do you clear a method in java?

729


Explain the private field modifier?

839


What kind of variables a class can consist of?

841


How many classes can any class inherit java?

713


Explain yield() method in thread class ?

816


What is object cloning in Java?

841


How to store image in arraylist in java?

704


What are controls and their different types in awt?

825


Is minecraft java edition free?

843


What is the difference between static class and normal class?

734


What is difference between hashset and hashmap in java?

692