0% found this document useful (0 votes)
27 views15 pages

Java Notes.

This will be helpful for students who are searching for this information or practiceing for seminar.

Uploaded by

geethageetha6711
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)
27 views15 pages

Java Notes.

This will be helpful for students who are searching for this information or practiceing for seminar.

Uploaded by

geethageetha6711
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

UNIT1 JAVA BASICS 6108(2S

Wednes day
’Review OF Concepto:

tan ce
4)Tnhei
bstaction cYoit3n2kn
t u3iria0 o
5) Poymorphis m
4)

’ Dnheritana i Acauing tht properties trom parent


class to child clàe.

Advauntag : Reusabi ity

int a =l0 CUsOurI ArC nD

clss B entende A
Pubic static void main(stringCiarg)
BDbj -newB;26kg631nyiog gut
System:out printlnt obj· a))

COmpiott on cormnand javacitilename java


Emecution conandi jova coKname,
Advantages i Resability
¬n: javac) Aj ava
jawa B
Abstaction: Hiding wneccssoy details and
presentignecessoy informaton:;ion oabhu
Advantages: seity
To Qchieve bstuaction in ava, we art having
CUbstiact casses and inteyfa les
Classes Interfacees
bstia ct class A
absthact void m, C); Void mi l);
3
Polymorphism: Poy means many, morphS mmean
form wich means mayfornme. o 3
S1ie entity tan show muuttipu benavioues.
Advantag si
2typs of poymorphism cOmpiletme
- Rn tine

Encapsuation: Binding or wrapplng vaiables tdata)


and metnods Cbenaviour) togethe
Advantageu: Maint ainabiütyseoD aoitaigurs

Jnt a;
Void main )
1S: class 1s a nodel or a buepint forA4
areating n object,
Class is a
Co uection of variables
nc nnetnoc

Obiect i 0bject s an inst nce Of C clas


syntan:

It becomes a seferc n e v a a .
’ MiStory of Java:
1491: Initiay the project name
is
&un micOSys tems led by the team 'Green project´at
wih JOmes GDsLing.
Dt was dvetoped by hem f0r horne
oppliances TV

1495 Dn 1995, vesion t-0 Dss tieas ed Initiay it


was naned'o ou' but in lq4s. it kOa
was chan
changed to TaUa
418; veYston l-2 is Yleas ed by adding
GUIRCDueetion
ADD4: vesion ):s is dulald (BOMingk
unb0 ning
OYace toD charge over
snicDsyotenAc
version 9 y:o is teleased in March 2025-
Tn Spt
asi0 is 9 Oing to bet rele ased in 20 25.
) Siple:
’ Syntan is simuas to C
7 connpeN topi cs Úke pointers are lininated
’he menvnory auo ation ic dOne by prDgramne4
menmby deauocation is dDne by gAYbOGe coUector
)Object oritnted:
tvengtthing in java is reprta tntedl with ctasses4 cojeds
There avt 4 main Con epts :
’ Abstattion
poynnorphism
’ encapsutation

3) RobLst:
JOa is a stiong tyPed proqraning aguage
decaosation of vasiabie, we wiHhout
connot accs he variable.
tventhough encption ic qenerated it tan be handld
and enecute yemaining pOt of thne program
manag ement uso Membny
U)
U9 Portable:
Enecuting the proqram in dirfeYtnt Os and tceiveu the
SOUme Dutpt.
S. PLatform Independent
"java ile qeneratey "cLas Ale after niing this -ciass
ic qjve to TVMand it can run on fferene Os
SUch a& windowS, macs, inu

[compile once vun anywhere]


4. ArchitechtuYe NeutTal:
is 32.
Gither i t
ntreoD
T sie Of pimtive data type is fimed
inespective of the archittchture. pg Sip

Even thouqh we include au the packages, it wes


menoy ony when it is needed, wn ere it is needed. [It
toads the method wnen it is needed] Unere s in G if
Ue incude any package, it uses the memory before Wing

& Distibuteds
COLe Ctinq inform ation trom different Sources: u b a
RMI- Remove nnetnod Jnvoking .0 443
ET8- Enterpnise Tava beam.
q- Interpreted:
Ohen conmeared to C, java is slowes sheh i
Dntrpretes in java checks tine by uine.
COmpiler checke aUthe proqrarm at a tine and thYowS
erors.
Java is a interpreted lanquage JIT COmpler.
(JUstin ime).
40- Secuwei
The un time enviionment in C is Ds onere as the rn
tine envirDnment in java is JVM CJava virtual machine)
in the DpeYating sysFem Los) It provideslsecre
pertormn
11 Muti threadledi

DI ferent tasks are niqned to ciffertnt thieads in


dingle poqram which makes computer to won
efficitinty in aless time.
12-High perfo man c.
’JVM Architectuse:hb2itahdouio
Class toader performu :
’ takes input a lass fle.
’ cheCkS wheher "class COntauy byte
Ode or not
’ 1F bytecode is present, it auootes
menory to
oifferent nime data areas |F byte code is not
present it throws an e 3 3 . d i b

cLass loadea

|Heap Mhod java Native


Area |Stae igister ubrans
Dbjects

Exection JIT COmpila NOtive Native


pnerpeses method ibrais
engn 2 v merfae
sea to Store au he obje cts
OMehod Are ai
Thls methocl a ea conais ts 0f metho d.
Tt amanges the memoyto methods
JaVastack:

Java stack is divided jnto frames


Cnecutable me thoc1 wil be pyes ent in stack Imain 1

’ PC Yeqisters
froqram contes vegistea)
ene uited
Dt contoins acdress of he cuenty being
Code/insoucion.

bibranes
Stores data Othe than java codes: En: c
3578
’ Datatypes:
Data t y p e o

Pimitive|NOn rimitive
Integer floating Bootean charactr

-byte LOat boo1tAnchar mauy


Fshort
int cOuble
Long
’ Intequ: unaiCat
t wiu store bny cletwa vaues, eith er posl tive
or
heg eive
Basld on the sit and range we have u ufferentD.T

D. T
Range
byte
8hort -3Q468 to t32t64
int
-y47,483, 64e (~')to
t2, 141 483, 64 (2)
tovg 8
6

-9,223, 34, 036, 8su, #$, 808 (-2


to ?,223, 34,034, 8Sy,S, 804(2
The efault vaut wnder intges catagony is O
The defaut data type wnder integs catagoy ic int
’PLDating polnt :
Jt wIu Oystore tractionat/ d(cimau vaues that art
eEHner positive or neg etive. The range is wntimittd
Tne detault vaue under toating point is Di0!S
The defawt alata ty pe wnder tloating point Is dobie!
Te datatypu at tlOat dDuble and the size )s

The tO t wilsto re Singu peùion, 92 bit, TEEf 7SY


torm at.

DOUbe iu stoe dDube preision, 6U bit, EEF SY


FoYmat

>BOOLeun:
the detUt Vaue nder boblean Catagony is fall- t
wil store true ortfae vaues.
Majory he sie 0t boo lean is 1 bit (atpendingon J .
9charocter:
'chas' wiu sort incividua cnaYatrs within the nngu

The &i2e Df character ls byles and he defautt Vaue

s |4o00o'to 1fFFF'COY) 0pto &ss36.


In C, chas eis byte becase We we Asi
Qnd in java it is 9butes becaus e it is Witten i
unicod1lmutiple foYeign tanquages)
’ Varable:
Vasiables are uspd t0 Stort the vaues in the menmoh,

DeUaration ts Syntaiobil Siuayih


datatupt vaa(ablLname;hs

NOE:Can de clAe mctiple vaiabus by c0mma


8eperatoi y
’ Iniiaisatio;

Asigivg a vaue at the thime of declaration ís


th

’Assigment:
Asiqing a vaue to a va table rom the
time OwaYs second

4. Dnstan ce

3. Static
stance voiable: h K O N h
Decaain9 the viable in the clax
meehod ic caued nitane vaalable
adOusidethe
int a; Jnstance Nariable
psum LStingargscI) {
Samplsnesangl)

SUystenn.out rint (a) ;


Satt)
3
Soy J,a);

can be accesible thovghot the pooram.


2OaU Variable:

a vriable njde the clas and inide the


Defi ning
ca variOble
metnod or bloC is caued do
ing.
The oca Vasise must be iniiaized betore occes
SUOPe R itetine: wiin he me Hh0d oY withi he bDCK

’Static Vaiables

befinung a varioble inuide th las, ots


idetheMetnOd
before the vartbie
Or bLock with t u stotic keuvord
dlecloutiOn is caled static variobley.
Clas samplu
Static int ai

NOTE : Por istanu vaiable the mermoy is aUocated


at the time ot object Chtating
we con instance vaiabes y using Dbje Ctn JlooiVtN
FOr staic variabes, the mmony is alocoted at th tine
aci'ng. Static vOibles are auo Coued au
class vaiable
ThestatiC yaniabieu an be oa (cessible by sing the
Las name

Static ivnt a;
Staicvoid n,()f
Sop("Meuo');

pubúc staic void main lsing


-orosC){

’ Method parametUS:
wnting a vaiabls at the thme of Mtthod
They at a jcind 0f LoCal VOriabls
deciaroti on,
SCDpe itime: within he
methodu
Eni static vofd M, linta,
int bl
inte -atb;

psvrm)f

Thu vaniblu are a siqned tb method


porameers at
the tme of invocaion,
’Armays:
An 0nay s a coue cion ot sinnilaitype of elements
Ioch wiu store in continous memory o atons
Anay ls a pre-defined causin Java which inheits
Cbiect clais and iwpuments Seriatizable, Clonable
interfaces

C0de Optimi|otiDn.
RandOm alcs.

Disadvan tagesi

4. single dimens io nal anayordib ihiUh


Singie oiymensionaL anay is esenti a ike typed
lements whete
but wihout space
kyntan i datatype g 2 t r 1 à)
int Cjas
an a n o y : tart
Aing the sit of
00ouyName =new datatype [sie]; i oanss
Lsi]
a new 0nt
nta-nlwfnt[s7
4inea daatupe Lsiz)
Name C] -nw 2];
D0tatype anay
Eramplei
las taendas Days ?
pubuc &tatic void moin tStinglI arq) 1
int month-daysC]- nlw 1ntlI2T;LA
month-days [D] = 31;
month.days [ 1]- 9 : ; b b o
Month- dayg [a

ACY]-31)Uhu
t CS= 30,
wntl onth -days L12]-31,
&ysem Out pintun ("Apil has'+ month.days te

Jnt int month-days ET- 3, 2¬, 3,D 3i, 30-


’MULi dimensional anayioi33re
pn
Pay ot anauys is known a muti cinensional
anay
Syntan: cotatype anaynam CiCJ- new dotatype
En: int aCit] : nw int (1][2]; CYDus]ou];
Decaanon: int ar101 14b2 o323
ho
ClOys TuwOD
public StaicVol a nain (Sting C1 args){
int at it 1 =new int I0S23pby
for lint i=0; jc4) it+)f
For Cint i=0j ieus i+t) f
for (intj= 0; j<sijtt) f
Sysem- Oupuintin ta0143+Y 4);
sysHem-0uutpintln ();

Combjne
CHDmewot)
comb 2arays into a
pr0gram to
g- write a java he Singu aMy.
ayYay and ietn
Singu
cass wD Df

You might also like