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


Please Help Members By Posting Answers For Below Questions

What is difference between this and super keyword?

517


What does the string method compareto () do?

540


Can a final method be overloaded?

510


Differentiate storage classes on the basis of their scope?

673


What is the purpose of using javap?

618






What are the steps in the jdbc connection?

573


Difference between java and javascript

586


What are methods?

553


What is the purpose of main function in java?

538


What is the difference between dom and sax parser in java?

532


When should I use singleton?

521


What is string and example?

555


What is a treeset class?

560


How do you override a private method in java?

505


What is __ init __ functions?

551