Sunday, 20 March 2016

Objects



class box
{
double w,h,b;
void get()
{
w= 12;
h=6;
b=4;
}
void print()
{
System.out.println("Width ="+w+"\n");
System.out.println("height="+h+"\n");
System.out.println("breadth="+b+"\n");
}
}
class boxdemo
{
 public static void main(String args[])
 {
box b = new box();
b.get();
b.print();
}
}

OUTPUT


H:\>cd java

H:\Java>path=C:\jdk1.3\bin;

H:\Java>javac boxdemo.java

H:\Java>java boxdemo
Width =12.0

height=6.0

breadth=4.0

No comments:

Post a Comment