Difference between abstract class and interface

Answer Posted / s.arun

Main difference is methods of a Java interface are implicitly abstract and cannot have implementations. A Java abstract class can have instance methods that implements a default behavior.
Variables declared in a Java interface is by default final. An abstract class may contain non-final variables.
Members of a Java interface are public by default. A Java abstract class can have the usual flavors of class members like private, protected, etc..
Java interface should be implemented using keyword “implements”; A Java abstract class should be extended using keyword “extends”.
An interface can extend another Java interface only, an abstract class can extend another Java class and implement multiple Java interfaces.
A Java class can implement multiple interfaces but it can extend only one abstract class.
Interface is absolutely abstract and cannot be instantiated; A Java abstract class also cannot be instantiated, but can be invoked if a main() exists.
In comparison with java abstract classes, java interfaces are slow as it requires extra indirection.
For m ore detail click on http://edugoing.com/qna/index.php?qa=1&qa_1=what-the-difference-between-an-interface-and-abstract-class

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain about clr?

588


Explain about microsoft visual studio?

556


What is textview control of .net mobile? : Microsoft dot net mobile

494


Can you explain control extenders?

526


4. Wcf- what Asych and Sych call and how that works

1447






How to implement the display in the class printdoc (how to resolve the naming conflict) a: no naming conflicts

620


What is the use of web.config?

612


what are the fundamental and common properties of .net controls?

1606


Explain the race around condition? : Dot net architecture

484


I am working with asp.net 2005 and Crystal report 10. I have an image field on my dataset to show on Crystal report.And the image is shows dynamically from database in image field of CR. The image field is showing well on my Crystal report on its first page with all other data but when i click to open second page of CR,it does not show any data on that.I found that this is because of adding the image field on crystal report. Because when i remove the image field from the CR then it will run both the pages of CR. I am using the Page Load event to bind CR data with Database. And i have already check with the Init event to bind CR , but it still not shows the data on second page when i use image field on that. Please give solution for that.....

1475


What is .net mobile input validation. : Microsoft dot net mobile

530


Explain different pipelining hazards and how are they eliminated? : .NET Architecture

511


Explain the purpose of cache? How is it used? : .NET Architecture

548


deference between display and visibility property of CSS

1789


What is a clickonce application?

516