CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2005
    Posts
    25

    Post defination of interface,abstract

    I know something about interface, abstract
    But actually I want to know

    When a interviewer ask or in a seminar, in a class,
    1.what is interface?
    2.what is abstract?
    3.what are the definition of interface and abstract in the case of client/server and in core java part
    4.difference is the difference of interface and abstract
    5.why interface
    6.why abstract ETC

    please give me details theory, example, any link etc

    Thanks & Regards
    Manoj

  2. #2
    Join Date
    Jul 2005
    Location
    Ontario, Canada
    Posts
    107

    Re: defination of interface,abstract

    You probably need a good book or a link for this, but here is a summary:

    Interface
    Any class that implements an interface must contain each of the method names in the interface. An interface is simply a list of method names. You use it to enforce the way that the object is referred to. If the interface does not change, the way the object is used will not change even though the class that extends the interface may change.

    Abstract Class
    This class is designed to be extended by another class. You cannot actually make objects of this class.

    Abstract Method
    When a class extends another class with abstract methods, all abstract methods must be re-written.

  3. #3
    Join Date
    Feb 2003
    Location
    Sunny Glasgow!
    Posts
    258

    Re: defination of interface,abstract

    An interface is a collection of methods (doesn't provide the functionality) that any class implementing must use. An interface can be empty (examples are cloneable and serializable). An interface contains a return type and method name of any method, together with any arguments that this must take.

    An abstract class cannot be instantiated (i.e. you can't create an abstract class - "new AbstractClass();" would not be allowed). Abstract classes are used where there are several classes all using a similar features - abstract methods in an abstract class can be empty (left of the concrete class to come up with the functionality), or it can provide functionality - therefore unless any concrete class inheriting from the abstract class overrides the method, they will all use the functionality the abstract class defines.

  4. #4
    Join Date
    Feb 2004
    Location
    USA - Florida
    Posts
    729

    Re: defination of interface,abstract

    An interface is sometimes called an "ultimate abstract class" because it (usually) contains nothing but implicit abstract methods. In general, an interface defines a set of behaviors for class's that implement the interface regardless of where the class is in the inheritance hierarchy. An abstract class defines behaviors for all class's that derive from the abstract class. Abstract class's also sometimes have some implementation code that subclass's can use.
    Hungarian notation, reinterpreted? http://www.joelonsoftware.com/articles/Wrong.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured