— Scott McNealy, Sun Microsystems Chairman, President and ceo



Download 40,57 Mb.
Pdf ko'rish
bet222/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   218   219   220   221   222   223   224   225   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

// generic printing
}
}
Report
runReport()
printReport()
runReport()
buzzwordCompliance()
superclass methods 
(including the overridden 
runReport()
A reference to the subclass object 
(BuzzwordReport) will always call 
the subclass version of an overridden 
method. That’s polymorphism. 
But the subclass code can call 
super.runReport() to invoke the 
superclass version.
If method code inside a 
BuzzwordReport subclass says:
the runReport() method inside 
the superclass Report will run
superclass version of the 
method does important stuff 
that subclasses could use
call superclass version
then come back and 
do some subclass-
specific stuff


interfaces and 
polymorphism
you are here
4
229
 BULLET POINTS
$
When you don’t want a class to be instantiated (in other words, you don’t 
want anyone to make a new object of that class type) mark the class with the 
abstract 
keyword.
$
An abstract class can have both abstract and non-abstract methods.
$
If a class has even one abstract method, the class must be marked abstract.
$
An abstract method has no body, and the declaration ends with a semicolon (no 
curly braces).
$
All abstract methods must be implemented in the first concrete subclass in the 
inheritance tree.
$
Every class in Java is either a direct or indirect subclass of class Object (java.lang.
Object).
$
Methods can be declared with Object arguments and/or return types. 
$
You can call methods on an object only if the methods are in the class (or interface) 
used as the reference variable type, regardless of the actual object type. So, a 
reference variable of type Object can be used only to call methods defined in class 
Object, regardless of the type of the object to which the reference refers.
$
A reference variable of type Object can’t be assigned to any other reference type 
without a cast. A cast can be used to assign a reference variable of one type to a 
reference variable of a subtype, but at runtime the cast will fail if the object on the 
heap is NOT of a type compatible with the cast.
Example:

Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   218   219   220   221   222   223   224   225   ...   555




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