Java Notes by Genie Ashwani
Java Notes by Genie Ashwani
mNt be
The Ramometer con be possed
aLLephed by he method i
n
sequente they
Some Seunze
Publie e lass A
int add co withut Arayumey
tnt 70
3
publie lass 8
int odd cint ,ty) cwith oyument
int
JassHorme inputamys)
/iniAalieadtto t tnstonce vonable
thìs ìs keywosd
this is
keyward uId t mete eurent cless in stonce
nAmbes Cinstonee Nojablay A metha
thiskeywocd we con use to ditterenti ate beteen loeal ond
qlobad vojable otz
we con vse this key Dord insid e d method jnide a
congtrute
sbclassTest doss yz
bertbam sbat publie stette yoid madnCtiyg)
Najd setyalue (intiD
this.i t setvelwe eio);
3 t. showC)
void shouw4
System.out pritn ()
(0
snstonee block
Sste m.ou.ptla (
Olocks
statie Nonabe
Synta Cextends
Typs of Inhestonce!
O Single or sìmple
ultilevel
Hierorehiad
lHple
Hybrid
Gydie
d
Note- oTovo sug posts for sin mulhlRNel Het osehio
joheri tonce ela sses t jntentoeeg
by
Tavo Suppt tr mulple Hy brid nheritanee by
Snqle simple Tnheritone !
Class C extend p
Leolsbltrds
Sopln n ehild loss mathod')
me m
Pel ne
slemiz o slpal2
Closs PS
soplnc porent class p-) na method":2ols oog
3
Jass eeyotends P
bidsDnlgoz
Soplnehil eloss m2 method
bns9 oly
Qoss ce entend s <
Nojd
Sopln ( chìld clags c< p3 methad'
3
Jova sypport multple tybrnd
jnhertone by us iadertaee
Tohesitonee!
Closs
Nold ml(§
sopln ( pore nt zloss p m methad'y
Clo ss
Noid mn c)
soplne" 2hìld zlass <m2 method)
U9st Ca ertendsP
SDpln ci' ehi ld Ches nethod'%
Anaedenence voriable
f tis a non Statie bomedin.
seper eloss (porent ) closs
F Supenr key wo-d holdsoe sont to reter sup er coss ngtoneeC
Aomn sub- eloss 14
*
keyedord
nem beS then use super instone
ditteretiade subdass nstence yoables s meta
To intone
yorlabey
methos from su perrduss Ynstonce
in stodie meBhodSm
cwe con not use Super keyuo
stetie aettho bloeks
Syso(this.X)
sysol super),
ong cc congtruete')
sysoZ" o
20
Ccccintx)
oy cee (onstvcto,
L Sy so " int
ste
new 00D()
emo Closs
D
Test mport
pI TeIt closs
Pe;Poekaye pl;pockage
Pe
pntecey
c/osses
metheds
Cojova
Com
methodg corejava, fockage!
(om,
nome. Pockage
Shatemenoekge
stat
omme, joyo yw^ nmet is
stete frogt statemente
package one most odo)te con only ckage po
jotesloce class eer me T0
otpost oîs fockagetime
jte closseg Teladed
unit sìrgle itoad soce
d ispactge
qoup thoehonis
fo umencopsuladin simple fockae'
ois K
tolder.
Tnport
Test Jovd sfatement
pockaye
1st statment
mpost sfadement
od statement
Closs eelosodion
jotetoce derleratiay or muliple na)n
o)|o
maùn
Soya
t AceJs madiAres in
tho powatenool
Proteeted
publie
Pro eehed!
Access - oithin tte poekage outeide ot poekaye 8nlg
n child elosseg uding chilo reterenceg.
Aecegs 9odiery
Vosiaubleyor mthods
Top leve edose Tnner leNe elog ostab
zborttsm25doio
dol
poe kaqe
Prcapsulatt.
9m.jbk. encap
puble clags Student
publiz iotqettollNun ()
Student
bioy ildug
metho
Ngojable
Hide doda torr seeuity pupa
too to achieve encap suladteg'
by na kr metods publieprNateu
Class tBkBork Dato hlding-
psivade long oLeountNumb em moky Narleble of
pivate double balonce
erivade
puslle void get&alonce C)
if lnakdatk user)
2/outhentteatea wse
sapleCbalone;
/| vnaudhetcat usersm
pleoge proujde yal)d usemome):
Soplo
mborhsm 9h92
Compile time
Cstadie polymasghis)
Metho hethod Closs Tet
Oyesloadiy
) Some Nome void shod (into)
( gome name
Some elosj dih dosf
Same om
No.ot yeld shon) (iot a, lnts)
sopln C"a);
p-sm
show (o
man method ? methodo in a clasj by
we ovesload medn
0 Con ot dwg,9 calls
hane Ory Tueq
ThÌs s Beeguse
We con
method overload'y
maln method Jhieh
closs est
Testt ne) TestC);
yo'd shoul)
S0p";
9
onstuehog mst be defne hoin Some name
n sdme lasg.
’
Constrcterg jth dif!. omg list.
number ong- yn be dtt
9n be Jitt
mnadhod
* Methed Overriding hoe the same ovenniidiry,
ehild class
colled method
-> Ip cogs
poet jt is
declored n the the ehild
method n
porent elass
dening
nee - Re. methad
Jassalled ag
poret
some
so Me nome os
o ln the Jore
tt
he
ho method mt hove
method ne posometert
the some
mehod must hone
fhe porent eloss
Is-4 melattonship
There must be hoNing
dw6 closses thet
metbod Nereiding eeeus n
posentehiid elactfonghp bodfam nohanE
elos chid closs medhod
Nate- 0 Both porent name.
haNe he ome method muSt hoye
zhild elass methodg
Both poest eloss
the gaMe aeturn ypes
dogs eijd eloss methodg must honve,
6 Both orent
the some ponomefen 1'st
9d ifo 0ouote
Ouedloadlrg Olerniding
js harg
honlng multiple ORe detniry the porenf doss
medheos th the some nome metho chio Jas.
but dt dmg. ist
Metho o ouerjdiy
method overtoading tos clossey thot hon porent
2h)/ latonship.
ovenrload)ng pa 6d mete
n method oveminy
6 In method poroome te s must game
|st must be dipteren+
netha oNRrmoiy s a ame
9D method overtoadiy is o eomple
ot campi1e me polymophlcm
method ovenidiy both
porent elass ehi eass methos
moy hoNe the same t n tye
must hawe some
A-21d t2u
ibtetho
Methad Oleooidlng hidiny
O Instonce nethod Oatadte method qlobe/ vor
tn method oNemallr n method hì d)ngmethad
medhodmesoion bosesresotuon
objeet
Qunttge pohmonghsm Gmp) le Hme polymenphism
bis0ho0
method nesoluHon oj! be ) method reso)o wll be
act copile 4tme oniboolas
closs
S polnt
ceated.
Juprint Arorn cokteh obfe ats ifmethod
demplte os 20mno
20mmo) paperhy
class is
hjeod dbieh hove
ruf od wbleh objeel wil!
onine how sbjeeh behove
eloss dete is used to delne clos
keylod ohich
closs
closs is logieal entiy
dedine wsetdadne datotyp,
de ss is Used to
eecio),
clocs doss not g ulre mermo for meheds block sh
e cen ereate
constueste
STnside o chss
object.
dbject is collecten ot dato ¢ methads
obje et is on ingtonce ot elogs
cbjeet is ed oosld entiy
behove
object is on entty cohieh hog stades
objects thaving guln memoy kog txecuton
eon not (oeate Okjeet withot lass
doss
e con coeate mony ob'e ett ot one
s closs by eatiry on objee.
eneopsulation
It qoup mo chonism where we con qroup Narìables
s
method toto slngle un)t ealled elass.
is bert eo mple ot encopsul ation
9Hiding dato behind ometh ods te ealled ehcapsulaton
the
we con oeheve encopsu(afio) Vonables osopNat
moklng
wzhiese encapsolaton by mokiy meth ods as opubliz.
6) Dato
hidny
iding meons id moktng af vohalbles pvate
decegs
furekoaiy o ob