Q)What is an abstract class?
=>If "abstract" keyword is applied to a class, it becomes an abstract method.
For eg.
abstract class Vehicle{
}
=>An abstract class can have zero or more abstarct methods.
=>An abstract class can have non abstract methods(concrete methods).
=>Non abstact classes are conceptually known as concrete classes.
=>An abstract class can’t be instantiated.I.e. an object of an abstract class can’t be created.
=>A reference of an abstract can be created.
=>The most generalized class in the hierearchy is generally made abstract.
=>An abstract class is too generalised to be physically realised.
=>If a classs is inheriting from an abstract class, that sub class must override
all the abstract methods of the abstract class.
Interfaces
------------
Q)What is an interface?
=>An interface is a class like construct in Java that contains only abstract methods and
static constants.
=>"interface" keyword is used to create an interface.
For eg.
interface I{
}
=>All the methods of an interface are implicitly public and abstract.
=>All the constants of an interface are implicitly public,static and final.
For eg.
interface I{
public static final int i=10;
public abstract void m();
}
=>An interface can’t be instantiated.But its reference can be created.
=>A class can inherit from an interface by using "implements" keyword.
For eg.
interface I{
}
class A implements I{
}//sub class of I (implementation class of I)
=>If "abstract" keyword is applied to a class, it becomes an abstract method.
For eg.
abstract class Vehicle{
}
=>An abstract class can have zero or more abstarct methods.
=>An abstract class can have non abstract methods(concrete methods).
=>Non abstact classes are conceptually known as concrete classes.
=>An abstract class can’t be instantiated.I.e. an object of an abstract class can’t be created.
=>A reference of an abstract can be created.
=>The most generalized class in the hierearchy is generally made abstract.
=>An abstract class is too generalised to be physically realised.
=>If a classs is inheriting from an abstract class, that sub class must override
all the abstract methods of the abstract class.
Interfaces
------------
Q)What is an interface?
=>An interface is a class like construct in Java that contains only abstract methods and
static constants.
=>"interface" keyword is used to create an interface.
For eg.
interface I{
}
=>All the methods of an interface are implicitly public and abstract.
=>All the constants of an interface are implicitly public,static and final.
For eg.
interface I{
public static final int i=10;
public abstract void m();
}
=>An interface can’t be instantiated.But its reference can be created.
=>A class can inherit from an interface by using "implements" keyword.
For eg.
interface I{
}
class A implements I{
}//sub class of I (implementation class of I)