File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes What is the difference between Abstrace Class and Interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "What is the difference between Abstrace Class and Interface" Watch "What is the difference between Abstrace Class and Interface" New topic
Author

What is the difference between Abstrace Class and Interface

Dudekonda Sudhakara
Greenhorn

Joined: Jan 17, 2013
Posts: 1
public abstract class A {

public void add(int a, int b);
}


//interface

public interface B{
public void add(int a, int b);
}

My question is java provides abstract class as well as interface, then what is the main difference b/w these two.
It's MNC interview question.

I gave him answers like elimination duplicate code, access restriction but still he was expecting something else.

please provide me an answer.

Thanks in advance.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13875
    
  10

Welcome to the Ranch!

The question "what is the difference between an abstract class and an interface" is asked regularly here. We have a FAQ page about it: Interface vs Abstract Class


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: What is the difference between Abstrace Class and Interface
 
Similar Threads
which one is called abstract or interface.....?
which method is called?
difference bet. abstract class and interface
difference bet. abstract class and interface
Difference between abstract and interfaces