Difference between interface and abstract class with ex.
Answer Posted / vinoth sing
abstract class contain both abstract and non abstract methods
vs
interface can have only abstract methods.
a class implementing a interface itself a abstract class.
eg for interface
interface shape2d
{
double getArea();
}
class circle implements shape2d
{
int radius;
public double getArea()
{
return math.pi*r*r;
}
circle(int radius)
{
this.radius=radius;
}
class circledemo
{
public static void main (string args[])
{
circle c= new circle(10);
system.out.println(c.getArea());
}
}
Is This Answer Correct ? | 4 Yes | 1 No |
Post New Answer View All Answers
Explain the difference between private, public, package and protected in java?
What is defined as false sharing in the context of multithreading?
What is object of class in java?
What is data type modifier?
What is java virtual machine and how it is considered in context of java’s platform independent feature?
How can I become a good programmer?
How many wrapper classes are there in java?
How the interruptible method gets implemented?
What is meant by string is immutable?
What are the principle concepts of oops?
What are the concepts of 'OOPS'?
Can a static block throw exception?
How do I get 64 bit java?
What is * argv?
Give an example of use of pointers in java class.