0% found this document useful (0 votes)
2 views16 pages

3rd Sem Java Full

The document contains a collection of Java programming examples and concepts, including input handling, operators, and control statements. It discusses various types of operators such as unary, binary, and ternary, as well as methods for reading input from the keyboard using Scanner. Additionally, it covers conditional statements and loops in Java.

Uploaded by

km4366184
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)
2 views16 pages

3rd Sem Java Full

The document contains a collection of Java programming examples and concepts, including input handling, operators, and control statements. It discusses various types of operators such as unary, binary, and ternary, as well as methods for reading input from the keyboard using Scanner. Additionally, it covers conditional statements and loops in Java.

Uploaded by

km4366184
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

Oop

DWAP oop 119/25 /9/20


Mcrepting an inderger wltvefrombryferd
import [Link]
class Tesst

publie stortie void maph(String


argery)
throwsIDE
xcepton
String str:
Bufferedheader br=new Butfered Rerf
(new, InpoutS
toCram estos
Syptni, iutprind (f
a t r n
readlinee; Atygera n
Stra br.
mai)
indnomg s Inleyen. p
a r
Sy stm .oud. eint m yoeT (s
w end eed

Scanned with OKEN Scanner


WAP to aedelition of 2 No.

imprt jaxania
Va

Clam Tert

Public Static ve
roid main(String ongs
()
throwsIo
Bxce pti
on
toing

Butferred Reoler b
re new Buttered R
Chew I
ende
Inputstreamke
System- O idon
Stor ud: prigt( (girm' n
asldfirte
rn the ltva
num
le ).
2 = mum
It malints
Suytanm Oul print
ita br read @ Bnder the sand va
Stor2 Liners: beny.
Stirn noms nu
mit num2(i
nt)3
System- oud, print ( " = m
3 The fieril 1s p Dum)
Scanned with OKEN Scanner
A P th e, n a m e , g e n d e r y a
1 W t o s t o r e
f s u d e r d a n g
hey titratien n ady mir o j k o a

Imporg" yava
import jave io
class Test

public shidisvoid moin (stsing


ing..9orado(
throis IOException
iString stri, stoa, stra, stey
Buttered Reader brenew Bufferedhod
(ren ThiputSre
em feoderl t
Suystem oudi peidt ("
insder ame, neg st
rtine omber d
Str=brireadli Mark
neс
Stigineoioar st
s string ioneni
Strieshined The
Str nes; z e r ( sty
2= stnexd
tokencg
Stm32 Sti ne
xt ToRene
Stery stre:St ரிை
r= stnl.
trino
Str2 =
Str3=
str2.
frincoj
Strg. f
rinc li
Scanned with OKEN Scanner
String mamea str t h
int regno a IntegerporseTnt tr2)
2

Vamfoble
marsk loat pars

eat maree Ploast, porset(ors a)


S.0.8
Gemder M/f 11
PrinAf( Entename gand
C
enteer
, rgd vg
l d
mariaofa frdantion 2i
Seon(/o/5 fif Iname, sutordstrs 2

char thethamBrt yoer

Syrem.-caut. prithiywr phmie t ty ore


is

Sgurem aod println Yoney g


Sepatein cosd yprt it tn /omyaurmar is
[Link] ma

12

Scanned with OKEN Scanner


Dapoop op 12/9/28

, hecting the oput throm the keytomrnd


Through Scannenclans.
digrto
(We Use,Seenner clovs present in jevasuar
Can
Paerage, the read the in pust from the
)
the kery beord
thp foreg of Bopsens. tiy the foepeung
inthods
me

7 nexico 7 This methad isused foread


String from thekig boor
nexthiner This methe d is used dorrada
sitring till end ot the tine.
next(. chorAt(o) 7 This me thad isusied tra
ac heracter trom thekesiboo
rrd
nertlytResy Ths fmeByte
thenvalue.
1
i teddorea
a

Scanned with OKEN Scanner


7 nextIntos This method is usep fa reopa
intergenvalue
enegt auble ths meted isvied boregta
ia dou ble va loectron, thekey bard.
metheddis used to
is used
[Link]:-This metho
read Float valuefrom the
toefanm the heyiord. s 18(
7 next Lonpe(3's Thismethad ir ouedde
us

• reada "hongevatiefromReybiond.
A
WMp to tase a input Is,nome, and salorynfan
emppyee. and displacpi
import java. [Link] 26
class Test

piuble Staticmid main (Ste e e


Scanner ob- scanea-clay
it=new Scann
er (S [Link]).
Systame:Oud prind
(Enter the s,
int eida N ang
lame.

se, nexdI salary of


tthhe eemlae
ndos
String name
=sc. nexte елows ui
llo?
flertsal =sc
em. . nextFlater")
yrteneouk prioth (En reTar=eA6O8 * Vr
[Link] pri e
ntlo("FrmporaeNiam
ea rarin
Scanned with OKEN Scanner
Syter printh/"Enploge oria

a)WApiP toreyrsea adigidtnod heon


tonevresea
iporch jovsn undid sehien
a

Class Test

Serot mbed sme


Ewbodee

pult statie void matnystreo nah(


) eEDOC2
n
Scannneer se=new Scanner
System out: prind("En
der the3 digst n
humber)
2368
se nextInt 368
8
(

rev= rev *1
[Link] m:
223
コマの
360 .rrem= h/10.Jat2
revsrevxlotreтm
.6rem= n%10;3 33610
=n098 1de 6/10 76
talx
13

Scanned with OKEN Scanner


System. out. primndtlacnThe tReveritied
number is!"trar(S
3 6
380 Tostne369 sremanden 9

remnder 3
HoW

R wAe to tind the Somoifa adigisdn


Scanned with OKEN Scanner
7 Operator: Opomartor is thesymbolwhichlact
• upan the opermands to evaluate I the exprenion
ir called as operotonAr
Acconding to the numbir ot o percare the o peratras
are 3 I types
2ppm unary operator 3) Ternanyoperator
ryoperator
ta 20

operator ato = addifion


OPerand oponetron nyta
a
Unary-a
unory t
Oore the operatoo tw
hich actsupon s onl
operands to evaluate y
the expren ion is conedas
Unary operatar.
These are y types of unarh edsise
Unarryt g
tpontive
Unarye
ttayidenlcorremmearnntt

operrator(-) fri
inirementope
rator:- The o
Increse the v perator which
th rent alve of opor
uperator porncetyh bented s
ance Ca
2

Scanned with OKEN Scanner


The re are 2 ty pes of increment
(r Mih
"pet
9 pominerementeper prsimiremnt
Operator

posfincirementioperator
proinirimentoperutos The operratoron whichi
froot in oresethe ve weof operance operand
then evaloatre the expression..Iscallag pre=
inrrement opertor
Here the o pemastorm prerent betore thesporands.
Exytta
port inrsement oprntor:- The fersaturnwltrch
firrt evaluate the emprenion then inurese
stthevalwent operrance is call as posd ine romup
"operratorp Here the operatur presenst aften
the , pemance. Ex at+
CWAP. s inremnt operaton

mpord fova. Wtil t


Class Bief

Pubilin,statieroid main (Streig oc


int nas,

Scanned with OKEN Scanner


Sjistem. Outi println (0)j 6
System .Outi printh (++9; 7
[Link]: println(tto); 7
SystemOus printH4(ttn)
int y

System. out, pornth (yjy '7


[Link] prinitth (y t);7
Syesem. cud,printh(oJj 8
System-Outipointh cntt) 8

Syetem- outprins in(nngy 9


[Link]( ys 8

Scanned with OKEN Scanner


OLOAP using dercrement opecaton
impirt java. util
frew

Class Biet JavHaome work

public statie void maln (Strtny aings11)

int n=5, x;

System. out. prindln(2); 4


[Link], printlacm)
Sfatem. put. println(--23 3
System. out. println (--n)s 3
intys
yn
[Link] (g); 3
[Link]. printin(y--);.3
[Link]( n) 2
System. out priath (-~); 2
Sy staemmroouutteo printinc.
Sy1st
2
em. out prind ney 2

Scanned with OKEN Scanner


Hoop
A

18 18/-9/257
Binany The pontiies
pera

operetor
upond 2 operand to evaluate theexpressioo
is caled as Binary operartor
Ex-0-6
atb
a*b
2b
eta

Termany sperstons- The operetrnshgh act


Upon 31 Soperand toevaluate the exprenion..
is called ternary operator, ilisalso
as
cateden
as ant hihajt fenider ashrde
asbasedon
the condilion it evaluate the expresion.
EX ? 3 Nipant atatimeeva luate
023
Coloun
Luotion mo
rtk
Syntaxi- condionaterxpreniog. A
eapresio
renpres
ior
iftirve eval
wate lstex p
Cond Biang
Tsikeerahuite2n [Link]
OWAP to checke whether person is eel
for vote not. or
a igible

Scanned with OKEN Scanner


[Link]. util. S canneng
class Biet:

publre Staticevoid main(String args[])


S

Monnen S= new Seamer (Syrterein)


SirtomiOuto printn("Entr the aye othe noseed
int ag = SC
sc neutintes
7Cagt> ts) ?iSystem-oidprtrtn (aTou
eligid efor wte"): Sgsten ohpint
vote

Foiow

WAP to find the marximumno between 2 No


Dne import [Link]
Class Biet. 2hosipes
Public
vealinain (Prtey ae
static voidmain
stote
Scsan
annemerr S=
=new fomier (Sуe
anner

Sytin -duste prinll ("Ender the,2 nax"


a

int b=sc. neSxctiInnetxot;Int );


er=

Scanned with OKEN Scanner


lA Iwbory

22013
Siyo pem. Dst prentln ("
ers
n ste ta
Syitem-oud ·printly"d
2 dt t

Acording toy theoproutir the perntor's


are"different types ("tlai
7 Arrthmafte かわり
吉品

Relational インクシー
7sergimist=

koi8 22019
Logical78, 11,!
Bitwiserk1 s sро
Speeit nenete
Scanned with OKEN Scanner
20

Contnd statement w The staterent cohisb


controd the tlow ofexecution is called as Contwel
fns pen
There aresevernd . Ayper of contr
od eatemond
7 Conditional sratemen simp leif
if ele in sila og
Yloop uhpdei e nn Componond if i
docwhile ested Helse
foreachnod ladderif.
7Switich o i f t s i m p l e l i s t h e s i n g l e ?
si m p
t d i t
on on o
optnal
contiave Dopti
o r Co

s k i p i d
rrtu rn. intwe o t h e r l u k t

Scanned with OKEN Scanner

You might also like