DescribewhathappenswhenanobjectiscreatedinJava?Severalthingshappeninaparticularordertoensuretheobjectisconstructedproperly:1.Memoryisallocatedfromheaptoholdallinstancevariablesandimplementation-specificdataoftheobjectanditssuperclasses.Implementation-specificdataincludespointerstoclassandmethoddata.2.Theinstancevariablesoftheobjectsareinitializedtotheirdefaultvalues.3.Theconstructorforthemostderivedclassisinvoked.Thefirstthingaconstructordoesiscalltheconstructorforitsuppercase.Thisprocesscontinuesuntiltheconstructorforjava.lang.Objectiscalled,asjava.lang.Objectisthebaseclassforallobjectsinjava.4.Beforethebodyoftheconstructorisexecuted,allinstancevariableinitializersandinitializationblocksareexecuted.Thenthebodyoftheconstructorisexecuted.Thus,theconstructorforthebaseclasscompletesfirstandconstructorforthemostderivedclasscompleteslast.InJava,youcancreateaStringobjectasbelow:Stringstr="abc";&Stringstr=newString("abc");Whycantabuttonobjectbecreatedas:Buttonbt="abc"?Whyisitcompulsorytocreateabuttonobjectas:Buttonbt=newButton("abc");WhythisisnotcompulsoryinString’scase?Buttonbt1="abc";Itisbecause"abc"isaliteralstring(somethingslightlydifferentthanaStringobject,by-the-way)andbt1isaButtonobject.Thatsimple.TheonlyobjectinJavathatcanbeassignedaliteralStringisjava.lang.String.ImportanttonotthatyouareNOTcallingajava.lang.StringconstuctorwhenyoutypeStrings="abc";ForexampleStringx="abc";Stringy="abc";refertothesameobject.WhileStringx1=newString("abc");Stringx2=newString("abc");refertotwodifferentobjects.WhatistheadvantageofOOP?Youwillgetvaryinganswerstothisquestiondependingonwhomyouask.MajoradvantagesofOOPare:1.Simplicity:softwareobjectsmodelrealworldobjects,sothecomplexityisreducedandtheprogramstructureisveryclear;2.Modularity:eachobjectformsaseparateentitywhoseinternalworkingsaredecoupledfromotherpartsofthesystem;3.Modifiability:itiseasytomakeminorchangesinthedatarepresentationortheproceduresinanOOprogram.Changesinsideaclassdonotaffectanyotherpartofaprogram,sincetheonlypubl...