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
What is difference between this and super keyword?
What does the string method compareto () do?
Can a final method be overloaded?
Differentiate storage classes on the basis of their scope?
What is the purpose of using javap?
What are the steps in the jdbc connection?
Difference between java and javascript
What are methods?
What is the purpose of main function in java?
What is the difference between dom and sax parser in java?
When should I use singleton?
What is string and example?
What is a treeset class?
How do you override a private method in java?
What is __ init __ functions?