RE: What are interfaces, abstract classes. What is their purpose and differences ?
By default all methods present in the interfaces are abstract. where as we can provide mthod definition in the abstract class but we cont provide body to a method in the interface. Interfaces provides multiple inheritance in java. abstract classes provides the facility to extend the functionality of a class.
RE: What are interfaces, abstract classes. What is their purpose and differences ?
Interfaces: We can define only methods, no implementation. All methods are abastract. We can define variables, but those shld be constants.
Abstract classes Class which conatains one or more abstarct menthods or class which is marked as abstarct. We can have implementation inside this class. This class in meant to be extended by some other class, subclasses will provide implementation for abastarct methods.
Interfaces are a way of implemention multiple inheretence in java.
RE: What are interfaces, abstract classes. What is the...
Ans:
Abstract Class: Instance can not be created. Optionally can have one or more abstract methods but not necessary. Can provide body to Classes.
Interface: What a Class must do, But not how-to. Bridge for the communication when the caller does not know to whom he is calling. Describes externally visible behavior of element. Only Public members which defines the means of the communication with the outer world. Can-be-Used-As Relationship. Can not contain data but can declare property. There can be no implementation. Interface can be derived from another interface
Difference between Abstract class and interface
In an interface class, all methods are abstract - there is no implementation.In an abstract class some methods can be concrete. In an interface class, no accessibility modifiers are allowed. An abstract class may have accessibility modifiers