How is it possible to create a sub class object within it's base class?

后端 未结 5 1626
自闭症患者
自闭症患者 2021-01-25 17:38
class arijit
{
 public static void main(String args[])
 {
  System.out.println(\"Base class main\");
  amit ab=new amit(); //how is it possible as the sub class object a         


        
5条回答
  •  后悔当初
    2021-01-25 18:31

    When you compile your program two .class files are formed,namely arijit.class and amit.class. So when your program is being interpreted ,interpreter knows about both the .class files and hence you can create Objects like that.

提交回复
热议问题