1 Reply Latest reply on Jan 21, 2003 8:36 AM by 807549

    What is the difference between Abstract class and Interface ?

    807549
      Hi,


      Could u plz tell me the difference between Abstract class and Interface?


      Thanks in advance.

      Gopi
        • 1. Re: What is the difference between Abstract class and Interface ?
          807549
          Lots.

          An abstract class can contain some method implementations, or indeed all the method implementations. It may contain methods with all the various access modifiers. It cannot be instantiated. A class may inherit from only a single abstract class.

          An interface contains only public method stubs and constants. A class may implement multiple interfaces. An interface cannot (obviously) be instantiated.

          Abstract classes are particularly useful when you need to provide a semi-complete implementation for reuse. Interfaces are used more like types.

          Look at java.util.* for some good examples of the use of both.