0 ratings0% found this document useful (0 votes) 36 views24 pagesJava
Copyright
© © All Rights Reserved
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
miming : Obfe
a4
a, Ov oojeus ,vaith
punchony 0nd logic An Objeur, Con BE defi
data hetd that hou unique ott bul and
oop focuses onthe objeus that developers |
manipware 7ather than the logic yequivd
sae
mani put atte them:
is d programming. obj et oviented programmiry
Sbrnehwred programming ts onjeur ovenked programming
gene whieh focuses | 18 designed which Focuses.On
on process | log ica | dato
(huuthive and then dala} objelt pyiented POganmIng
neguryed tor tina proces | foitows bob om Up approach
srrucruned proqicunmning| ppp ect pviented programing
follows op down a suppoyd inheritances
| encanp (Aba ON, apphag
stnuut N ning |
nucruved: programening i. jotymorphisMD ge
ented
aiurded
Known asmodutar fo
programming and 4 jubieh | Jn objctt 0
) procedaceet programed) prog OF
lanquaye sm
ain Srucrved prog ray yi
program are dmded iu a '
Gnd inweate qu
and deuelopment time Of
Com puter program ‘es
at Simply focuwe on functors
cunnd Procemes tev usually
work on data (
Tt provider tow Meni beh ty and Ay
Absharkon a compared to tn big:
objet oviented Programming "PRR Mograrnrang,
TE CS move diffi CULE fo modify Sei ey {PULL fo rod
Shiucrued: program and »Cule ‘obey gHented proqpanny
Code ai compared fo ObjeE \reLUNE Code Os mmpaned |
orenkd propa Shruchoved prrogvarns
Tt Give more importance oF VIE Nich Mose TMporrance
(og dato,
Shuduyed Progy amming ix 00 pits, raore. secute Wika
fer cee ob fa) fa dara hiding feature
Way oy data hiding porscan ole ene
Programs.
hove Gbsha thon and moe
‘OD abshachon and ton Hen bilihy G
Heni bility
4B explain the oops prnaplesin detai) ;
ENcOpsULahON :- encapcutahon’ ithe" mernenism that
binds to.gUhe lode and rhe data I moinipuletter and
keeps both sate fom oubide inkvtérence and mecuse
one way fdhink bout cna@piwerbon 4 @ protechue
wrapper that jnevenh the (de and data tw, being
arbiravily accened by othe Code defined ouside wya
Stuchincd Programming can
Modercely omplex programs. Techn Cally Wn
oy 0 houn hectdlen from any
ce OM only fhyouyh an evi
mnwhtth They are declared ate
authe varrable! Inthe dom
publea meray In 4he clan #9 seh and
veo ables
dechoutng
wyihng
values 4
Inheritance
qnhevitanc
the propernes 4 another ob,
uc it suppors the concept 6) hierar chal
andicahon: Inhwitaince §6 aprocen 4 decking
anew clan boued on entshing aan by eaten hg
is common acre membeu and methods. inheritance
(ows Wh ALLE 4 tocle, {ure xewabililay
ana application the parent clos U Ue
the child law thak
lous
demeect Claw by sub Ula
AA
whith one Objeu aq
e isthe procem by t
jer TiC imponant
in Your J
base eam On supe! (
the bove das 15 caued
thitel cles :
Polymorphism i o oe .
roiyrnovphiam (rom Greek neon gi a
wee be wed 1
iy So dearer Arnatt
g achor
auiows one In
a genevel clawPhrae
Anal TEAS pots
Qrlared achures Thre he
altouing same intotace
RtyPE & polymorphiim ‘)
WW) Run hme polymorphitm
Jeompile Hime poly mor hima
Ayplved duving compiler Hime tl
Polymorphesm d
WH) Runtime polymorp him :- gt hoo Methods ace
hautng jame name and same avgumenk auatlas
in the ‘Biperdlous anal Sub clan Amen wt cal thole
Fretnods. cue ouetriclen- TN aD RABOUT Nay ayng
method dispourch
2A. Explain bricHy about the arrays implemented fl
Faira with example :
An away iC a gy0UP of like typed Vanables that a
Acfened toby o common name Away! A ony ty
canbe uealtd andmoy have ne Or More dimenid
A spectre Clement inan anay accemed bY it inde
ava OFC a Convenient meen ) Grouping relaredl
in 10 ymahon
one dimensioned avrayt
A one dimensional auay It Mentally ,a (I(t o like
hyped van able the gencral PM 6) a one drmengfonll
ot oy qecbouanon Is
Van .
aype vau-na “Cd;
y
y
Mule
Im Ja
BYYCLYS
au lik
MULE ¢
addi t
int
Examp
Chua
Publi
tfuneral a
In Java, onli imeryional aways @
Lr dimenaton
ele Cuble, Speuty.
ro stk e
additonal '
int RooDL ILI = NEO
Example
C10 Ton May Bs
Public 1 a
tka woid main (Shing a
int wo Ol IE9= NONE (uate
int 4, {/ ete
;
Forti o, au; 14 ai)Rh: program generale the Iniiowoing OU ,
bi Aeey ;
prec ee
ot eb y j a
i te 13 (8 [4 J
when you aLlo“ats memory for a muthidimensronal @
You need only Speerty the memory tor tire Ast UF
dimension: You tan atiocate the xemaintng dime
2B Explain Abou the tava Buzzwords ’
Java buzzwords cue simple, secure, poneble, objece
onvented ; Robuut, HWKthicaded, Arhriechuc neubal
oa High Peformance, pithibuled , dynamic §
imple
qoua was deigned to be Casy 40% the prvfenonad
proguarnml ng to learn and use CHeehively becauye
java inhurk Me cert Syntax and many othe
jbjcur oven ea RMA oot +. mma Pangrounmg
or Imite frowble lecuning, Java
sented
oyet ore ad tne java 1am athe heedom fnderign
ie slate. one outcome 0) this Was a lea
wiwhich allows
Things semulraneowly
Ache newhal
A centras the doy the Java aeignes was
cae longeuityand ponrabilthy- one of Hhemain
programmes is that n0 quay anice enti thar
wriea program day, I wilt un monn
tt you
ven
anteyprehed and-irgh pee
onthe $a machine |
vance :
hon § Loss platform program
vale vepreentohon
pde-thil ade can be Exccutedon
temenh the 4UH Java byiccode
pit would be €0uy
mathme (de for
ne me
aug enabie the Hea
by compilin inh anintumed
auicd jauc byl cl
any SysKim tak
ft vay (orefullt aciqned Jo na
fo harulare arcttly trp nalie
using a just t
minew
/ y hig! performance by
Compltler
Dist puted «
1 ty desrgned Joy diyti buted anuivonment OF the; *
DYING, 05. iene Te
Tava programs cay with Ther
UNkme type information thal A
Gnd yesolve Accenes tp objec4 bean
Posttbie to dynamically sink code nm a
enpedient manner
3 dives about the cr Het Pypes 9 “nh
with gampls ., naan
“anhuitance can be detined ay ine proceduve CY Sua
mechanism q acquiring authe propernes an bi,
behauicy g) one lan fo andthe ye. ACQuInnG th Sys
Propehts Gnd behaviour & thild daw tom pa Sy
claw the concep! Was buleD Athitue the ii S
aduantaye..< “eahing a nel chars tha, gy D 5
upon an aleady entihing cautery 0 mermnlyt Mutiap!
407 Code Aowabilny within A TAWA program, the to
Single inheritance. When aclous ertends Anohen Clay
lan Only then Wwe COULTE a (ingle Inhemttance. intey,
Example:
clays Calecueloy {
ink addline a, int b) 5
t. atturn ato, eS
j A e: °
int div int a,int b) Pe
\ ae Alp - ov}
7
; j
public
Advanced Caladalor
Sytern-p ut: print, (cal adaly2)),...;
System. ou: parting (at-(whl,2))-
System. os pontine mul',2)).
printin( cold vy a9).
ve
Hohe woid main’ Shing arguiays
val new Adianced Cal adalon
pue
System Ou -
eh bull Pe 4
Mulhiple aphenstance- ‘ruleple inhentance yeln
one an Lucnding more than one bare]
the concept 9)
be implemenka throug h inkuacer
Clay. >t Can
ineyface A
4 pupire vord aifCint num);
J
neviace B
: public wid dip cine nun)Public claw zest entendy NUE 7
{public trate wid main( sring sat
1 nwt mie new nul);
m)- dis (10), x
m1. difp(eo),
a) y
3-nulhlevel inheritance: Mulblewe inheritance x¢fet C10
fra mathantim in ob kehnolog y whe, ONC Can. « -
Inherit tom adenued law thereby maki ng thit
denved clan tne barectays For he neo Ua
clan A }
J public wird da At) “ta
{ - wa uy
4 SyoHeen-oul printing Mdascasl); | {
y y
Uan pg entnds A
{public Wid ANBLD a
{ Sy stern-our-println (class ey
y
5
4 c. eienels,j ‘ae
—cvarchual Inher fence: ans
one Law TE Inhewled by many §
tx. OM A —
1 public void method aC) v
L so-p(method 4 are A);
y 5
clos B entencls &
t public “old method ®()
L s0-pC" method q 40% 8"),
J d i
claw C enttnds A
1 public Word method’ c)
System oul Printings method gan 9}
4
y
if -b cntends A
public Word method DC)
L s-0°p ("method 6) laws pi:
y
clam Java € xample
public (rahe cold, mann (Sring argseDsu 4 iY es
{ pubirc vord dupe)
ft SOP CMe,
igh) :
(tay A exlends ©!
public word APC)
{ $o-pcta"-
5) _
dan B tntnds C
1 pubic vord AapC)
J so-plle),
ye
clo D tntends 4
1 publre word AMtpC >
{ System. ow! poniinc" pb"),
a
y
public Shahe vord main (Sing aygst J)
b Obj~ new 0). ’ ,
Obj. displ).
y
J 4 about the accen prokhons In dawa
Ly DISae
writ
phe acl
py sore
tne program on inkuferces
ey moaiticu m Fata specttCs the Cecesibild
4 ateld, method, Gonitnur or dadre the
7 aye: at you 40
iil be the devout aint a
‘quel 6 A Pro d
d oudtde ‘the raced "
orded: the aces
nin the parkaye an
child wow
the acce leud 6 & public modal
y. publfc
Hrcanhkt ama wom with the Claws
#A ywnee
LTnevtace
ymiatace looks tke (Low bur TE noPadax Onive
can say an iniatace inqaia is \aibluepane y
1 low OUD On intatace fla efecnte type in Tava.
orutank and abs haut method
anti f athitue
ab(nau methods ™
ody. 7 Wed fo
has stab’
intatace Inqaya fy a. meth
jreauhon. There (CON be only
¢ 00 interface, Nok method bi
absrrachon as ue Os mutttple
te In tae wting an tinfetae 1”
9h eta UL a CLOUs, descul bea the
Ache
inheiban
“imtlas to wnlng
fa ond behcviouls 4 an object and an
intergace ontatm behauiouu thar due athually_ aur» Alio the tata bles declaneer ©
~ snlatace au public stare and fal bY
Tmplementakon 6) interac
mntatace Area t
wah final Hoat peut; ©
Hoar gtkArta (Float 2, Hoak y),
By rectangle ‘implement Area ¢ ymple
public Hoar gethreaHloat x, float yy ¢ Run
otha (4 +Yy)- : of ap
4 ‘ ium
, with
cham, Wiangle implement Area $ wa
dT? ¢
Chetan 9¢t Area (float 4, “Hoar y) han
E aid TY Ay con
@ &
J dit
clam Cydle implemen hea } a
public Hoot gut Area’ Hoat 2, Poa y)
a3 yeh PX X* XY;
actJ
sous about the java excephons. and ‘progam b
y
5 DiS
throws and fnally
amplemenk encephom We
Runkme e710
pf aprogam thok disrupt the normal 7100 OF
rubra drrom €xcepron handling # ahi ‘help you ae
any unexpected ov ‘excepHonal srughon thar
with 7
pcou ushen a progam uni ng is alied Excephon
handling
Common suenarios Where Encephons, MOY OCCUY:
Awe
@ Scenaud wi i
i” Wid ‘where ArithmeHe excephon occurs: dF We
ditide ar
ee any number by 2evy, there occum an
avithmehc Excephon
int vova= 50/0 ; ,
1 M
» Scena i
( Scenawio whtre NU pointy Exceptron occun: Tf Ue
haue nu value inany vanable sPertorming any
occur during the excep éacwHOnring Sinn ge Mabe! ee
Int = Inkeger. pancant Uhrg);
d scenario whee “Avay Ender ouror Bounds Excep
occum: JF you au imueding any value Inthe
iMdex, ft Would ruth Array Inden OU oF Bouma
éxcepPon a vhown | ; oo
int anayl} new int CsT-
ayvayl to] = ay
Following tthe Int @ raweunchecked Runth
fucephon 7
Arraystore Excephon: Aygnment fp An andy cle
§) Gn ‘neompahible tyre JEU Cauied when a Pry
ines bp Howe wong type ) date in an anay
Clans casPexcephon: Invalid cash JP IS an
encepHon hak can occur wohen you My bo
pmpropenly Convat aUan trom one hype bo
anothe
filentot Found excephion:. this excephon ty
waned when Aleis Not acentble 0 docinae
open
Number 4
a tng K
Runkme
occuy di
secu
shingt
OK Ide
Follow iT
clay Nlo
Mlegad 4thea HOE ES
mparble wt th the © ‘a
out of BOUNG EncepHion: some
) bounds :
ue Arn aly gite FaceplTOr: Parag Ge
afi
; rue $i2€ {
poinky exce pron: anvcauied use Mull refeneme
nber format excephon : anvalid @nvenion
rq to 6 numeye jorrnal
qhmme excephon: Acuent any €xceprion Whi
(CUM during yuntime vt
tecsathy excephon: Arempl tp widl ve secu vily
hing nde ouret Bounds: Altcmpe to Inder
ide the bound Qa thing
Followmg Gde checked €xcephiom they are
clay alot Found Excephion, Clone dlot Mes excepial
Miegal acces &cephon, Isanhahon excephon,hun ie
}
Public srahe vord mam(shing 41gsl3)
Throws Example Obj = new Throwseramplay
tm f
Syttem-ow print in(obj. division (15)0))-
cath ithmeh ce tcepon ¢): { '
Sysem.our paintlnc” you thoutdn't divide. by cool)
5 7
4
J
7 } ma 4in
Lmplementahon OY gdcephovy WAIN nests
(tans Finally example
1 public oie veld main (Shnge 7
{ c
| IAF alje\new ‘intra4
args)
SOP ("OU 6 try").
? T acees th veut A
2 seo ( ACO Invalid Clement ‘ce
A. exp
!
along |
the suf
whith
whenel
jnjrar
ath
Yiage
+ Supe
TM
4 Sup
clay
* Sup,
clase
The
Wo
Th
Vai
fromexplain in detail ¢
ong wile Ean ples
wpe ceyword In 34M al a
wcqee immedi le
cate the instance OFF
can i ueadcel Impl
refuence vouiable
the
ohrth wed 10
newt oud
sryrance a parent
atened by Supu-
Wage oy Tae Yup. keyword:
- super can be wecl 1 seer ionmmedt ate
nance variable ,
1 can be wed to inl
‘ie
ot
yode
oke mmmediak pavene
+ Supe
clay method
Super() can pe wea fo invoke”
(ons udor ,
mnmnediake Parent
clas
The tuper KeYWere
to the pagent clan
{ in dave att like a ectuene
oui dole
“1h is moun WF
Vari able, method
hom snqaerved (tan
th actena
when we wan
the baye dal!
oY commpucoy ina er Keun
dete 1 dared lan
TE num= 30;
3
Clam pened enends Boel
int num= 20;
void calitnd()
S0-P(" Bore NUM ” + super NUM),
Sop (" puived num:” #num)-
A } 4 TavoKiINg |
clam Turd also be
public skahie Void main( Shing CI args) t Clo4s Ge
perived emp new benved ) ia)
50° PC
dtmp- callthis¢ y
y ; y
Buoking hcye claws method: Wher name B hunle clon
Behe Jomein both bduve and dered an pevived
Suporl
Pe CON be witel Wy Thuoke bove Clan orethod ic
4 “0-7mie hoe clas constrrctor = Saper
be wed fp invoke pooent Cons cobuday
so Lae
it
N
aio
yt
Bode) i
50° pC" Bare Cass combat),
y
“OM bevived. colends Baers
pevived () {
Sup or s
S-o-p (" pared cous consrutty "')s
i
y
y
clam teak {
pubwe stake wold mar (Sing av95 C4)
{ hermed HMP= Nuw bemuedie J
Mra a variable is aurrgned only gi
mutabie we can change the (onter
dehined cy final
The Keyword final i
want fo we the tinal keyword
bedore avariable, method and Was
use q Hina Keyword with avaiable
Avonable edn be devlared as final bY wing
1 anon accent modihel
we mut spea
Fnal keyword
tinal double pre ;
final int Gunt=s-
sraht final double pr'le;
fare tHnal double pr z3-14l,
Oye Q tina keyword with a métnod
Bomethod prthix with the Keyword Final i
mown @ dtnal m¢ thod
bend
Dymo! void display’)
a
S07 (" jnside inal method "),
eLo-p(" th Ww 4nd
j
y
clan B crtnd Ad
votd meth()
tu rpy! can Overmde
Lo p(" tilegal").
Z,
=
Z
hie method oventding ft ONE Q davay most
will be ime when you
jrom oclu ving To 4 alloe
speerty final a
powerful decane, Thee
wilt want h prevent th
amerhod Tum being ouerndtn,
a mode ad the stall 6) th deviarahon
Einhevilance
vsing fmaf_fo preven
want fo Iceni a ua
(ys thoulel be d
fomeim a You well
inhe nie
be hg
with Anal BegOr”
OOO Tunna’ cle
iB expends As)
tl ty
j