A class provides us with two access specifier’s namely
- Private.
- Public.
class Box
{
private double width;
private double height;
private double depth;
private void input()
{
width=10;
height=20;
depth=30;
}
void compute()
{
input();
double vol=width*height*depth;
System.out.println("The volume of the box is : "+vol);
}
}
class App21
{
public static void main(String yck[])
{
Box b1=new Box();
b1.compute();
}
}
output:
\>javac App21.java
\>java App21
The volume of the box is : 6000.0
