Home Answers Viewqa Java-Interview-Questions Why does Java provide both abstract class as well as interface

 
 


Anil
Why does Java provide both abstract class as well as interface
2 Answer(s)      2 years and 4 months ago
Posted in : Java Interview Questions

why does java have both abstract class as well as interface? what is the need or importance of having both?

View Answers

January 7, 2011 at 5:40 PM


Hi Friend,

They both have some unique features.

An interface is used in situations when a class needs to extend an other class apart from the abstract class. In such situations it is not possible to have multiple inheritance of classes. An interface on the other hand can be used when it is required to implement one or more interfaces. Abstract class does not support Multiple Inheritance whereas an Interface supports multiple Inheritance.

Abstract classes are used when you do intend to create a concrete class, but want to make sure that there is some common state in all the subclasses or a possible common implementation for some operations. Interfaces cannot contain either.

Thanks


October 8, 2012 at 10:13 PM


we use interface in case of multiple inheritance. if an interface contains 100 methods and we want to implements its only two or three methods at that time we make an abstract class and implements that interface in that class and we are able to use only required methods or our needs









Related Pages:
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
abstract class and interface - Java Beginners
() { System.out.println ("Moo! Moo!"); } } Why not declare an abstract class as an interface...? when should we use an abstract class? when should we use interface instead of abstract class?   Hi friend, Abstract classes In java
Abstract and Interface
Interface and Abstract Class 1)Main difference is methods of a Java interface... declared in a Java interface is by default final. An abstract class may contain non... extend another Java interface only, an abstract class can extend another Java
Uses of abstract class & interface - Java Beginners
to java. I knew the basic concepts of interface and the abstract class. But i dont... my doubt Thank you  Hi Friend, Interface: Java does... that extends the abstract class has to provide the implementation to the abstract
why we use abstract class in java?
why we use abstract class in java?  what is the the purpose of abstract class.Give example when to use abstract and when use interface
Interface Vs Abstract Class
Interface Vs Abstract Class      ..., an interface is equivalent to a fully abstract class (a class with only public abstract... need to use an abstract class, because they provide more design flexibility
Marker Interface,Java Marker Interface
; and "Why use Marker Interface?" and "difference between abstract...    Interface    Abstract Class.... Abstract classes may contain both instance as well as static variables
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
Interface and Abstract class
Interface and Abstract class  hello,, Can some body tell me what is the difference between an Interface and an Abstract class?   hi, Very... public members whereas an abstract class can contain private as well as protected
Interface and Abstract class
and Abstract Class 1)Main difference is methods of a Java interface are implicitly...)Members of a Java interface are public by default. A Java abstract class can have... interface should be implemented using keyword 'implements'; A Java abstract class should
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... and implements its methods (which are declared in interface) int the class. interface Ex
Interface in Java
; and "Why to use Marker Interface?" and "difference between abstract...; Features    Interface    Abstract Class... and static. Abstract classes may contain both instance as well as static
Abstract class and Interface - Java Magazine
Abstract class and Interface  Dear Sir, Please anyone help me........I wane exact difference between Abstract class and Interface.what... abstract class AbstractExample { public AbstractExample(){ System.out.println
abstract class
abstract class  what is abstract class .why we use it or what is the need of this class?   Abstract class is like base class which... the following links: http://www.roseindia.net/help/java/a/java-abstract-class.shtml
Why Abstract Class?
Why Abstract Class?  What is the use of Abstract Class if it has Zero Abstract methods
Why Abstract Class?
Why Abstract Class?  What is the use of Abstract Class if it has Zero Abstract methods
abstract class and overriding - Java Beginners
abstract class and overriding? Interface? Give some example program?   Hi friend, Abstract class : In java programming language, abstract classes..._value(); } } Difference between abstract class and interface
Interface vs abstract class
Interface vs abstract class  Hai, Is there any possible to defining abstract methods in Interface
Java Abstract Class
Java Abstract Class       An abstract class is a class that is declared by using the abstract keyword...;  --or-- Java provides a special type of class called an abstract class
Java Abstract Class Example
Java Abstract Class Example In this section we will read about the Abstract class. Abstract class in Java is a class which is created for abstracting the behaviour of classes from the outside environment. Abstract class can be created
Abstract class - Java Beginners
Abstract class  Why can use abstract class in java.?when abstract class use in java.plz Explain with program.   abstract class abs{ public void display(){ } public abstract void display1(); } public class win
Using Abstract Class
Using Abstract Class          We does not make a object of the abstract class. This class must be inherited. Unlike interface the abstract class may
Abstract class,Abstract methods and classes
(); Abstract Class In java programming language, abstract classes... so many times the word abstract. In java programming language the word abstract... that have the empty implementation. All the methods in any interface are abstract
The abstract Keyword : Java Glossary
the methods without implementations.  Abstract class in java have abstract.... In java program abstract class is deliberately missing similar to like an interface which will missing all method bodies in the program. Abstract class
What is Abstract classes in Java?
. That's why the Abstract class in Java programming language is used to provide...What is Abstract classes in Java?  What is Abstrack class in Java... visit Abstract class in Java
Java Inheritance and abstract - Java Interview Questions
abstract class or interface. Because both provides the abstract method. Thank...Java Inheritance and abstract  1) Why we need to write the separate Interface in which we are not doing any operation except declaring empty abstract
Class or Interface
Java NotesClass or Interface Declare variables as class or interface type.... Why change the underlying class? The two List classes, ArrayList and LinkedList both implement the same List interface methods and can be manipulated
Interfaces and Abstract Classes - Development process
Interface and Abstract Classes?  Hi Friend, Interface: Java does.... It relate classes from different types of hierarchy. Abstract Class: Any class that extends the abstract class has to provide the implementation to the abstract
Real Time Example Interface and Abstract Class - Java Beginners
Real Time Example Interface and Abstract Class  Hi Friends, can u give me Real Time example for interface and abstract class.(With Banking Example
Abstract Class in Java
Abstract class in Java is a class that is declared using abstract keyword. It cannot be instantiated but can be extended into subclass. Abstract class cannot... abstract as well. All abstract methods must be public. When an abstract class
Abstract Classes - Java Interview Questions
Abstract Classes  Why we cann't instantiate a Abstract Classes? Even if an Abstract Class does not have any abstract methods, but declaring the class as abstract prevents it from creating an instance. Why? Thanks in Advance
abstract class
abstract class   Explain the concept of abstract class and it?s use with a sample program.   Java Abstract Class An abstract class is a class that is declared by using the abstract keyword. It may or may not have
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... extending interface. Why use interface in java? We use itto achieve complete
Abstract class
Abstract class  j   An Abstract class is a base class which...://www.roseindia.net/help/java/a/java-abstract-class.shtml http://www.roseindia.net/java/master-java/abstract-class.shtml
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
; Through interface, we can achieve the multiple inheritance. Java does... it will take.It creates complexity.Therefore java does not support it directly...interface  What is the exact use of interface in real time scenario
Java Interface
class. It is saved with the .java extension. Inside an interface we can't... Java Interface In this section we will discuss about the interface in Java... extends the other interface. 3. How a class can implement one or more than one
What are the difference between abstract class and interface?
What are the difference between abstract class and interface?  What are the difference between abstract class and interface
why java does not support multiple inheritance - Java Beginners
why java does not support multiple inheritance  hello friend, i... then why we can not extends multiple classes in a single class, eventhough...().show1(1,2); new A4().show1(3); } }  Hi Friend, Java does
Java abstract class
Java abstract class  Can an abstract class be final
Interface in JSP
the methods are abstract. There is no code associated with an interface. In an interface all the instance methods are public and abstract. Interfaces are always implemented in the class. They provide extra behaviors to the class
Why does Java not support operator overloading?
Why does Java not support operator overloading?  Hi, Why does Java not support operator overloading? thanks
abstract class - Java Beginners
abstract class  what exactly is abstract class and in which cases its..., In java programming language, abstract classes are those that works only... inherited from the abstract class (base class). Abstract classes
EJB, Enterprise java bean- Why EJB (Enterprise Java Beans)?
Why EJB (Enterprise Java Beans)?        Enterprise Java Beans or EJB for short is the server-side component architecture for the Java 2 Platform
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
Abstract and Interface
Abstract and Interface  what is the difference between Abstract and Interface accurateatly
Interface - Java Interview Questions
Interface  Respected sir why we use Interface in java? because we have abstract class for do same work.  Hi Anwer, When you define... can still mark the class as abstract. Developing by interface helps in object
abstract class - Java Interview Questions
abstract class  Explain the abstract class and abstract method...://www.roseindia.net/java/master-java/abstract-class.shtml http://www.roseindia.net/help/java/a/java-abstract-class.shtml Hope that it will be helpful for you. Thanks
The interface keyword
to implement an interface by a class. Interfaces in java are abstract means they can.... An interface in java includes only abstract methods i.e. methods have signatures...). An abstract type in java defines that it must be implemented by any class to make
Java-Abstract Class - Java Beginners
Java-Abstract Class  Can a abstract class have a constructor ?When would the constructor in the abstract class be called ? Please give me with good...; Hi Friend, Yes. But Abstract class constructors will be called when its

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.