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 are the five major types of reference sources?
What does replaceall do in java?
Differece between class and generic class?
What is == mean?
Can a class extends itself in java?
Garbage collection in java?
What are different types of classloaders?
What is the difference between scrollbar and scrollpane?
what do you mean by marker interface in java?
What are the important features of Java 11 release?
What is the destroy method?
Explain about interthread communication and how it takes place in java?
What is the purpose of the finalize() method?
Explain the difference between throw and throws in java?
What is instance means in java?