Exforsys
+ Reply to Thread
Results 1 to 6 of 6

Difference between Interface and Abstract Class

This is a discussion on Difference between Interface and Abstract Class within the Java forums, part of the Programming Talk category; What is exact difference between Interface And Abstract Class ? Where exactly these Interface are useful in realtime scenario....

  1. #1
    Aditya.ark is offline Junior Member Array
    Join Date
    Oct 2007
    Answers
    1

    Difference between Interface and Abstract Class

    What is exact difference between Interface And Abstract Class ? Where exactly these Interface are useful in realtime scenario.


  2. #2
    karthigayini is offline Junior Member Array
    Join Date
    Sep 2007
    Answers
    2
    an abstract class is just a outline of the entire class. u can have only method name inside it. u can't create objects for them. a abstract class should always be inherited. where as a inteface is a collection or a group of empty methods.

    Last edited by karthigayini; 10-29-2007 at 04:47 AM.

  3. #3
    adarshshukla is offline Junior Member Array
    Join Date
    Oct 2007
    Answers
    5
    An abstract class is a class which may or maynot consist of the abstract methods while an interface must have all the functions as abstract.

    the abstract class with all the functions as abstract must be defined as an interface.


  4. #4
    vickyas400 is offline Junior Member Array
    Join Date
    Nov 2007
    Answers
    7

    Abstract class vs interface

    Abstract class can (or not ) have methods in it and it has no use in instantiating it since it has no meaning in instantiation.
    It has to be inherited for use .
    You need to INHERIT to use an abstract class.
    You can have a variable in Abstract class. ( a silly difference )
    Basically u use an abstract class when you want to provide a generalized form of abstraction and leave the implementation task with the inheriting subclass.

    Interface - group of related methods with empty bodies .
    You need to IMPLEMENT to use an interface.
    I dont think you can have a variable in a interface.
    When you want a few classes to use a few methods which you dont want to be included in the class ,then you go for the interface, which makes it easy to just implement and make use of the methods defined in the interface. But the problem with the interface is that, u have to implement all the methods defined in the interface , even if you dont need some of them.


  5. #5
    sampra is offline Junior Member Array
    Join Date
    Mar 2008
    Location
    bangalore
    Answers
    9
    An abstract class is a class which may or maynot consist of the abstract methods while an interface must have all the functions as abstract.

    the abstract class with all the functions as abstract must be defined as an interface.


  6. #6
    vickyas400 is offline Junior Member Array
    Join Date
    Nov 2007
    Answers
    7

    Hello

    Hello .,.. welcome ./.. .this group seems to be inactive for a long time !! !..


    •    Sponsored Ads



Latest Article

Network Security Risk Assessment and Measurement

Read More...