Declaration type of an object [closed]

RuiManuel

New Member
Can someone clarify the following 2 questions:1st question. If I have the following...\[code\]class interface MyInterface{ ....}public class MyClass implements MyInterface{ ....}\[/code\]what is the difference between these two statements?\[code\]MyClass a = new MyClass();andMyInterface a = new MyClass();\[/code\]When would you use either?2nd Question:\[code\]public class SuperClass{ ....}Public class SubClass extends SuperClass{ ....}\[/code\]what is the difference between these?\[code\]SuperClass a = new SubClass();andSubClass a = new SubClass();\[/code\]
 
Back
Top