Difference between abstract class and interface

Lets discuss differences between an interface and an abstract class in Java,to start with-

An abstract class can have non-abstract method but an interface cannot.

Replies

  • Vishal Sharma
    Vishal Sharma
    interface uses abstract classes
  • Anoop Kumar
    Anoop Kumar
    abstract class :
    1. can have all the methods unimplemented (abstract) like interfaces (useless why not use interfaces)
    2. Generally have some implemented and some of the unimplemented methods so child class can use unimplemented as they want and already implemented methods in abstract class they already present while extending.

    Interfaces:
    1. Main purpose of using interfaces is a contract, between client and developer that what kind of method a class should have. Client does know what an object could do but not the implementation. It's job of developer.
    2.Since interfaces can point to any object of class which have implemented it. In real programming developer always makes reference to interface not the concrete class name.
    Actual purpose of interfaces to provide a structure of a project.

    Rest of syntax tricks, you can Google and exercise it.đŸ˜€

You are reading an archived discussion.

Related Posts

Every signal traveling through a transmission medium gathers noise and as the distance increases so does the noise. Conventional ways to reduce noise are good but what if we can...
Nokia India has revealed on its website that the company's new flagship phone Lumia 925 is 'coming soon'. Unveiled earlier this month, Nokia Lumia 925 is the smartphone with the...
It is with shame and sincere regret that I write here about this topic, particularly with respect to India. I've lived my entire schooling in Kuwait, and there has not...
Samsung recently announced event ‘Premiere 2013’ scheduled for June 20 at Earls Court 2, London, where it’ll be unveiling latest additions to its Galaxy and ATIV portfolio. Tech enthusiasts may...
On VoiCE you have already read about the Black Hornet Nano UAV and Me Cam and how they are being used for military and civilian purposes respectively, but this time...