class Demo{
double height;
double base;
Demo(double height, double base){
this.height = height;
this.base = base;
}
double area(){
return 0.5*base*height;
}
}
public class Main{
public static void main(String args[]){
Demo dm = new Demo(10.0,5.0);
double res = dm.area();
System.out.println("The area of a Triangle is: " + res);
}
}
Parameterized Constructors
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment