0% found this document useful (0 votes)
10 views7 pages

Java Assignment 1

Uploaded by

ketankotane552
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)
10 views7 pages

Java Assignment 1

Uploaded by

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

Aesigpmeol No1

Iruclo. in Java tih


solable exomple
J Oeloull conluclor
Aconstrutor which
dre not been A cosructor crealed by User b
implicilly creded by TUn is caled or delall construco
las A
int as20;
vad diplayC)
Void

3
Syaler), out.printlo ("a:"ta);
Pablic elakc void main
A obË pew AC);
objdilogC)
2) No gumen corslruclo '
called
A cordudor, cith
construcho, gumen
no
i
gumen!
cless Cons&
inl ab;
ConsC)E
Syalem out-prinlh("No orunenh conh
as
b:20)
publie void display C)
tint sum
Systerf-ofprihh
Syclen.oul prinlo(sum),
class No
yoid maio
Cons CI new Cons())
3
Paramelerized condruor
Acondludor
Iructor ih
called us potameBerizel
is

e class Cons2
int

pub liç ConsCin,p in q)2


Syslen.out prinlnoronelerized Contruclor ");

putlie, void
int sum,
displayc)¿
Sum : a 4b
Syalen.out-prinl sam);
class PorcCons:
pablic dake oid dmain(shipg oyl])
Cons CI= new ConsC\o ,20);
Cons c2 =new Cons C30,40);
cl-displaC;
C2.displayc);
pot labilBy ath'repect
Paloro indepeodence':
JTo javo, you can. arle gompl e
then your
you
progtam
co
machine Ceg.coindow)
cormoiino))
in the Celoss le) on
or Mac0s).
other machine Ceglinux
2Thl is ohd Athe pellencorilen
indapegderconpile
Means in java .program
4

oa be run on any ofer


on one oacbine can
machine,
21
Porlabitly
is porlable because he bulecode
C.class e) oFablea program can be run
Cceut
on diPerent mechinét cotho any
chag
a) Explain, he corornond line
slable oxample.
T is posxible, to provide ingut, o
program direetly, ho Commanà line. These
are calle as "Comman \ine °jumenlo',
or

class Cmd

CAJ pubkic dahie vod moin (shin ogs


Ror Cal izo; ik agtlengh ;it)

ay Deseribe the use R metbod o veclor


class e their Synlax.

Usel o add elemenks


v.addElerernl Cio);
99 elemenlAt Cin .indei
porlicalar index
Velemeolat Culo);

3 int size ();


lo sel size ol vector

4) o
relurn capocily o veclor
Vcapaiky);
sJ lastelement(J
rekurn ladt elemen!
buller

bulWer
clasr jor
is C
shigg buler, is, o
pee los o shg
is Kred 2J
Linnutable] Croutable]
Con be 2J Obieds can be
Çrecoted
shing cono creok2d by coi
Construcor
ensed in double shing buller class
quoBes. ne'

s:"abe'!; Sriog Bufer sinew)


ShiheuPer Cabe ");

You might also like