filmov
tv
Regular inner class vs Static nested class || Java interview question 2021
Показать описание
Regular inner class:
Without existing outer class object there is no chance of existing inner class object i.e. inner class object is always associated with outer class object.
Inside regular inner class we can’t declare static members.
Inside normal inner class we can’t declare main( ) method and hence we can’t invoke regular inner class directly from command prompt.
From the normal inner class we can access both static and non-static members of outer class directly.
Static nested class:
Without existing outer class object there may be a chance of existing static nested class object i.e. static nested class object is not associated with outer class object.
Inside static nested class we can declare static members.
Inside static nested class we declare main( ) method and hence we can invoke static nested class directly from the command prompt.
From static nested class we can access only static members of outer class directly.
#innerclassjava
#regularinnerclass
#java
#javainterviewquestion If you want to help us for enlarging our channel, then please donate us by your own wish:
Paytm: 7509058785
Without existing outer class object there is no chance of existing inner class object i.e. inner class object is always associated with outer class object.
Inside regular inner class we can’t declare static members.
Inside normal inner class we can’t declare main( ) method and hence we can’t invoke regular inner class directly from command prompt.
From the normal inner class we can access both static and non-static members of outer class directly.
Static nested class:
Without existing outer class object there may be a chance of existing static nested class object i.e. static nested class object is not associated with outer class object.
Inside static nested class we can declare static members.
Inside static nested class we declare main( ) method and hence we can invoke static nested class directly from the command prompt.
From static nested class we can access only static members of outer class directly.
#innerclassjava
#regularinnerclass
#java
#javainterviewquestion If you want to help us for enlarging our channel, then please donate us by your own wish:
Paytm: 7509058785