TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Java - Calculate Area Of Rectangle And Area Of Circle Using Interface
Senthilvelan Sambamoorthy
Aug 21
2016
Code
81.2
k
0
1
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
test7.rar
interface
area
{
double
pi =
3.14
;
double
calc(
double
x,
double
y);
}
class
rect
implements
area
{
public
double
calc(
double
x,
double
y)
{
return
(x*y);
}
}
class
cir
implements
area
{
public
double
calc(
double
x,
double
y)
{
return
(pi*x*x);
}
}
class
test7
{
public
static
void
main(String arg[])
{
rect r =
new
rect();
cir c =
new
cir();
area a;
a = r;
System.out.println(
"\nArea of Rectangle is : "
+a.calc(
10
,
20
));
a = c;
System.out.println(
"\nArea of Circle is : "
+a.calc(
15
,
15
));
}
}
Java
Area Of Rectangie
Area Of Circle
Interface