Question: public class Parent { public void rubyDoo( ) { . . . } . . . public int x = 0; } public class Child
public class Parent
{
public void rubyDoo( )
{ . . . }
. . .
public int x = 0;
}
public class Child extends Parent
{
public void busterStein( )
{ . . . }
. . .
public int x = 39;
}
18. Is the following legal? If not, why not? Child theObj = new Child( ); Parent newObj = theObj; newObj.busterStein( );
19. Is the following legal? If not, why not? Child theObj = new Child( ); Parent newObj = theObj; newObj.rubyDoo( );
20. Is the following legal? If not, why not? Parent meatloaf = new Child( );
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
