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
I want to print “hello” even before main is executed. How will you acheive that?
Is void a data type?
Is empty .java file name a valid source file name?
What are internal and external variables?
what is thread? What are the high-level thread states? : Java thread
What are the differences between getting and load method?
What is a Presistent Object?
What is difference between static class and normal class?
What do you understand by access specifiers in Java?
What is the use of set in java?
Why java is not 100% object-oriented?
What are 4 pillers of object orinted programming?
What are the java ide’s?
When can we say that threads are not lightweight process in java?
what invokes a threads run() method? : Java thread