Java Interface and Abstract Class?

I am a student in Java, and I am trying to understand the concepts of an Interface and an Abstract Class.

Everywhere I try to read about them, even my textbook, I can't quite understand WHEN you would use them. I have seen a few examples of an Interface - isn't it just a class that includes the shells of methods with no actual commands in them? If that is the case, doesn't that would mean you would never actually NEED to use an Interface?

I also understand an Interface cannot be instantiated, it must be implemented - but what does implementing an interface do?


  • we use interface when something in design will change frequently i.e we can change them in every implementation according our needs.

    Abstract class can have default behavior.i.e code in methods.

    using interface has another advantage i.e. u can implement as many interfaces as u wish but u can't do the same with class(u can extend only one class).

    Interface have all methods as public. u might not wish to expose all the stuff to others thats why Abstract classes are used.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion