Create 2 classes, Shape and Circle. Have class Circle extend class Shape. Create a static method in class Shape called sayHello() that prints "Nice Form" to the standard output. Declare a method with the same name and signature in class Circle that prints out "Well Rounded" to the standard output. Create a class named Problem1 with a main() method that creates a Circle object and stores its reference in a variable tupe Shape. Invoke sayHello() on the reference to the Circle object.
the code I created from this statement:
publicclass Shape{
publicstaticvoid sayHello(){
System.out.println("nice form");
}
}
publicclass Circle extends Shape{
publicstaticvoid sayHello(){
System.out.println("well rounded");
}
}
publicclass Problem1{
publicstaticvoid main(String arg[]) {
Shape shape;
Circle circle = new Circle();
shape = circle;
shape.sayHello();
}
}
My question is this. does this code satisfy what appears to be asked of me in the statement? Also, given the code, would you expect it to say "nice form" or "well rounded"?
My problem is, I fully expected that the reference to circle (which is 'shape') would retain the overridden method values of sayHello() in Circle. when I run this, the method call still gives the value of the method in the superclass, ("nice form") why is this? does it have something to do with the methods being static? if I should expect the reference to circle via shape to output "well rounded" then what am I doing wrong.
this may actually be the correct answer to the problem I just dont understand what it was getting at.