Abstract and Interface

Ads
 

Abstract and Interface

what is the difference between Abstract and Interface accurateatly?

View Answers

June 2, 2012 at 6:29 PM

Difference Between Interface and Abstract Class

1)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.

2)Variables declared in a Java interface is by default final. An abstract class may contain non-final variables.

3)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..

4)Java interface should be implemented using keyword 'implements'; A Java abstract class should be extended using keyword 'extends'.

5)An interface can extend another Java interface only, an abstract class can extend another Java class and implement multiple Java interfaces.

6)A Java class can implement multiple interfaces but it can extend only one abstract class.

7)Interface is absolutely abstract and cannot be instantiated; A Java abstract class also cannot be instantiated, but can be invoked if a main() exists.

8)In comparison with java abstract classes, java interfaces are slow as it requires extra indirection.

Ads









Related Tutorials/Questions & Answers:
Abstract and Interface
Abstract and Interface  what is the difference between Abstract and Interface accurateatly
Abstract and Interface
Abstract and Interface  What is interface? When time is most suitable for using interface? Why we use interface instead of abstract? What is the differences between abstract and interface?   An interface defines a set
Advertisements
Interface vs abstract class
Interface vs abstract class  Hai, Is there any possible to defining abstract methods in Interface
Interface and Abstract class
Interface and Abstract class  Difference between Interface and Abstract class? Give some example   Difference Between Interface and Abstract Class 1)Main difference is methods of a Java interface are implicitly
Abstract class and interface in Java
Abstract class and interface in Java  What is the difference between abstract class and interfaces in Java?   Differences between an interface and an abstract class: At the same time multiple interfaces can
Difference between abstract class and an interface
Difference between abstract class and an interface The difference between abstract class and interface is one of the most popular question in the interview... between abstract class and interface in java. Abstract class is a class
where exactly we use interface and where abstract class?
where exactly we use interface and where abstract class?  what is the use of interface over abstract class? and where we should use interface and where abstract class
Why does Java provide both abstract class as well as interface
Why does Java provide both abstract class as well as interface  why does java have both abstract class as well as interface? what is the need or importance of having both
Interface
Interface  I need to implement the interface without overriding its method and also don't use abstract class for this. How to do
interface
interface  what the use of interface?   An interface is one which has abstract methods(not defined just declared)and static or non static variables.Any class can implement(inherit)the interface and make use
Interface in java with example
We are going to discuss about Interface in Java. Interface is blueprint of a class. Interface is a collection of abstract methods. Interface has only... all method in interface abstract and public. Multiple inheritance allows
Interface
and abstract class   interface ShapeInterface{ int l=0,b=0; public...Interface  1.Create an interface names ShapeInterface that has two methods and one constant and an abstract class named ShapeAbstract that has two
Interface
and abstract class   interface ShapeInterface{ int l=0,b=0; public...Interface  1.Create an interface names ShapeInterface that has two methods and one constant and an abstract class named ShapeAbstract that has two
Interface
for Interface in java? and want to know why they used interface instead of multiple inheritance? Thanks in advance   An interface is one which has abstract... implement(inherit)the interface and make use of the methods(functions
interface
interface   what is the use of marking interface
interface.
interface.  Write short note on interface.   Please visit the following link: Java Interface
interface
interface  will the interface implements a interface   Hi Friend, No. Interface can extends another interface but cannot implements it, because interface will not contain the implementation. Thanks
INTERFACE
INTERFACE  how interface support multiple inheritance in java
interface
interface   Hi I have interface in that interface 3 methods are there , after some days client said that,i want to add one more method in that interface ,so how can add 4 method so that the implemented class did not affect
interface
interface  can we extend interface?   Hi Friend, Yes an interface can be extended by other interface like using extends keyword interface A{ } interface B extends A{ } For Example: interface IntefaceA { void
interface
interface  What is marker interface ?? what is its use in java programming?? is this us in programming ??Explain is implementation with code
interface
interface  develop a library interface which has drawbook(),returnbook()(with fine),checkstatus() and reservebook() methods.all the methods tagged with public
interface
interface  develop a library interface which has drawbook(),returnbook()(with fine),checkstatus() and reservebook() methods.all the methods tagged with public
Abstract class
Abstract class  Can an abstract class be final
Abstract class
Abstract class  what is an Abstract class
abstract method
abstract method  is final method is in abstract class
Abstract class,Abstract methods and classes
that have the empty implementation. All the methods in any interface are abstract... Abstract methods and classes     ... so many times the word abstract. In java programming language the word abstract
interface
interface  why do we need interface in java..if it`s usefull for to obtain multiple inheritance in the sense how it gonna be achieved...and i can...)...the y we need interface...THis is question often i heard from my developer
interface
interface  What is the exact use of interface in real time scenario? some people says that interface provides multiple inheritance. Is it true...; Through interface, we can achieve the multiple inheritance. Java does
abstract method
abstract method  Can a concrete class have an abstract method
Interface
Interface  Declare an Interface called property containting a method compute price to compute &return the price.The inerface is to be implemented by follwaing two class (1)Bungalow&(2)Flat both the lasses have following

Ads