Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

public class BaseClass { // methods of BaseClass } public SomeClass extends Base

ID: 3541647 • Letter: P

Question

public class BaseClass { // methods of BaseClass }

public SomeClass  extends BaseClass

            { // methods of SomeClass }

a.       SomeClass scobj = new SomeClass( );

b.      BaseClass bcobj = scobj;

c.       SomeClass scobj2 = bcobj;

d.      bcobj.aMethodOfSomeClass( ); // does not exist in BaseClass

A.    Is statement b above legal, or is casting required?

B.     Statement c is trying to assign the SomeClass object referred to by bcobj to a SomeClass reference variable scobj2. What is wrong with this statement and how would you fix it.

C.     In statement d, a BaseClass reference is trying to access a SomeClass class method that is not part of BaseClass. Is this legal? Explain.

            

Explanation / Answer

for rest of the answer please ask in other question