Why Object class methods are available in interface?

前端 未结 5 1522
故里飘歌
故里飘歌 2021-01-24 23:25

Following interface and classes are successfully compiled. Problem is mentioned in the output below :

interface MyInterface{}

class MyClass imp         


        
5条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-25 00:00

    At run time there should be a real object (or null) behind the reference mi. The real type will implement this interface hence the compiler allows it. At run time any type that implements that interface could be there.

提交回复
热议问题