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 OOP Language?
Why we used vector class?
Can bool be null?
Can we extend immutable class?
How do you identify independent and dependent variables?
Can we execute java program without main method?
What does sprintf return?
What is java thread dump, how can we get java thread dump of a program?
What is anti pattern in cyber security?
We are seeing so many videos/audios as many web sited. But question is these videos or audios are stored in Databases ( Oracle, Mysql, Sybase,... ) or stored any file directory from there they will give the link for that? Pls explain and give sample code to achieve this one? Thanks, Seenu.
Do you know how to reverse string in java?
What are the kinds of polymorphism?
How to stop a thread in java? Explain about sleep () method in a thread?
Can we rethrow the same exception from catch handler?
What is the final keyword denotes?