OATA AesTRACTTON
Albstrachion refers to the act of represenhng
essenhal featurer uthout nchding the backgfourd
dletails Tt helos to hide interna) implementahon
de tails thot are not relevant to the wrer: I+ s
relahve to the perspecHue of the vieuer. There
can be d:fferert ab stracion of an enhiy depending
on the vieo oiat of theusec.
ENCAPsULATTON
Encapsulahon is a mechanismthat binds ne doata
and code together into a single unit: Tt keeps
them both sae rom he otside old, prevenhng
any onauth0rized Gccess or misuse Access to the
data ono o code inSide a elars is shicHy
con trolled. Only he funchons hot are iaside the
class can aces data In nis Loay,the data
and funchons ore said to be encops wlotedato a
singleeaihy
INHERTTANCE
Inheritance is a poerhul mechanismby ohich.
one claSS acquicer the properhes oh ancther class
he comon class that getr iaherited is caled
the pa ent class or the bare cloassor the super
class. he clars that ioheit ironm the comon
class is called the child class or the derived cass
or the Sub class The inheritonce mechanisM molels
t poscible for an object to be specihe ins tance
d a more generi object T+ is avery poerh to
in the objeet - Oriented derign which enables you
to reuse existig code easily and fleibly Using
ioheritance you can fe progrersively build up
cacses oth ex ensive capabihtiesith minimat
efort. The capabilies ot each stoge are odaed in
a Clear and simple manner, moking the code
easy to manage and maintain:
Inheritance is transive means that oll the
ahbutes and benaiour ore pass ed down roma
porent closs to the childcbss and then trom the
child class to their children and turther.
PoLYMORPHTSM
Polymorphismis a mechanism by which you can
Send trne same message to diHerent oDjects, ond
each object can respond ina ditterent ay.
based on ts class
oR
Polymorphism is the abiky ot a ncion of an
object to take on muhple forms.
Tt helps in reducing tne compleaihy by ahouing
one intertace to speciy a qeneral ype acion
The code designed and orittn oith polyMorphie
capabiliiesis unafected by the oaddiion ot ne
types
Computer Cnap 7: In put in Javo
ComMENTS :
Comments are an imporant part ot a pr o4ram an
ere usually added to give an overvie ot the code
reod
and provide addhona informohon toot 1S not asi ly
availabie init: The primary purpose ot comments
is to document the cde so that even a layPeson
can understand the pue pose the ariten code
hey ae ignored by the compier and do not atfeet
the program eyecuhon:
," STNGLE LTNE CoMMENT
It is the simplest comment in Tava that appeacr
in a single line ()
MoLTTLINE CoMMENT
They are reauired to exploin the ogie oto program
(/and * )
DocumENTATION ComMENT
It is a special comment thot loolks ike a muiine
comment It is qenerally used to genecate externat
documentahioa, olbout the source code. The cempiler
iqnores them just ike othec comments I** ond
INPUT UsTNG INTTIALTZATION
By iniializing voariables with the desiced values. The
reguired daa iS decided before the program
execuion starts Whernever a progromer needs to
get an output using a d:ferem set of input valbes,
fheprogrom has to be modifed and recompiled.
INeUT USTNGPARAMETERS
Required doto is deided at the hme of ex ecuhon
Ihe alwesused in the
method call ore ocquired
hrom the user shen the
program is eecuted
LNPUT UsTNG
SCANNER CLASS
lhe Scanneris oa closs in
thne ava uhl packgg
that Can be used to occept voious
types ot
inputs
" STREAM
Asreom is a path along cohieh the data ftous
It tronsters data from a aource to a des hnahon.
The keyboard uses special streOm called
Susterm h to trancfer he entered dato to ih
deshnaton. he ottput oi this shreom is in bites
Sys tem in stYenn is lknown as the Standoard
ioput
GCANNEA CLAss
Reads the inpt data fromm astreor and convert
it into valuer ot uariaus dota types Making it
easier for the pcoqrammer to rcad oll types d
numerie valuer shings and other typer of data
Tt Can be used to read input froi the lkeyposrd
a fle ,a shing or any other source. T+ brea its
input into token using o delimter pattern A delnie
Seqwente more chara cttrr that
se perates uo tokens. he defau lt delimiter is
whitespace
ERRORS
Errors ore mistalkes in a progrom that prevent it
from it normal
ormol orking.They
workinghey ore tea reffered
to as buge
" SyNTAx ERRORs
Synto errors occur due to the fact that he synta
Progromiag lanquage has not been folled
coccecty
Synta is the arrongement ot tokens to creote ocllz
formed stotements in a programming \anguage.
" RuNTTME ERRORS
Runimne erros 9ccur during the exeeution o a
progrom. The program may comple suceestully but
may not run
execute at al)l. properly
Hence
as planned or
we con say
may not
hat tne proqram
has crahed
Runime is ahen a proqram is runing r
ereeuted. cbeing
LoGICAL ERRORS
Logicol errors occur shen the progrom comples
and uns ithout erors but Produces on incorrect
result. It is caused by a mistalke in the
program logie, oich is ottea due to homan
error. They are the mast difficult to ix because
you do not 9et an error messoage as no Syntax
funhme ercor has OccUred.
PAcKAGE
Hpackage is a named collecion of Tava classes
that
ht are qrovped on the basis o their tunchonal;i
Jova proider a number of built in e hods and
feares that are all stored in o nomed pockage
hese pre-riten classer can be easily Used ia.
your pro 980M Eq : Jov a: uhl, java l×ng,inclvdeS
ete
The fully el name ot a class
its pack aqe nome. L+ coul be a tedious tac k
to tyee Tong, dot - seperaled name every time
USe the chst
clo . For this reoson, Tova
provides a feace called import statement to
bcing certain classes or an enhre pocikage iato
the currentpcogram
ADVANTAGES.
4) Packages qroup reloted closces So that tey
can be monag ed effechvely
2) The classe contoned in other pockager Can
easily be reused
3) You'can declare mlp)e chsses th the
same nome in dtecent packaqes.
43Encapsulohon can be implkmentedsing
packagei.
Computer - Chop -Mothermahicol Librory Methods
code withino
h method is a nomed block ot a
ot inctruchons
closs. T+ execUtes a deined set dehned by tne
method
A user dehned method is a
urer itreif.
ds or built in methods are methods
Lbrary metho
dehned Dy the Jova System developers.setp andore
These methods are poart ot the Tava
lob)e to oll JavaPcoammers in the torm o
Qvai
packaqer
Package jaua long Dy Tovo afe
The basie lang uage toncHons suppofted
cotains coss er
storet in java \ang poaclcqqe.It
tudomental to the Tava
and intertaces that are
ured
proqramming langage One ot tne most
classes in this pock ageis the Moth classuall
class
referred to as the Maths Lbrary. Thi(vonous
contains valuo ble methods ued in
mothemaieal expressions
Metnods ot Moth class
The Math class of tne java. lang packkage contain
ageneric mathemoical unchns incwding the
lot cf
qeomehic on trigno merie tunchons.
Method Syata Short deseripion
po Moth pou Returns the volue_ of the ficet
argument, raised to the pouer
the see ond argument
do
Moth Sqr) Rerns the sa ware bot of oa
yowe double volue
cbrt oth cbrt l Returnstne cube root ot a
double Volue
cei oth-ceil() Rehrns tme smalert integer ihat
S qreoter than or eaual to the
Ocgument
foor Moh ftoor() Retirnstne sargest itgtr thatií ess
thon or eaual to the argvment
rOUnd roth roundlu) Rehurnghe clorest int o( \ong
Moth dosla) Retnsthe abrolot Value ot the
Orqument
ma Moth-ras la, b) Retorne the largert of the tu0
arqumer
Moth ininla, b) Retürns tne Smallet ot thne tuo
arguments
rondom Moth rondoml] RetYns a double volwe qreder han
or equol to O:0 to and 1ess than 1-0
Math P Returs the volue ot PE Ne, he
raio of thecireumfe rence ot
a circle to t diameter: