Free Java Programs
A program with multiple classes in Java
import java.io.*;
Class Room
{
float length;
float breadth;
void getdata(float a,float b)
{
length=a;
breadth=b;
}
}
class RoomArea
{
public static void main(String args[])
{
float area;
Room room1=new Room(); //creates an object room1
room1.getdata(14,10);
area=room1.length*room1.breadth;
system.out.println(“Area=”+area);
}
}
Output is:
Area=140
A program with multiple classes in Java
import java.io.*;
Class Room
{
float length;
float breadth;
void getdata(float a,float b)
{
length=a;
breadth=b;
}
}
class RoomArea
{
public static void main(String args[])
{
float area;
Room room1=new Room(); //creates an object room1
room1.getdata(14,10);
area=room1.length*room1.breadth;
system.out.println(“Area=”+area);
}
}
Output is:
Area=140