How access Instance Variable of super class in sub class Method()
807600Sep 4 2007 — edited Sep 5 2007i am using two classes in which the super class consists of instance variable and i want that instance variable to be access in the subclass method.....
example:
class Figure
{
double length;
double breadth;
}
class Rectangle extends Figure
{
Rectangle()
{
super();
}
double area() // i want to acess this method.......
{
return(length * breadth);
}
}
class FigureDemo
{
public static void main(String[] args)
{
Figure f = new Rectangle();
f.length = 10.0;
f.breadth = 10.0;
f.area();
System.out.println("Area of Rectanle is"+ f.area());
}
}
Note: I want to excute the same code return in the Main method.
How to can i access super class instance variable in sub class method.. please help out on this........
Thanks & regards,
Ravi