Friday, 20 December 2013

Unknown

Java interface versus abstract class


An interface differs from an abstract class because an interface is not a class. An interface is essentially a type that can be satisfied by any class that implements the interface.
Any class that implements an interface must satisfy 2 conditions:
  • It must have the phrase "implements Interface_Name" at the beginning of the class definiton.
  • It must implement all of the method headings listed in the interface definition.
This is what an interface called "Dog" would look like:
public interface Dog
{
 public boolean Barks();

 public boolean isGoldenRetriever();
}
Now, if a class were to implement this interface, this is what it would look like:
public class SomeClass implements Dog
{
 public boolean Barks{
 // method definition here
 }

 public boolean isGoldenRetriever{
 // method definition here
 }
}

Now that we know the basics of interfaces and abstract classes, let’s get to the heart of the question and explore the differences between the two. Here are the three major differences: 

Unknown

About Blog No Baap -

Since 2016 BlogNoBaap has been bringing you the very best in all types of web resources. Posted daily, and delivered straight to your inbox each morning.

Subscribe to this Blog via Email :