0% found this document useful (0 votes)
4 views4 pages

Practical 09 Java

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

Practical 09 Java

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Shri Vile Parle Kelavani Mandal's

INSTITUTE OF TECHNOLOGY
DHULE (M.S.)
DEPARMENT OF COMPUTER ENGINEERING
Remark
Subject :JAVA Programming LAB

Name : Juhi Anilkumar Kursija Roll No. : 67

Class :[Link] Batch : S3 Division: B


Signature
Expt. No. :09 Date : 13-11-2025
Title : Write a Java program to demonstrate Interfaces, block initializers, final
Modifier, as well as static and dynamic binding.

Code:
interface Shape
{
void draw();
void area();
}

interface Colorable
{
void setColor(String color);
}

class Circle implements Shape, Colorable


{
double radius;
String color;
Circle(double radius)
{
[Link] = radius;
}
public void draw()
{
[Link]("Drawing a Circle");
}
public void area()
{
double area = 3.1416 * radius * radius;
[Link]("Circle area: " + area);
}

public void setColor(String color)


{
[Link] = color;
[Link]("Circle color set to " + color);
}
}

class Square implements Shape, Colorable


{
double side;
String color;

Square(double side)
{
[Link]=side;
}
public void draw()
{
[Link]("Drawing a square");
}
public void area()
{
double area = side*side;
[Link]("Square area: " + area);
}

public void setColor(String color)


{
[Link] = color;
[Link]("Square color set to " + color);
}
}

public class ShapeInterface


{
public static void main(String[] args)
{
Circle c = new Circle(5);
[Link]();
[Link]();
[Link]("Red");

[Link]();

Square s = new Square( 6);


[Link]();
[Link]();
[Link]("Blue");

}
}
Output:

You might also like