Posts

Showing posts from July, 2010

When to User Interface and When Abstract Class

This discussion is very common , when to use interface and when to use Abstract Class. Before deciding we should know properties of Abstract Class and Interface in details ::Abstract Class:: It contains both abstract methods and non abstract methods Classes Extend Abstract Class Abstract Classes cannot be instantiated. Abstract can't be declared with Final Synchronised Native. It can have static and instance initialise block. Abstract Class has constructor. Abstract Class may not contain any method(any abstract method) ::Interfaces:: Interface contains all abstract methods. Classes implements Interface. all methods compulsory implemented by particular class which implement interface. Interface variables are implicitly public static and final. Interface variables are constants that cannot be overridden. They are inherited by any class that implements an interface. Interface may not contain any method(Marker Interface). Interface does not contain Constructor. I