Hi All,
The following code is not compiling and the message that I am getting is that "incompatible types" ie at Line 1
"String str = se.doStuff(); //////Line 1"
If am right the object reference "se" should be invoking the method in Class "Second"
I now Iam missing something here, please explain
Thanks in advance
/******************* CODE *******************************/
class Second extends First{
public static void main(
String[] args){
First se = new Second();
String str = se.doStuff(); //////Line 1
System.out.println("Printing from main :" + str);
}
public String doStuff(){
System.out.println("Derived");
return new String("Derived");
}
}//close class second
class First {
public Object doStuff(){
System.out.println("Base");
return new String("Base");
}//close doStuff
}//close class First