Hi I am trying to execute this code in Eclipse.
abstract class ShapeNew {
int length;
public abstract double area();
}
class Rect extends Shape{
Rect(int side){
this.length = side;
}
public double area(){
System.out.println("area of rectangle"+ length*length);
return length*length;
}
/**
* @param args
*/
public static class Area{
public static void main(String[] args) {
// TODO Auto-generated method stub
ShapeNew rect = new Rect(32);// I am unable to use this. The eclipse throws an error//
rect.area();
}
}
Can anyone help me with it. Why am I unable to assign a reference of ShapeNew to an object of Rect.? I get this error
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Type mismatch: cannot convert from Rect to ShapeNew