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