0% found this document useful (0 votes)
13 views12 pages

Adobe Scan Jul 01, 2024

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)
13 views12 pages

Adobe Scan Jul 01, 2024

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/ 12

Assienoot No- 1,

Q-1 Waite a jovo progum to illustaade constuc oveolo


ucing on method ovealoading
class veo loacl
int a;
int b;

ovenload co{
b=0;

Oveload (int ad, int bb)

bzbb;

int ccddo
retun catb);
double add (deutbl. o, doubble b)
retun Catb);
int add ( int a, int b, int )f
tunC atbt):

class ovenloadtest
pablic Stodic void main (Stning angst ){
int inji
double d;
ovenloacd obj1=new ovealocc (1,Do);
oveorload obj = New ovenloac c;
ovenlcac obi3 new ovenltecl t);
Sulslem.ote paintin cobj?.a);
i= obj4. add c);
jobj2. add(O,90,90);
d= obj3. add (1o.5,13,6);
System. Out pintln ("re Sult of oddc) "+i):
Sysem.out pnintln ("nesult of add Cint,int int ):" d
Stem.out paintln c"aesalt of add ( double, dousle ):"+d)

Qutput
oesult of add=32
gesalt of add Cint, int, int)-60,
vesalt of add Cdouble, double) =24.1
G-a&rplain with pnogrum the this opeoado in java
Woite shosnt noteson gbac collection.
class Cincle f
double y'
double ;
double auac)

Cincle Cdcuble . dable y. dousle n)f


this.=M;
this.y 9}
this:)
else
netun
0;
undnSyutem.oudprintln
("Stack
pop){ Jnt
stack. the from it an/pop
i; tos]= ++Stck
lse
is
Stark paintln
(" .oto Systery
=g) tos C34
item) Cint pusb void
stack. the onto iten anPush /
-1) t=os
Stockc)
stcck. top-of- Tniiaize |
tOS; iot
o]3 int =
nestckt] int
sttk class
thut Stack inteceer cfines
Cn class |valeus
This
can
Strk oimplem paoanum
to ajova Wort
s.clas Seb fnomac colled cannot method *AA
class. Sub atessed
in cannot
be Vomiable
class. Sub a to
s Supe tsitem
karuendconcept:The the aestict finalto-d
isjavo keuooc
on finalan ofaCcess
keyurd stack and final Ezplain
d
c)): (mytak
pop println outSgsm
itt) iki0; i0; Cint fon
"); stat g instak println
C" Sytemout
()): pop (mylack.a printh .od- Sgstam
it*). iK(o; i=0;fonCint
:");myslack1 Sqstm.out.
in ack C"si printin
stack offthe numbens those |/pop
ci) push mystact
2. itt) i<20; i=10; (int fon
Ci)3 push mystack
1- itt) i<i0 ; izo; (int fon
stack. the onto umbens Sorne push 7
Stackc new = SBauk
);
Stacle
gsti){ C'shing void SBatic public
main
SBack Test class
false; etuon else
o){ CTest equads boolean
ct invoking the tocqual is otaeit etuan I/
bji
intj) i, Cint Tst
b; o,int
Test class
posscd
to bemay objets 1/
methocs.
objecs sing U
Paoamet
es. os
using concept
of progrom
the paorometeas. 0S
wiath Eplain 5Q
e (ocal the to asel 0 asb, and veiablea sS
ic too the to Skmenls
feo e paintln
() thre
) to pssino
42 methc), ealls which called, s
12,Then Or to b
4a* initializes theo and
n to pnints tutes,
cohich ezeteates, eze block stahie
stctic he
toaded,
opal Set. is,a Fiost un. statements
CSe Sttic
is
closs USeStatic the asSooo Ds
with
(n callecd JS
ise3ttuns,
epression
()fat thisevalucte *n.To
the
(n1) fat
ntunns funtion
gument anoith called fat
Js c) When
is"+f. (fademiol
3 of println Sytem.cu
t3){ (Stong ning
moi void stadic public
Reunsion class
O;(n-1) fat Sall: se
oesl!; int
{n) ifatC
nt int
nehod tunsive
fial Faetoo closs
vecusion egompl.
of simple AW
is selr colls tho methocd A
be oSaic
eploin euSrsion isWhat
j.ceda); pintln .outSystem
AO; new obj A
tgs
1)f main(Sining votdl sitic public
8 ss
copublic
}
class ("
paintlo ou. Syitem
O{ msg void
40; deto
= int
class
A public
inheionce
only thcush
ackaee outside
o fhom pacaoe thino accessible
i
iSfieon modi access proteced
pected modifieo:
The modifieo: cccess Paotectel
class.
within onlycccessible mocdifier
iS acess vate pai The
mecdiiets. cthi atl
scepe wiest the cveayohere,
has T+ accessible is
e ess acc public the mocifieci
i- access Pablic b
paatage
ong
acessible is fie
mod faut oThedataalt+ as
called is
moditie
csithout dufined class en: mdi!i Gccess DetedtLecessS
paivate.
public belwun dffrence paognam Spgm a
&
ExplcioSpecifies, acceSs Ezplain
the and List
-ning
beein methocd the toculsCuncthe eqecds
1
extends
ingmean The class. ezishng Go
from cenives that
lass new efine to usec
keyuwond
is
eatencs The
oon SBs oPitemS Some to
in loss base the om iHems the cll has which
lasses Specific moe Couate beUsel
to cun closs his
tems oeCommoo
Set Sonne intude tht class Qtnenal
Coucte
c clossificccion.sing
ccu)
One tunce inheeni chicol
oPcdion Coe thecallows
pegnmming
becase
cnd obict-
0ori of Stone cooneo the ofone heoritance
is Tn
ntonte
in of
toncept
0f proernun)
he wioth Eplaio 8a
public ismg
//ok:"sg: cbj
paivete. deto
is earon: fime ompile b
deto): (cbý- pointbnSystonout
angstJ) (Sning main void stehe publie
class public
): closs println
("Syst.outo
mseco void public
4o; dcter
z intprivte
class
f a public
closS. thewithin -Ssible
ois modi accesS
pnivcte modifie;
The CuCcess Privcte
toessible CLCc ce and methocd. cnd
class
B
public contains cless
A 3 and
Th claSS class
tcoocdta ponom given
above To
cte cre huNe We
ecitc;
); tuSupen.
t
brtud eading pai('ntlo {syst
cul em (){ wank void
adseid
ple..colo):
loa): outpaintlo Supen prinlnC -cutSystem
pintcolosn
f)( vcid
black") :" crlc Staing
Animal{ exods Des closs
mol
oniis pointln
(" Sytem.
aut Animal
){
; paiSytem.
nt cut o{eat void
"ohite" =o r colStaing
cinimal class
nPegom :
Constnuet
a.Supxnc)
lose pantinmedite ncfeo toised becan 3
class immediate
,ot pe inveke touscd becan 2}
vniable.
can Sepes
inmediate nfeor
keacend. to
used Supeor be Osug
of
cless
in pnent
membeas. closs pnentnfeoimmclikeyccord Supen toused
ich
iablen nfeencev isa jevc in The
kesyucec Supecm of
usage G9plain
the
Noid
z;iant 2D
Point etnds 3D
Point class
(prilrn nt Sytni.
cat Disploy
Of void
yiint
PoiDn2t class
gunce. inhei Sinle Mudtiple idance& Tnh:a Sinole
Subclass- Sabclass
k-1 class Suuben
inheoitance singleMtlevel <
clasS Sub glass Sul
cass- Sub
cuss Supes class Spen
Hance inheoni Single ple Mut b tunce Tnheoi Sinale dp
itunce Toheon ofTypes
-le.
inheoitance
oith typcs
of cliPeoent Disuss
itable
}.
(d.uook
03
(); Coload'pint
Doec); new dDog
ongl){ Csining moin Noid sBetic public
Super Tst as
z' }
Disco
play void
int:Point3D{ eends Point4 class
inheitonce cMalilevel
single
3.
c); Display is'aP,. Ps3D4 pritn"
Point Systm.out-
uy); +PT. Pai"s C"Poi
3D ot printnSystem.oud D0;P3.=
o); 04. +"is Paprintin('
0Poind System.oP.=15
ud
20
20; P1.y=
P'yc; nes PointD1
Poc3 neoPoint3D
P1) ; new Point
90
)f anost (string
Main anceTnhcotl voi aticSingle Pablic
Sistple class
("xt*
4y1a prinSstln em.oud-
void
oi poin+20{
int extocds 31 Poiot class
class MutilevelToheoitonce f
public sttic void maln Cstring angsrD
Point2D
Point3 D
point Dneo Pac:

Pa.y =0:
Pa-z = 53

Sypiem. oud paintn "Peinl3D @ais "tpa- Display );


.

.out printinrPoint 3D Po is" 4es. Displuy co)i


point uD pgis"
printn pointuD
Systemot printin( +03.
P3is" +e2. Displaye;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy