What is the difference between abstract class and interface?

Answer Posted / ranganathkini

An interface is purely contractual in that it only defines
method headers but no implementation. Classes that implement
the interface must provide implementation to all method
defined by the interface.

An abstract class contains partial implementation, i.e. it
provides implementation for some methods where as just
defines abstract method headers for other. Abstract classes
cannot be instantiated directly and have to be extended by
subclasses who implement the abstract methods defined in the
abstract superclass. Unlike an interface, subclasses of the
abstract class only need to implement only those methods
that are marked abstract.

Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the purpose class.forname method?

560


How is a structure different from array ?

582


Can we override a variable in java?

547


Difference between java and javascript

586


what are the disadvantages of indexes in oracle?

1865






What is data movement?

661


What is the basic concept of java?

539


How does java pattern compile work?

546


How we can generate random numbers in java?

610


What are constructors in java?

572


Can we convert stringbuffer to string?

563


Explain about complier design(phases)

628


What purpose do the keywords final, finally, and finalize fulfill?

612


Explain about wait() method?

568


How to read and write image from a file ?

561