We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 10
fl |
between jmva and ct.
The main _ditference helwween cry and java. is that
cit is anty Pa ompiled language. cahile java ig
both Campiled andj i }
Loler preted The tp
Converts the Source cade inta machine code and
there fore it is plat
Source code is converted into bute code by it
be Compi ey ard follousing that the joua, inier preter
€xeciiies this bite cade at runtime ard praduce
output -
core and Fxplain java features.
a) umole and famitiay :
x
Java eae ee aa is imple to
Loi
Qre easy to creaie eae aes
ther -
b) Object - oriented
Java is _a fully-abject - ariente
i ; ais .
\H- Threaced
acta’ iia ia
Scanned wth CamSeannerJ
| ie
|__ yao supports moulti threading _pragyanoming —A_
| thiead is an inde pendent process to _execuile
—__|_ a Sel _of stalement- peasy Ie.
al Mefine class anda so explnin_stclie oF Java —
ea ioe arte catap as
=i Clase =
ass Soisthelalagetas oO blueprint of java program Tt
Re ces cteiteademrcin tical closined meth
—} variables nel consianis. -Fvery Java program 4
| nag ot east one class that contains the main
| _C) method 4
| Struckure of java Oroqianami ng = __ ae
a I Macumentatian Sechon
I Package Statement
it Import Statement -
TnierFace Statement |
Cla Derinahan
main _methad cla:
main_methad defination
|
1
@ | ohat_is | token. Explain its 4ypeg.
— ova tokens aye the smallest individual
building ae Smallest tunit of oO 10v0 ar
4 2
al 5
Constracting, eantiteiane ae
‘Thete are various jakens used in java‘:
‘) tdenh fiers
2) Literals
3) operator
4) Separators -
‘Scanned wih CamScanner5 ~ fxplain syméalic corstanis_in_jova sith example 2
= Symbolic consinnts are nothing” mare than —
Q_lohel or name thal is used to epresent og __—
| fixed value that never changes thraughoct
pr gram, n
"Ex= one might _derine OT as a constant ta
TE tepresent the value 3: tenes aS a
pees pe costa he e
Type casting may he defined as the process _O. =
t converting the data tyne of the’ atitcame of ang
aah to another data type. ____—
ae
class Main £ :
public Static. void main Csiring PT args) ___
£
int num = 190; F _
Sysiem.oul priatin C” The integer value : "4am )3_
= double data : num 5
= Syslem-out- printin C the double value :"4+data\s
\
1
Oulput - The integer value 210
The double value; 10.0+
Exalai ¢ 3 a
ovith an examAle - ; Bt
a) anstance of operator - |
s i oi
lo
; A '
instance iS of a Specified type ar nat:
‘Scanned with CamScanner—_Fxaropte -
} public Class Dataperatar fxamplet
Jaid_dis play C)
' | £ z
| double ds 67-545. ;
int i= Cint} do
ata nt
Be a oni p-Ching. arg st) 7a
2
Dot aperatarfxample 1 da ec: nec pat !
Operator Fxamole 1 C) 5.
| Aoe- display ()3
3 =
3 2
4
Joutpat 4.
Tnsiance_at Example = et
Class Main f 4
| public static void main (string args) Ef
| —-
String name « * pro 7"
boolean rest 1 Pame ee |
Qringies! 4 result 1);
Main obj - New main ¢)s
e
‘Scanned with CamScanner—_- ~~
ee
a boolean result 2= ahj instance of main ;——
(susie. out priniin (" ob} is dn. instance of
“matin > tases Ds
b oo es spades ee
at al
(eee ns Pe i
eo ain ternary or a_conditional operator in java —
grith an example:
ig alsa knownas the conditional
=| the ternary operator
| ‘oncrator This operatar con igis of thier operands —
| and is used tou ldale Baolean expressian “The —
| goat of th yperatar is to decide chich value
Shouid be assigned to the variable. oa
Example i spit. tt 3
public class Test — 4
| ' ae ]
____public “glaticunid_onain (-string_args £1. f —— _|
J} int ab |
Ee Oreos
{| ooh sofa ssl) Pao 30% s|
H __sysiem-autpnalln alue at bis :“4h)
I 41h Goss Wane 20: 305 — . |
H ___ System. ot oxiatin (’value of bi "tb); |
a= Sa |
I : Q i
| o UR ea ee
| plusacbeb. 1s aces i
=, || ae
| public cla Fava Math ceample 1 |
‘Scanned with CamScannera
ison
ps ——— = —
double x= 28
double Y= 45
guslem. Out print\o C_ Maximum odunober of x and
y is i" + math. maa Cxz.y))s
System out protin quare Yoot of Yt vy
Math. sqrt (9))5
Susie Oud. print\n ("power of x and 4 icasth
t+ math. pow (#-4))5
stem. oot priniin Co lagarithm of aise." +
math: tog (2))5
yslem out printin (logarithm of 4 is ales
Math. \o9 (4)) Sebescy.
Co toq to xis: "+ math
|. Joa (uy);
| stem. ow printin (" teg to gy is "4 math.
fog CY))5
Wyster . oud - priniin (" teq tof xis." 4
math. 169 p Cx))s- 4
Sy slen cut printin C’ exp of d isf!+ math -exp@) —
&
&
out pul = =
Maximum pumber at x ony Wis . 28-0 -
Sdiiore fenton t Siac eed
power_of x £4 is 6M cae .o :
lo \ 1 ‘ 33 200NSt
Aogariihm of § is: t 38629 43 6111989060
joa 1 ot ¢ iS 3 144415 80319422192 z
jog 18 of u is 3 "0 66205999 13249624
exp cf a is i ts L-44 625% 66 4291476612 - a
‘Scanned wih CemScannera Fi
ee ig even or not using if else ; |
=| Aublic class Fxample £
| a
| _ Sceanney Sc = Meay scanner CSysiom . thy;
System - out-printin C foter a number :"y
{nt a=: 9c. nextIn Os
ese ROU/atie=ea Oy) a
a
| f 7 : x
I uslem- out printin C the number is even *) +
I é 7
l e19¢e ! =
i
Gyslem oct priniin (the number ‘is’ odd “Ls
3 =
dé. clase (Yo
preipor
I _autout : Enter Number. 25 s
I The number ig’ Odd 7"
—@) oni inj
of number fram 1 ta 20:
ES? pe Class Sum af Natural Namber t
| public static void main ¢ String £1 args)
fe a
I For Ci: 1s ic = num; +ti)
£
Sum: Sum +i 3
‘Scanned with CamScannerSy Teus. oriatio Suro OF “cra 20 an
Natural nunobers 1 “+ Sum
a
x
outout = —Surn oc first Besadlral Doe iS:
Lo.
he ech ghirt operator _move all -bils by ia
Oi en Number Of bits to the left The cight =
Ge an
1
number af bits to the right
| yort shirt operator € um ple -
i “Tmport java. io ees
Clas:
ublic Stahic void main
il ‘
siting args 2D
oi number = 3
int Ans = Number <<24
system out: etiniin Cans\:
rf
il perians 28
— igh} shirt operators Fxample -
re i
ae yee
xX4+ Tava 1O. 7 4
‘Scanned with CamScanner|
sa
int “number Qi
ini _Ans = number
System- out pyint in (Ans
ic.
— —@__anrile_a_piogs
=
public lass TavaFxampte f
een onan ee ET args) —
| the Fibanac Seis
“Using for_toap control fracture. +
id_main ( String CF
ae Siatic
yot count =F. Numt=
a. Num 2:14
$55)
Cibonacei Series Of "
Sum OF pre Tuo
svt 1nurh ti
System. Out printtn C
4 Count +” Number 5 i?
“for Cint i: 1 1x count 3 ++i)
M i
I System. oul printin (nun ferecseeien) a
“int
| numt: Nam 23 se
num 2- Sum of PlevyTwo fs i
ee ' 7 :
a -
we
‘Scanned with CamScannera
j
eal =
|_the bisa sialement- ferminiates O'cahile ool
| for loop completely “The continuc— Statement
Jorminales execution of the State ment coithi
Q white or Cot {oop and cant aues {he toag_|
in the Next ilerahon
a
+
i
jot, Sum:o, tempi
int oa. 454;
temp ni A ;
tohite (nro) f
EEE 1Ox,
Sum: (sum * to) rs
fae TaV RCS:
:
if Cleme = = Sum)
System Out Print nC *
Palindxame auch
‘Scanned wih CemScanner