0% found this document useful (0 votes)
21 views9 pages

PCCCS303 Notes

Makaut 3rd year

Uploaded by

Ritik Raj Prasad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views9 pages

PCCCS303 Notes

Makaut 3rd year

Uploaded by

Ritik Raj Prasad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

1>what is inhesitance in Ohjeck Oriurtol oogramming?

What c e tHe
Le diffnent
diffeoRt typs, af Iheaitonce
teattance in JAVA?
Desc >ibe each of Hen lt, dioqary and implement
Bseugh pogranS.
One
oiented eroganing- Te's
oft e ha97e fectunes of ojert
Programming
poceune hat allows s to Seuse code by
oetenencing
well as
he behavioun ad data of
Le
object
Ceneatfo Liieroney of closses,
he
mertonien class qs
loss.
qlve types of Dahaitance:,
1. Sigle
Iuhanitnce:
class laheis
Siglem inhaitonce is when
Supoclass.
Example; class Animal
vod eotC)

class Dog extends Anlmal)

Syten. out pottlnOoy is

(Class A) Roment /Sup dass


(Class B) Cnd|Sub closs
2. Multiple Lnhanitance ogs intafare):
JAVA Suppozts muliiple inhitance
which lows Hoough intefass,
class to inplemet
AouweveN a closs multiple
still ihet om intefoe,
Supenclass.
Exonple intanfoee A S Oogived clas)
void method AO8
Bae Cioss
inteface Bi Bose Closs 2
void mehod BC)?
class yClass
publte vold lplements A,
melhod ACO
BI
Sypten out.
pulblilc veid matodpotintaCuathod A:
B
Sgsten. ot.
3.nalllevel
wben a Trheitance ;: Malti
class inhaits o laval nhai
class konce occurs
from
mple: class
anoh clasg. ot is
aldy
Class A ylase
cicoss
Gandpnant ii
vold pointGorcd pase
Class Brt
vedite
class
System.outpontn(Grodpeset clas ,
classVoidPonat etends
Patint PaerteGrno mdpsm ant
Closs CJclass Syten. out. prtntlh (Parat closs;
class Child extends
pourt CildOEomt
Setes. out. pit (CLid aloss;
Heaohicl
multiple
Tuheitance Henachial Duhenitance occuns when
clesses inheits orn a slgle upast closs.
Exople: class Shapel)
Void dnaw )
Sytenoute pintl¬ Osaw a sop;
class cicla atads hape
Systen.out paitly (Doraw ccle :
Class Ractungle atend shapel
Sy:len. coulponintln"Draw a atangle");

(Class A
class (Class C
aoss D)
Cluss B,C die fz m
common base clossA
Hybid Taheitonce: ylot Iahaotance ls
Combision of tuO types of inheitane,
Tt's cchieved b
Cobini-g he obove ypes of
Iuheatance jn VariovS ways
2 what is function Oueleoding and fncte Oveniding?.
Baiefly axploin och
poegon.
5 funcion
ovaloading and
Function ovei diig
Concapts in Oojact-Oented
Found n lagvoqes Gke C+4 pOqgnning
and JAA.
tical
Function Oueorloading -
Functin ovloadi Occuns wter
uliple Functios
elass Same but
differeit be o type of hel parntos
The
conpilan detamines whte fun tin to call
lasad He ogunents porouldad duing He futio
calli This alows ue to Cneate
funtions wi sllo
Functionalthy hot occept dirferet ky pes of
input.
Exampe? puillc closs Test
public statte vold
malnCStztng
Systam. out poitl Cotr ongs)
3 Test. main "Evsnyonc"); funetion called).
Rublic tatte uo;d moin
(strina an

Sgsten.out.
t on):
Tost,matn (Hallow
Cueryone",Gocd tagi
anl,
Sgstan. out. i¬tl (Hay
thae, 9
Oudput nain funcio called

Halloa veryone, Good loning


functien Ova|di
Function ousniding is concept in iahaitance
a 9ubeloss pouides
peciftc lmplementotioy
Function hat s alody dafied in it's
Gupenelass. OveI slding funetly in he subos
has he
neduy pe, md parametes
e Spnclass,
Txanplei Closs Vehicle
Uoid enginaC
Systen Out p ntlu C'his is veide
egie
Class ke catends eiale
gsta od println C''s is loike engie
class Can atds VehtcleE
uotd enqinec
Systen. out printn Ris is Co nge),
Pablic chatic code Exnple
pulic totie veld mah
Output: Bike nonda 2 (staig ons)
|Tis is a bikQ cgt 7e
Tis i a Ca honda,
Ca Bene
engine;
Bene. eigine;
3) wha is Nestad Class? Explat
Yaough progran.
SA nostd class class Uot is Jefied witin

alass. Nected classe) offan used


g1oup elasses togeth wter closs
legialy
closely
Ated Ao anoye. bay Can accesS e mebe
he outa class nd
Can be usful
encapsulation and onganisotie
Exanple. closs Oten Cless
ivote
I/Nestad Class SuterUod =
Class Lme Claas
void display )$
ysten out poiatVolue of Oute Von:4
Outero
Public closs laio
pullic totie void moin (stzi n onq)
instance of ue oten olss
OutenCloss
I) Conaate
the outey cloLsS
OuterClassO;
Outancoes. Dnclos in190bj
Dutebj
o
I| Accass
I1nanClassC):
class
muaO. digloy;
clasc, wweh Contalns
OutaaVo nastad elas called
IuneCless.
"Dnne ClosS nosted Cbs whic hos, acess
to Outer Van Uai able oute closs,
maln mohod We
Coacte an istanQ ot
he oter closs (outar Ob) Hen Caat
instonce
class oute hetoce.
Con all the
disploy met od of e inen olS
dplay value of Outaybn.
Con gtucto, what ne We diffenet upes

inplamet hoough progon.


Oject- Oietad progpomning is
spid malhod hat is
oject f a closs is automattealy called wten
pupose is to oreotoo. t's mo
itclize
pfoms setup Suiad fonatiuteg
a setup tho object
funtion
>Dafault Conslrucko - A
dfault Consluct
PIOuldad s
closs.
Eranel; Publie closs hycloas i
/Oefoult consA>ucto
Putlie ylossc

iSPoanatoiged Conslnucto
Constuclan accepls
A paametonis
allou 4O
Values. Initialise ciect atnibutes witt peci ic
Example! Closs yloss
daf-\nt- Cealf. value:
myvale value
g-oject
nyClassCH 2) # Gnattg
object wilh value
Cop
Constucton- A copt Conslucto s use to
oQject that is a of
oject. coR
Example: class yeloss C
Pablic
int doto
hy class nt vaudi la
data en. at) Uau3
Static Concsrueto C#): Tu C# , static
used to
15tolize steic manben constueto
closs
bekane any iheikere
Exanple: closs Hyclass
statc yClass

Vate Conslucto - A psiwote


t
orawet He oractio of mstanos of Comslruta is usad
outle class. class
Example - uble cos
pot vote Gingleton
stalie ingleton
polucte Stgleler
Stleton instances;
public dotie
9gleton getinsfaneal);
instancQ
istane;

You might also like