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

9. Here are some class definitions with questions that follow. interface MyInter

ID: 3553399 • Letter: 9

Question

9.     Here are some class definitions with questions that follow.

interface MyInterface

{

            // Methods of MyInterface

}

public SomeClass implements MyInterface

{

            // All methods of SomeClass and MyInterface

}

SomeClass obj = new SomeClass( );

a.      MyInterface miobj = obj;

b.     SomeClass obj2 = miobj;

c.      miobj.aMethodOfSomeClass( );

Statement b is trying to assign the SomeClass object refered to by miobj to a SomeClass reference variable obj2. What is wrong with this statement and how would you fix it.

Explanation / Answer

Find the code here : http://ideone.com/ovinmo