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 the difference between length and length() method in java?
Is java hard to learn?
What is a boolean structure?
What do you understand by synchronization?
What are thread local variables?
How do you pass by reference?
What is the meaning of 3 dots in java?
Can singleton class be serialized?
Can we define static methods inside interface?
How can we make string upper case or lower case?
What does singleton class mean?
How to sort list of list in java?
What is pre increment and post increment in java?
Can we override the private methods?
What is jdbc api?