Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

How do you stop a thread in java?

1111


What does the ‘static’ keyword mean? Is it possible to override private or static method in java?

1033


Explain what access modifiers can be used for variables?

1107


Write a function for palindrome and factorial and explain?

1138


which pattern is default in scanner package?

2267


What is the purpose of the System class?

1040


Can singleton class be inherited in java?

1058


Is void a return type?

1017


how to know the total memory occupied by the objects in the ArrayList(Array list may contain duplicate objects)

2389


What is the difference between inheritance and encapsulation?

1197


What is a generic code?

1127


What are the advantages and disadvantages of object cloning?

1162


Why runnable interface is used in java?

1192


What is the access scope of a protected method?

1076


What does provide mean construction?

1154