Grokking The Java Developer Interview: More Than 200 Questions To Crack The Java, Spring, SpringBoot & Hibernate Interview



Download 7,31 Mb.
Pdf ko'rish
bet22/89
Sana21.04.2022
Hajmi7,31 Mb.
#571320
1   ...   18   19   20   21   22   23   24   25   ...   89
Bog'liq
Grokking-The-Java-Developer-Interview-More-Than-200-Questions-To-Crack-The-Java -Spring -SpringBoot-

Static nested classes :
Static nested classes are a type of inner class in java where the
inner class is static. Static nested classes can access only the static
members of the outer class. The advantage of using static nested
classes is that it makes the code more readable and maintainable.
In the case of normal inner class, you cannot create inner class
object without first creating the outer class object, but in the case of
static inner class, there can be a static inner class object without the
outer class object.
How to create object of static inner class:
OuterClass.StaticNestedClass nestedClassObject = new
OuterClass.StaticNestedClass();
Compile Time Error comes when we try to access non-static member
inside static nested class:


C:\Users\jjatin\Desktop\Different Versions\All_Photos\Question
46\Compile Time Error comes when we try to access non-static
member inside static nested class\color.png


C:\Users\jjatin\Desktop\Different Versions\All_Photos\Question
46\Compile Time Error comes when we try to access non-static
member inside static nested class\error.png


Using inner class object:


C:\Users\jjatin\Desktop\Different Versions\All_Photos\Question
46\Creating object of static inner class\color1.png


C:\Users\jjatin\Desktop\Different Versions\All_Photos\Question
46\Creating object of static inner class\color2.png


Output:


C:\Users\jjatin\Desktop\Different Versions\All_Photos\Question
46\Creating object of static inner class\output.png


If you have static members in your Static Inner class then there is no
need to create the inner class object:


C:\Users\jjatin\Desktop\Different Versions\All_Photos\Question
46\When Static inner class has static fields\color1.png


C:\Users\jjatin\Desktop\Different Versions\All_Photos\Question
46\When Static inner class has static fields\color2.png


Output:
C:\Users\jjatin\
Desktop\Differen
t
Versions\All_Ph
otos\Question
46\When Static
inner class has
static
fields\output.png

Download 7,31 Mb.

Do'stlaringiz bilan baham:
1   ...   18   19   20   21   22   23   24   25   ...   89




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish