Unit 1- Basic concept of object-oriented-programming.ppt

hannahroseline2 201 views 56 slides Jun 29, 2024
Slide 1
Slide 1 of 56
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49
Slide 50
50
Slide 51
51
Slide 52
52
Slide 53
53
Slide 54
54
Slide 55
55
Slide 56
56

About This Presentation

Basic concepts


Slide Content

UNIT 1
FUNDAMENTALS OF OBJECT-
ORIENTED PROGRAMMING
Basic Concepts Of Object Oriented Programming
And Java Environment
By
Hannah Roseline
Assistant Professor

Introduction To Object Oriented Programming:
Object-orientedprogramming(OOP)isaprogrammingparadigmusing
"objects"–datastructuresconsistingofdatafieldsandmethodstogether
withtheirinteractions–todesignapplicationsandcomputerprograms.
Programmingtechniquesmayincludefeaturessuchasdataabstraction,
encapsulation,messaging,modularity,polymorphism,andinheritance.
ManymodernprogramminglanguagesnowsupportOOP.
OOPWhichformtheheartofjavaLanguage.
DefinitionofOOP:
Object-orientedprogrammingisanapproachthatprovidesawayof
modularizingprogrambycreatingpartitionedmemoryareaforbothdataand
functionthatcanbeusedastemplatesforcreatingcopiesofsuchmodules
Ondemand.

Programming Paradigm :
Aprogrammingparadigmisafundamentalstyleofcomputerprogramming.
Paradigmsdifferintheconceptsandabstractionsusedtorepresentthe
elementsofaprogram(suchasobjects,functions,variables,constraints,etc.)
andthestepsthatcomposeacomputation(assignment,evaluation,
continuations,dataflows,etc.).
Thecombinationofdataandmethodmakeupanobject.

Basic Concept Of OOP:
Object:
Objectsarethebasicruntimeentitiesinanobjectorientedsystem.They
mayrepresentaperson,aplace,abankaccount,atableofdataorany
itemthattheprogramhastohandle.
Anobjectisaninstanceofclassthatallowsprogrammestousevariableand
methodinsidetheclass

Object:
•Objectisanruntimeentity.
•IsanInstanceofclass
•RepresentsaPlace,Person,anythingthathavesomeattributes.

Class:
•Objectcontainsdata,andcodetomanipulatethat
data.Theentiresetofdataandcodeofanobject
canbemadeauser-defineddatatypewiththe
helpofaclass
•Aclassisablueprintortemplatefordeclaringand
creatingobject.

•AClassisa3-CompartmentBoxencapsulatingData
andFunctions
•Classname(oridentifier):identifiestheclass.
•DataMembersorVariables(orattributes,states,
fields):containsthestaticattributesoftheclass.
•MemberFunctions(ormethods,behaviours,
operations):
Containsthedynamicoperationsoftheclass.

DataEncapsulation:
Thewrappingupofdataandfunctionsintoasingleunitisknownas
encapsulation.
Thedata isnotaccessibleto the
outsideworld, onlythosefunctionwhicharewrappedinthe
canaccessit.
Thesefunctionsprovidetheinterfacebetweentheobject’sdataand
theprogram.
Thisinsulationofthedatafromdirectaccessbytheprogramis
calleddatahidingorinformationhiding.

DataAbstraction
Abstractionreferstotheactofrepresentingessentialfeatures
withoutincludingthebackgrounddetailsorexplanations.
Sinceclassesusetheconceptofdataabstraction,theyareknown
asabstractdatatypes(adt)

Data Encapsulation And Abstraction:
•Dataencapsulation,sometimesreferredtoasdatahiding.
•DataEncapsulationandDataAbstractionisoneofthemost
strikingfeatureofobjectorientedprogramming.
•Thewrappingupofdataandcodeintoasingleunitiscalled
dataencapsulation.Thedataisnotaccessibletotheoutside
worldonlythosefunctionswhicharewrappedintoaclasscan
onlyaccesstheprivatedataoftheclass.

Inheritance:
•Inheritanceisoneofthemoststrikingfeatureofobjectoriented
programming.
•Inheritanceistheprocessbywhichoneclasscanacquirethe
propertiesofanotherclass.
•Thenewclasses,knownassubclasses(orderivedclasses),inherit
attributesandbehaviorofthepre-existingclasses,whicharereferred
toassuperclasses(orancestorclasses).Theinheritancerelationships
ofclassesgivesrisetoahierarchy
•Inheritanceistheprocessbywhichobjectsofoneclassacquire
thepropertiesofobjectsofanotherclass
•InOOP,theconceptofinheritanceprovidestheideaofreusability.
Thismeanswecanaddadditionalfeaturestoanexistingclass
withoutmodifyingit.

•Asuperclass,baseclass,orparentclassisaclassfromwhichother
classesarederived.Theclassesthatarederivedfromasuperclass
areknownaschildclasses,derivedclasses,orsubclasses.
•Inobject-orientedprogramming(OOP),inheritanceisawayto
compartmentalizeandreusecodebycreatingcollectionsof
attributesandbehaviorscalledobjectswhichcanbebasedon
previouslycreatedobjects.

Polymorphism:
Polymorphism,aGreektermmeanstoabilitytotakemorethan
oneform.
Anoperationmayexhibitsdifferentbehaviorsindifferent
instances.Thebehaviordependsuponthetypeofdatausedinthe
operation.
Forexampleconsidertheoperationofadditionfortwonumbers;
theoperationwillgenerateasum.Iftheoperandsarestringthen
theoperationwouldproduceathirdstringbyconcatenation.
Theprocessofmakinganoperatortoexhibitdifferentbehaviorin
differentinstancesisknownoperatoroverloading

BenefitsOfOOP
OOPoffersseveralbenefitstoboththeprogramdesigner&theuser
Throughinheritance,wecaneliminateredundantcodeandextendthe
useofexistingclass
Wecanbuildprogramsfromthestandardworkingmodulethe
communicatewithoneanother,ratherthanhavingtostartwritingcode
fromscratch.Thisleadstosavingofdevelopmenttime&higher
productivity.
Theprincipleofdatahidinghelpstheprogrammertobuild&secure
programsthatcannotbeinvadedbycodeinotherpartsoftheprogram.
Itispossibletomapobjectsintheproblemdomaintothoseinthe
program
Itiseasytopartitiontheworkinaprojectbasedonobjects
Thedata-centereddesignapproachenablesustocapturemoredetails
ofamodelinimplementableform.
•.

Object-orientedsystemscanbeeasilyupgradedfromsmallto
largesystems.
Messagepassingtechniquesforcommunicationbetweenobjects
makestheinterfacedescriptionswithexternalsystemsmuch
simpler.
Softwarecomplexitycanbeeasilymanaged.
Whileitispossibletoincorporateallthesefeaturesinanobject-
orientedsystem,theirimportancedependsonthetypeofthe
projectandthepreferenceoftheprogrammer.Thereareanumber
ofissuesthatneedtobetackledtoreapsomeofthebenefitsstated
above.Forinstance,objectlibrariesmustbeavailableforreuse.
Thetechnologyisstilldevelopingandcurrentproductsmay
besupersededquickly.Strictcontrolsandprotocolsneedtobe
compromised

ApplicationofOOP:
•Real-businesssystemsareoftenmuchmorecomplexand
containmanymoreobjectswithcomplicatedattributesand
methods.OOPisusefulinthesetypesofapplicationsbecause
itcansimplifyacomplexproblem.Thepromisingareasfor
applicationofOOPinclude:
Real-time systems
Simulation and modeling
Object-oriented databases
Hypertext, hypermedia and expertext
Al and expert systems
Neural networks and parallel programming
Decision support and office automation systems
CIM/CAM/CAD systems(computer Aided
manufacturing)(computer aided design).

About java:
•Java isa widely-used programming language for coding
web applications. It has been a popular choice among
developers for over two decades, with millions of Java
applications in use today. Java is a multi-platform, object-
oriented, and network-centric language that can be used as
a platform in itself.
•Java was originally developed by James Gosling at Sun
Microsystems. It was released inMay 1995as a core
component of Sun's Java platform.

Java Features:

TheprimereasonbehindcreationofJavawastobring:portabilityandsecurity
featureintoacomputerlanguage.
•Besidethesetwomajorfeatures,thereweremanyotherfeaturesthatplayedan
importantroleinmouldingoutthefinalformofthisoutstandinglanguage.
Secure•Whenitcomestosecurity,Javaisalwaysthefirstchoice.Withjavasecure
featuresitenableustodevelopvirusfree,temperfreesystem.•Javaprogram
alwaysrunsinJavaruntimeenvironmentwithalmostnullinteractionwithsystem
OS,henceitismoresecure.
•Noexplicitpointer
•JavaProgramsruninsideavirtualmachinesandbox

4.Simple•Javaiseasytolearnanditssyntaxisquitesimple,cleanandeasytounderstand.
TheconfusingandambiguousconceptsofC++areeitherleftoutinJavaortheyhavebeen
re-implementedinacleanerway.•Eg:PointersandOperatorOverloadingarenottherein
javabutwereanimportantpartofC++.
5.ObjectOriented•InjavaeverythingisObjectwhichhassomedataandbehaviour.Java
canbeeasilyextendedasitisonObjectModel.•Robust•Javamakesanefforttoeliminate
errorpronecodesbyemphasizingmainlyoncompiletimeerrorcheckingandruntime
checking.ButthemainareaswhichJavaimprovedwereMemoryManagementand
mishandledExceptionsbyintroducingautomaticGarbageCollectorandExceptionHandling
6.PlatformIndependent•UnlikeotherprogramminglanguagessuchasC,C++etcwhich
arecompiledintoplatformspecificmachines.Javaisguaranteedtobewrite-once,run-
anywherelanguage.•OncompilationJavaprogramiscompiledintobytecode.Thisbytecode
isplatformindependentandcanberunonanymachine,plusthisbytecodeformatalso
providesecurity.AnymachinewithJavaRuntimeEnvironmentcanrunJava

Secure
Platform Independent

Java and c++:
Comparison Index C++ Java
Platform-independent C++isplatform-dependent. Javaisplatform-independent.
Mainlyusedfor C++ismainlyusedforsystemprogramming. Javaismainlyusedforapplicationprogramming.Itiswidely
usedinWindows-based,web-based,enterprise,andmobile
applications.
DesignGoal C++wasdesignedforsystemsandapplicationsprogramming.It
wasanextensionoftheCprogramminglanguage.
Javawasdesignedandcreatedasaninterpreterforprinting
systemsbutlaterextendedasasupportnetworkcomputing.It
wasdesignedtobeeasytouseandaccessibletoabroader
audience.
Goto C++supportsthegotostatement. Javadoesn'tsupportthegotostatement.
Multipleinheritance C++supportsmultipleinheritance. Javadoesn'tsupportmultipleinheritancethroughclass.Itcanbe
achievedbyusinginterfacesinjava.
OperatorOverloading C++supportsoperatoroverloading. Javadoesn'tsupportoperatoroverloading.
Pointers C++supportspointers.YoucanwriteapointerprograminC++.Javasupportspointerinternally.However,youcan'twritethe
pointerprograminjava.Itmeansjavahasrestrictedpointer
supportinjava.
CompilerandInterpreter C++usescompileronly.C++iscompiledandrunusingthe
compilerwhichconvertssourcecodeintomachinecodeso,C++
isplatformdependent.
Javausesbothcompilerandinterpreter.Javasourcecodeis
convertedintobytecodeatcompilationtime.Theinterpreter
executesthisbytecodeatruntimeandproducesoutput.Javais
interpretedthatiswhyitisplatform-independent.
CallbyValueandCallbyreference C++supportsbothcallbyvalueandcallbyreference. Javasupportscallbyvalueonly.Thereisnocallbyreferencein
java.
StructureandUnion C++supportsstructuresandunions. Javadoesn'tsupportstructuresandunions.
ThreadSupport C++doesn'thavebuilt-insupportforthreads.Itreliesonthird-
partylibrariesforthreadsupport.
Javahasbuilt-inthreadsupport.
Documentationcomment C++doesn'tsupportdocumentationcomments. Javasupportsdocumentationcomment(/**...*/)tocreate
documentationforjavasourcecode.
VirtualKeyword C++supportsvirtualkeywordsothatwecandecidewhetheror
nottooverrideafunction.
Javahasnovirtualkeyword.Wecanoverrideallnon-static
methodsbydefault.Inotherwords,non-staticmethodsarevirtual
bydefault.
unsignedrightshift>>> C++doesn'tsupport>>>operator. Javasupportsunsignedrightshift>>>operatorthatfillszeroat
thetopforthenegativenumbers.Forpositivenumbers,itworks
samelike>>operator.
InheritanceTree C++alwayscreatesanewinheritancetree. Javaalwaysusesasingleinheritancetreebecauseallclassesare
thechildoftheObjectclassinJava.TheObjectclassistheroot
oftheinheritancetreeinjava.
Hardware C++isnearertohardware. Javaisnotsointeractivewithhardware.
Object-oriented C++isanobject-orientedlanguage.However,intheClanguage,
asingleroothierarchyisnotpossible.
Javaisalsoanobject-orientedlanguage.However,everything
(exceptfundamentaltypes)isanobjectinJava.Itisasingleroot
hierarchyaseverythinggetsderivedfromjava.lang.Object.

Java Environment:

Java development kit:
•The Java Development Kit (JDK) isa software
development environment used for developing Java
applications and applets. It includes the Java
Runtime Environment (JRE).
•Javac(java compiler)
•Applet viewer(for viewing java applet)
•Java (java interpreter)
•Javap( java disassembler)
•Javah(for c header files)
•Javadoc (for creating HTML documents)
•Jdb( java debugger)

Application programming
interface
•Applicationprogramminginterface(API)includes
hundredsofclassesandmethodsgroupedintoseveral
functionalpackage.
•LanguagesupportPackage:
Acollectionofclassesandmethodsrequiredfor
implementingbasicfeaturesofjava
UtilitiesPackage:
Acollectionofclasstoprovideutilityfunctionsuchas
dateandtimefunction.

•Input/OutputPackage:
Acollectionofclassesrequiredforinputandoutputmanipulation.
NetworkPackage:
Acollectionofclassesforcommunicatingwithothercomputersvia
internet.
AppletPackage:
ThisincludesasetofclassesthatallowsustocreateJavaapplet.
JavaVirtualmachine:
Itisaprogramthatinterpretstheintermediatejavabytecodeand
generatethedesiredoutput
RuntimeclassLibraries:
Theseareasetofcoreclasslibrariesthatarerequiredforthe
executionofjavaprogram

•UserinterfaceToolkit:
AWTandswingaretheexamplesoftoolkitthatsupport
variedinputmethodsfortheuserstointeractwiththe
applicationprogram.
DeploymentTechnologies:
Javaplug-in:Enabletheexecutionofajavaappleton
thebrowser.
JavaWebstart:Usercanlaunchanapplicationdirectly
fromthewebbrowserwithoutgoingthroughthe
installationprocedure.

Overview of Java:
Introduction:
Javaisaobject-orientedprogramminglanguage.
Therearetwotypesofjavaprogram,
Standaloneapplication
Webapplets
Standaloneapplication:
Atypeofsoftwareprogramthatisdesignedtorunona
singlecomputerorlocalmachineoftheuser,withouttheneed
foraserverorinternetconnection.
Executingastandalonejavaprograminvolvestwosteps,
•Compilingsourcecodeintobytecodeusingjavac
compiler.
• Executingthebytecodeprogramusingjavainterpreter.

WebApplets:
Anappletisasmallprogramthatrunswithinan
application.Appletsarecommonlyusedtomake
otherwisestaticWebpagesmoreinteractive.Examples
includeanimatedgraphics,games,configurablebar
chartsandscrollingmessages.Appletsalsoplayan
importantroleinnetworkcomputers(NCs).

Simple Java Program:

Class Declaration:
•Declaresthenameoftheclassalongwithotherattributessuchas
theclass'ssuperclass,andwhethertheclassispublic,final,or
abstract.
OpeningBrace:
EveryClassDefinitioninjavabegingswithanopening
brace”{“andendswithamatchingclosingbrace“}”inlastline.
TheMainLine:
TheJavamainmethodistheentrypointofanyJavaapplication.
Themostcommonmethodtocallmainispublicstaticvoid
main(String[]args)It'sthestartingpointwheretheJavaVirtual
Machine(JVM)beginsexecutingyourprogram.

Public:
Thepublickeywordisanaccessmodifierusedforclasses,attributes,methods
andconstructors,makingthemaccessiblebyanyotherclass.
Static:
•Whenyoudeclareavariableoramethodasstatic,itbelongstotheclass,
ratherthanaspecificinstance.
Void:
•InJava,thevoidkeywordisareservedtypeusedmainlytospecifythata
methoddoesnotreturnanydatatype.
•Println:
Aprintln()inJavaisalsoutilisedtodisplayatextontheconsole,
whichistheparametertothismethodinString.Thismethodalsoenables
printingthetextontheconsole,andthecursorremainsatthestartofthe
followinglineattheconsole.

Java Program Structure:

•Javaisanobject-orientedprogramming,platform-
independent,andsecureprogramminglanguagethat
makesitpopular.
•UsingtheJavaprogramminglanguage,wecandevelopa
widevarietyofapplications.So,beforedivingindepth,it
isnecessarytounderstandthebasicstructureofJava
programindetail.
•Inthissection,wehavediscussedthebasicstructureof
aJavaprogram.Attheendofthissection,youwillable
todeveloptheHelloworldJavaprogram,easily.

Documentation
Section
•ThedocumentationsectionisanimportantsectionbutoptionalforaJava
program.ItincludesbasicinformationaboutaJavaprogram.The
informationincludestheauthor'sname,dateofcreation,version,program
name,companyname,anddescriptionoftheprogram.Itimprovesthe
readabilityoftheprogram.Whateverwewriteinthedocumentationsection,
theJavacompilerignoresthestatementsduringtheexecutionoftheprogram.
Towritethestatementsinthedocumentationsection,weusecomments.The
commentsmaybesingle-line,multi-line,anddocumentationcomments.
•Single-lineComment:Itstartswithapairofforwardingslash(//).For
example:
1.//FirstJavaProgram
•Multi-lineComment:Itstartswitha/*andendswith*/.Wewritebetween
thesetwosymbols.Forexample:
1./*Itisanexampleof
2.multilinecomment*/
•DocumentationComment:Itstartswiththedelimiter(/**)andendswith*/.

Package
Declaration
•Thepackagedeclarationisoptional.Itisplacedjustafterthe
documentationsection.Inthissection,wedeclarethepackage
nameinwhichtheclassisplaced.Notethattherecanbeonlyone
packagestatementinaJavaprogram.Itmustbedefinedbeforeany
classandinterfacedeclaration.ItisnecessarybecauseaJavaclasscan
beplacedindifferentpackagesanddirectoriesbasedonthemodule
theyareused.Foralltheseclassespackagebelongstoasingleparent
directory.Weusethekeywordpackagetodeclarethepackagename.
Forexample:
1.packagejavatpoint;//wherejavatpointisthepackagename
2.packagecom.javatpoint;//wherecomistherootdirectoryandjavatpoi
ntisthesubdirectory

Import
Statements
•Thepackagecontainsthemanypredefinedclassesandinterfaces.If
wewanttouseanyclassofaparticularpackage,weneedtoimport
thatclass.Theimportstatementrepresentstheclassstoredintheother
package.Weusetheimportkeywordtoimporttheclass.Itiswritten
beforetheclassdeclarationandafterthepackagestatement.Weuse
theimportstatementintwoways,eitherimportaspecificclassor
importallclassesofaparticularpackage.InaJavaprogram,wecan
usemultipleimportstatements.Forexample:
1.importjava.util.Scanner;//itimportstheScannerclassonly
2.importjava.util.*;//itimportsalltheclassofthejava.utilpackage

Interface Section
•Itisanoptionalsection.Wecancreateaninterfaceinthissectionif
required.Weusetheinterfacekeywordtocreateaninterface.
Aninterfaceisaslightlydifferentfromtheclass.Itcontains
onlyconstantsandmethoddeclarations.Anotherdifferenceisthatit
cannotbeinstantiated.Wecanuseinterfaceinclassesbyusing
theimplementskeyword.Aninterfacecanalsobeusedwithother
interfacesbyusingtheextendskeyword.Forexample:
1.interfacecar
2.{
3.voidstart();
4.voidstop();
5.}

Class Definition
•Inthissection,wedefinetheclass.ItisvitalpartofaJava
program.Withouttheclass,wecannotcreateanyJavaprogram.A
Javaprogrammayconationmorethanoneclassdefinition.Weuse
theclasskeywordtodefinetheclass.Theclassisablueprintofa
Javaprogram.Itcontainsinformationaboutuser-definedmethods,
variables,andconstants.EveryJavaprogramhasatleastoneclass
thatcontainsthemain()method.Forexample:
1.classStudent//classdefinition
2.{
3.}

Main Method Class
•Inthissection,wedefinethemain()method.Itisessentialforall
Javaprograms.BecausetheexecutionofallJavaprogramsstarts
fromthemain()method.Inotherwords,itisanentrypointofthe
class.Itmustbeinsidetheclass.Insidethemainmethod,wecreate
objectsandcallthemethods.Weusethefollowingstatementto
definethemain()method:
1.publicstaticvoidmain(Stringargs[])
2.{
3.}

JavaTokens:
•InJava,theprogramcontainsclassesandmethods.Further,the
methodscontaintheexpressionsandstatementsrequiredtoperforma
specificoperation.Thesestatementsandexpressionsaremadeup
oftokens.Inotherwords,wecansaythattheexpressionand
statementisasetoftokens.Thetokensarethesmallbuilding
blocksofaJavaprogramthataremeaningfulto
theJavacompiler.Further,thesetwocomponentscontainvariables,
constants,andoperators.Inthissection,wewilldiscusswhatis
tokensinJava.
WhatistokeninJava?
•TheJavacompilerbreaksthelineofcodeintotext(words)is
calledJavatokens.ThesearethesmallestelementoftheJava
program.TheJavacompileridentifiedthesewordsastokens.These
tokensareseparatedbythedelimiters.Itisusefulforcompilersto
detecterrors.RememberthatthedelimitersarenotpartoftheJava
tokens.

Types of Tokens
•Keywords
•Identifiers
•Literals
•Operators
•Separators
•Comments

Keywords:Thesearethepre-definedreservedwordsofany
programminglanguage.Eachkeywordhasaspecial
meaning.Itisalwayswritteninlowercase,becausejavais
case-sensitive.Javaprovidesthefollowingkeywords:
01. Abstract 02. Boolean 03. Byte 04. Break 05. Class
06. Case 07. Catch 08. Char 09. Continue 10. Default
11. Do 12. Double 13. Else 14. Extends 15. Final
16. Finally 17. Float 18. For 19. If 20. Implements
21. Import 22. Instanceof 23. Int 24. Interface 25. Long
26. Native 27. New 28. Package 29. Private 30. Protected
31. Public 32. Return 33. Short 34. Static 35. Super
36. Switch 37. Synchronized 38. This 39. Thro 40. Throws
41. Transient 42. Try 43. Void 44. Volatile 45. While
46. Assert 47. Const 48. Enum 49. Goto 50. Strictfp

Identifier:
•Identifiersareusedtonameavariable,constant,function,class,andarray.
Itusuallydefinedbytheuser.Itusesletters,underscores,oradollarsignasthe
firstcharacter.Thelabelisalsoknownasaspecialkindofidentifierthatisused
inthegotostatement.Rememberthattheidentifiernamemustbedifferentfrom
thereservedkeywords.Therearesomerulestodeclareidentifiersare:
•Thefirstletterofanidentifiermustbealetter,underscoreoradollarsign.It
cannotstartwithdigitsbutmaycontaindigits.
•Thewhitespacecannotbeincludedintheidentifier.
•Identifiersarecasesensitive.
•Somevalididentifiersare:
1.PhoneNumber
2.PRICE
3.radius
4.a
5.a1
6._phonenumber
7.$circumference
8.jagged_array

Literals:
•Inprogrammingliteralisanotationthatrepresentsafixedvalue(constant)inthe
sourcecode.Itcanbecategorizedasanintegerliteral,stringliteral,Booleanliteral,etc.
Itisdefinedbytheprogrammer.Onceithasbeendefinedcannotbechanged.Java
providesfivetypesofliteralsareasfollows:
•Integer
•FloatingPoint
•Character
•String
•Boolean
Literal Type
23 int
9.86 double
false, true boolean
'K', '7', '-' char
"javatpoint" String
null any reference type

Operators:
•Inprogramming,operatorsarethespecialsymbolthattellsthe
compilertoperformaspecialoperation.Javaprovidesdifferenttypesof
operatorsthatcanbeclassifiedaccordingtothefunctionalitytheyprovide.
ThereareeighttypesofoperatorsinJava,areasfollows:
•ArithmeticOperators
•AssignmentOperators
•RelationalOperators
•UnaryOperators
•LogicalOperators
•TernaryOperators
•BitwiseOperators
•ShiftOperators

Operator Symbols
Arithmetic + , -, / , * , %
Unary ++ , --, !
Assignment = , += , -= , *= , /= , %= , ^=
Relational ==, != , < , >, <= , >=
Logical && , ||
Ternary (Condition) ? (Statement1) : (Statement2);
Bitwise & , | , ^ , ~
Shift << , >> , >>>

Separators
•TheseparatorsinJavaisalsoknownaspunctuators.Therearenineseparators
inJava,areasfollows:
1.separator<=;|,|.|(|)|{|}|[|]
•SquareBrackets[]:Itisusedtodefinearrayelements.Apairofsquarebrackets
representsthesingle-dimensionalarray,twopairsofsquarebracketsrepresentthe
two-dimensionalarray.
•Parentheses():Itisusedtocallthefunctionsandparsingtheparameters.
•CurlyBraces{}:Thecurlybracesdenotethestartingandendingofacodeblock.
•Comma(,):Itisusedtoseparatetwovalues,statements,andparameters.
•AssignmentOperator(=):Itisusedtoassignavariableandconstant.
•Semicolon(;):Itisthesymbolthatcanbefoundatendofthestatements.It
separatesthetwostatements.
•Period(.):Itseparatesthepackagenameformthesub-packagesandclass.Italso
separatesavariableormethodfromareferencevariable.
separator<=;|,|.|(|)|{|}|[|]

Java statement:

Implementing a java program:
•Create the program by typing it into a text editor and
saving it to a file –HelloWorld.java.
•Compile it by typing “javac HelloWorld.java” in the
terminal window.
•Execute (or run) it by typing “java HelloWorld” in the
terminal window.

JVM (Java Virtual Machine)
Architecture
1.JavaVirtualMachine
2.InternalArchitectureofJVM
•JVM(JavaVirtualMachine)isanabstractmachine.It
isaspecificationthatprovidesruntimeenvironment
(JRE)inwhichjavabytecodecanbeexecuted.
•JVMsareavailableformanyhardwareandsoftware
platforms(i.e.JVMisplatformdependent).
Tags