Interface vs. an abstract class

Interface vs Abstract Class.

InterfaceAbstract Class
Interface can have only abstract methods.Abstract class can have abstract and non-abstract methods.
Supports multiple inheritance.Does not support multiple inheritance.
The 'interface' keyword is used to declare interface.The 'abstract' keyword is used to declare abstract class.
Cannot provide the implementation of abstract class.Can provide the implementation of interface.
It cannot have static methods, main method or constructor.It can have static methods, main method and constructor.
It has only static and final variables.It can have final, non-final, static and non-static variables.
Code is not allowed.Contains the code in method bodies.
Example:
public interface Drawable
{
   void draw();
}
Example:
public abstract class GraphicObject
{
   abstract void draw();
}
Synchronized block vs. synchronized method
Synchronized block vs. synchronized method - Synchronized block is better since it places locks for shorter periods than synchronized methods.....
Explain how to force garbage collection
Explain how to force garbage collection - Garbage collection can't be forced, it can explicitly be called using System.gc(), but there is not guarantee....
Difference between the methods sleep() and wait()
Difference between the methods sleep() and wait() - wait() is defined in the class Object and sleep() is defined in the class Thread...
Post your comment