Things one has to know about Interfaces in Java

The following article is mainly focused at beginners who are not much familiar to Java. It can also be a quick recap tool for Java Developers.

What are Interfaces?

Interfaces are 100 percent abstract classes i.e it defines only abstract methods and constants. But while an abstract class can define both abstract and non-abstract methods, an interface can have only abstract methods. Interfaces can be implemented by any class from any inheritance tree.

Why do we need Interfaces?

Interfaces help in implementing “Multiple Inheritance” the Java Way. Now what exactly does it mean by “Multiple Inheritance”? The Multiple Inheritance, one in C++, is allowing a particular class to extend/inherit from more than one class. Multiple Inheirtance can be quite messy and lead to deadly situation at times.

Read more

Interface Vs Abstract Class

There are three differences between an interface and an abstract class: you can implement multiple interfaces at the same time, but only extend one class, an abstract class is allowed to contain implementation (non-abstract methods, constructors, instance initializers and instance variables) and non-public members, and abstract classes may be a tiny bit faster (or they … Read more

%d bloggers like this: