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



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

local inner class
anonymous inner class
local inner class : Local Inner Classes are the inner classes that
are defined inside a block. Generally, this block is a method body.
Sometimes this block can be a for loop , or an if clause. Local Inner
classes are not a member of any enclosing classes. They belong to
the block in which they are defined in, due to which local inner
classes cannot have any access modifiers associated with them.
However, they can be marked as final or abstract. These classes
have access to the fields of the class enclosing it. Local inner class
must be instantiated in the block they are defined in.
Points to remember:
local inner class cannot be instantiated from outside of
the block where they are defined
local inner class has access to the members of the
enclosing class
till Java 1.7, local inner class can access only final local
variable of the enclosing block where they are defined.
But from Java 1.8 onwards, it is possible to access the
non-final local variable of the enclosing block
the scope of local inner class is restricted to the block
where they are defined
A local inner class can extend an abstract class or can
implement an interface
Example:


C:\Users\jjatin\Desktop\Different Versions\All_Photos\Question
47\local inner class\Example1\color1.png


C:\Users\jjatin\Desktop\Different Versions\All_Photos\Question
47\local inner class\Example1\color2.png


Output:


C:\Users\jjatin\Desktop\Different Versions\All_Photos\Question
47\local inner class\Example1\output.png


Remember, you can only access the block level variables, and
cannot change them. You will get compile time error if you try to
change them:


C:\Users\jjatin\Desktop\Different Versions\All_Photos\Question
47\local inner class\Compile time error\color.png


C:\Users\jjatin\Desktop\Different Versions\All_Photos\Question
47\local inner class\Compile time error\error.png


A variable whose value is not changed once initialized is called as

Download 7,31 Mb.

Do'stlaringiz bilan baham:
1   ...   20   21   22   23   24   25   26   27   ...   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