Docsity

CSE 205 Final Exam Key 2025 | Java OOP & Data Structures, Exams of Object Oriented Programming

Toggle sidebar
bg1
CSE 205 Final with correct answers
2025
Havingvmultiplevclassvmethodsvofvthevsamevnamevwhereveachvmethodvhasvavdifferentvnumbervofvo
rvtypevofvparametersvisvknownvas
a)vmethodvoverloading
b)vEncapsulation
c)vimporting
d)vinformationvhiding
e)vencapsulationv-vcorrect-answersv-a)vmethodvoverloading
Thevrelationshipvbetweenvavclassvandvanvobjectvisvbestvdescribedvas
a)vobjectsvarevinstancesvofvclasses
b)vclassesvarevinstancesvofvobjects
c)vclassesvarevprogramsvwhilevobjectsvarevvariables
d)vobjectsvandvclassesvarevthevsamevthing
e)vobjectsvarevthevinstancevdatavofvclassesv-vcorrect-answersv-a)vobjectsvarevinstancesvofvclasses
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37

Partial preview of the text

Download CSE 205 Final Exam Key 2025 | Java OOP & Data Structures and more Exams Object Oriented Programming in PDF only on Docsity!

CSE 205 Final with correct answers

Havingvmultiplevclassvmethodsvofvthevsamevnamevwhereveachvmethodvhasvavdifferentvnumbervofvo rvtypevofvparametersvisvknownvas

a)vmethodvoverloading

b)vEncapsulation

c)vimporting

d)vinformationvhiding

e)vencapsulationv-vcorrect-answersv-a)vmethodvoverloading

Thevrelationshipvbetweenvavclassvandvanvobjectvisvbestvdescribedvas

a)vobjectsvarevinstancesvofvclasses

b)vclassesvarevinstancesvofvobjects

c)vclassesvarevprogramsvwhilevobjectsvarevvariables

d)vobjectsvandvclassesvarevthevsamevthing

e)vobjectsvarevthevinstancevdatavofvclassesv-vcorrect-answersv-a)vobjectsvarevinstancesvofvclasses

Tovdefinevavclassvthatvwillvrepresentvavcar,vwhichvofvthevfollowingvdefinitionsvisvmostvappropriate?

a)vpublicvclassvCAR

b)vpublicvclassvcar

c)vprivatevclassvcar

d)vprivatevclassvCar

e)vpublicvclassvCarv-vcorrect-answersv-e)vpublicvclassvCar

WhichvofvthevfollowingvreservedvwordsvinvJavavisvusedvtovcreatevanvinstancevofvavclass?

a)vnew

b)vpublic

c)vpublicvorvprivate,veithervcouldvbevused

d)vclass

e)vimportv-vcorrect-answersv-a)vnew

WhatvdoesvacronymvAPIvstandsvfor?

a)vApplicationvParametervInternet

b)vApplicationvProgrammingvInterface

c)vApplyvProgrammingvInteractive

d)vAbstractionvProgrammingvInterfacev-vcorrect-answersv-b)vApplicationvProgrammingvInterface

Avclass'vconstructorvusuallyvdefines

a)vhowvanvobjectvisvinitialized

b)vhowvanvobjectvisvinterfaced

vhoursv=vnewHours;

v}

vpublicvStringvtoString(v)

v{vDecimalFormatvdfv=vnewvDecimalFormat("0.000");

vreturnvnamev+v"\n"v+vmajorv+v"\n"v+vdf.format(gpa)v+v"\n"v+vhours

v}

}

WhichvofvthevfollowingvcouldvbevusedvtovinstantiatevavnewvStudentvs1?

a)vnewvStudent(s1);

b)vnewvStudentvs1v=v("JanevDoe",v"ComputervScience",v3.333,v33);

c)vStudentvs1v=vnewvStudent("JanevDoe",v"ComputervScience",v3.333,v33);

d)vStudentvs1v=vnewvStudent(v);

e)vs1v=vnewvStudent(v);v-vcorrect-answersv- c)vStudentvs1v=vnewvStudent("JanevDoe",v"ComputervScience",v3.333,v33);

Considervavmethodvdefinedvwithvthevheader:vpublicvvoidvfoo(intva,vintvb).vWhichvofvthevfollowingvm ethodvcallsvisvlegal?

a)vfoo(0v/v1,v 2 v*v3);

b)vfoo(0,v0.1);

c)vfoo(0);

d)vfoo(1v+v2,v 3 v*v0.1);

e)vfoo(v);v-vcorrect-answersv-a)vfoo(0v/v1,v 2 v*v3);

Usevthevfollowingvpartialvclassvdefinitions:v

publicvclassvA1v

{v

vpublicvintvx;v

vprivatevintvy;v

vprotectedvintvz;

v...v

}v

publicvclassvA2vextendsvA1v

{

vprotectedvintva;v

vprivatevintvb;

v...v

}

publicvclassvA3vextendsvA2v

{

vprivatevintvq;v

v...

}

WhichvofvthevfollowingvisvtruevwithvrespectvtovA1,vA2vandvA3?

a)vA2vandvA3varevbothvsubclassesvofvA

b)vA1vandvA2varevbothvsubclassesvofvA

c)vA1visvavsubclassvofvA2vandvA2visvavsubclassvofvA

d)vA3visvavsubclassvofvA2vandvA2visvavsubclassvofvA1v-vcorrect-answersv- d)vA3visvavsubclassvofvA2vandvA2visvavsubclassvofvA

Usevthevfollowingvpartialvclassvdefinitions:v

publicvclassvA1v

publicvclassvA1v

{v

vpublicvintvx;v

vprivatevintvy;v

vprotectedvintvz;

v...v

}v

publicvclassvA2vextendsvA1v

{v

vprotectedvintva;v

vprivatevintvb;v

...v

}v

publicvclassvA3vextendsvA2v

{v

vprivatevintvq;

v...v

}

WhichvofvthevfollowingvlistsvofvinstancevdatavarevaccessiblevinvA3?

a)vx,vz,va,vq

b)vx,vy,vz,va,vb,vq

c)va,vq

d)vx,va,vq

e)va,vb,vqv-vcorrect-answersv-a)vx,vz,va,vq

Usevthevfollowingvpartialvclassvdefinitions:v

publicvclassvA1v

{v

vpublicvintvx;v

vprivatevintvy;v

vprotectedvintvz;

v...v

}v

publicvclassvA2vextendsvA1v

{v

vprotectedvintva;v

vprivatevintvb;v

...v

}v

publicvclassvA3vextendsvA2v

{v

vprivatevintvq;v

...v

}

WhichvofvthevfollowingvisvtruevregardingvthevusevofvinstancevdatavyvofvclassvA1?

a)vitvisvaccessiblevinvA1vandvA

b)vitvisvaccessiblevinvA1,vA2vandvA

c)vitvisvaccessiblevonlyvinvA

d)vitvisvaccessiblevonlyvinvA

e)vitvisvnotvaccessiblevtovanyvofvthevthreevclassesv-vcorrect-answersv-d)vitvisvaccessiblevonlyvinvA

Anvarray,vwhenvinstantiated,visvfixedvinvsize,vbutvanvArrayListvcanvdynamicallyvchangevinvsizevwhenv newvelementsvarevaddedvtovit.

True

Falsev-vcorrect-answersv-True

Avvariablevdeclaredvtovbevofvonevclassvcanvlatervreferencevanvextendedvclassvofvthatvclass.vThisvvari ablevisvknownvas

a)vprotected

b)vcloneable

c)vAvvariablevdeclaredvtovbevofvonevclassvcanvnevervreferencevanyvothervtypevofvclass,vevenvanvexte ndedvclass

d)vpolymorphic

e)vderivablev-vcorrect-answersv-d)vpolymorphic

IfvyouvinstantiatevanvobjectvfromvanvAbstractvclass,vthevobjectvyouvwindvupvwith

a)visvalsovanvAbstractvclass

b)visvavnormalvobject

c)vcan'tvexistv-vyouvcannotvinstantiatevanvAbstractvclass

d)visvavreferencevtovanvObject

e)visvanvInterfacev-vcorrect-answersv-c)vcan'tvexistv-vyouvcannotvinstantiatevanvAbstractvclass

Thevinstructionvsuper(v);vdoesvwhichvofvthevfollowing?

a)vcallsvthevconstructorvasvdefinedvinvthevcurrentvclass

b)vcallsvthevmethodvsupervasvdefinedvinvthevcurrentvclass'vparentvclass

c)vcallsvthevconstructorvasvdefinedvinvthevcurrentvclass'vparentvclass

d)vcallsvthevmethodvsupervasvdefinedvinvthevcurrentvclass

e)vcallsvthevmethodvsupervasvdefinedvinvjava.langv-vcorrect-answersv- c)vcallsvthevconstructorvasvdefinedvinvthevcurrentvclass'vparentvclass

Inheritancevthroughvanvextendedv(derived)vclassvsupportsvwhichvofvthevfollowingvconcepts?

a)vinformationvhiding

b)vmodulary

c)vcodevreuse

d)vinterfaces

e)vcorrectnessv-vcorrect-answersv-c)vcodevreuse

Duringvprogramvdevelopment,vsoftwarevrequirementsvspecify

a)vhowvtovmaintainvthevsoftware

b)vhowvtovtestvthevprogramvwhenvitvisvdone

c)vwhatvthevtaskvisvthatvthevprogramvmustvperform

d)vhowvthevprogramvwillvaccomplishvthevtask

e)vhowvtovdividevthevtaskvintovsubtasksv-vcorrect-answersv- c)vwhatvthevtaskvisvthatvthevprogramvmustvperform

Ofvthevvariousvphasesvinvsoftwarevdevelopment,vwhichvofvthevfollowingvisvusuallyvthevlengthiest?

a)vtesting

b)vmaintenance

d)vIfvavclassvisvdeclaredvtovbevabstractvthenveveryvmethodvinvthevclassvisvabstractvandvmustvbevoverr iddenv-vcorrect-answersv- c)vIfvavclassvisvdeclaredvtovbevabstractvthenvsomevmethodsvinvthevclassvmayvhavevtheirvbodiesvomitt ed

Ifvanvintvarrayvisvpassedvasvavparametervtovavmethod,vwhichvofvthevfollowingvwouldvadequatelyvdefi nevthevparametervlistvforvthevmethodvheader?

a)v(intva)

b)v(int[v])

c)v(intv[v]va)

d)v(a[v])v-vcorrect-answersv-c)v(intv[v]va)

Considervthevfollowingvclassvdefinition:

publicvclassvQuiz

{v

vprivatevintvx;

vpublicvQuiz(intvnewValue)

v{vxv=vnewValue;v

v}

}

WhichvofvthevfollowingvisvtruevaboutvthevclassvQuiz?

a)vItvhasvnovparentvclass

b)vit'svparentvclassvisvJava

c)vit'svparentvclassvisvObject

d)vitvhasvavdefaultvchildvcalledvObjectv-vcorrect-answersv-c)vit'svparentvclassvisvObject

Invordervtovdeterminevthevtypevthatvavpolymorphicvvariablevrefersvto,vthevdecisionvisvmade

a)vbyvthevprogrammervatvthevtimevthevprogramvisvwritten

b)vbyvthevJavavrun-timevenvironmentvatvrunvtime

c)vbyvthevcompilervatvcompilevtime

d)vbyvthevoperatingvsystemvwhenvthevprogramvisvloadedvintovmemoryv-vcorrect-answersv- b)vbyvthevJavavrun-timevenvironmentvatvrunvtime

InvJava,vpolymorphicvmethodvbindingvoccurs:

a)vatvrunvtime

b)vatvcompilevtime

c)vnever

d)vwhenvavprogrammervwritesvthevcode

e)vduringvthevtestingvphasevofvsoftwarevdevelopmentv-vcorrect-answersv-a)vatvrunvtime

InvJava,va(n)v___________________visvavcollectionvofvconstantsvandvabstractvmethods

a)vpolymorphicvreference

b)vabstractvclass

c)vimplementation

d)vinterface

e)viteratorv-vcorrect-answersv-d)vinterface

b)vintvgradesv[]v=vnewvint[5];

c)vintv[]vgradesv=v{91,83,42,100,77};

d)vallvofvthevabovevarevvalid

e)vnonevofvthevabovevarevvalidv-vcorrect-answersv-d)vallvofvthevabovevarevvalid

EveryvJavavarrayvisva(n)v_________________,vsovitvisvpossiblevtovusevavforeachvloopvtovprocessveac hvelementvinvthevarray.

a)vobject

b)viterator

c)vclass

d)voperator

e)vnonevofvthevabovev-vcorrect-answersv-b)viterator

Whatvwillvbevthevoutputvofvthevfollowingvcodevsnippet?

intv[]varrayv=vnewvint[25];System.out.println(array.length);

a)v 26

b)v 24

c)v 25

d)vThisvcodevwillvresultvinvavcompilevtimeverror.

e)vThisvcodevwillvresultvinvavrunvtimeverror.v-vcorrect-answersv-c)v 25

Whichvofvthevfollowingvisvavtruevstatement?

a)vArraysvarevpassedvasvparametersvtovmethodsvlikevprimitivevtypes.

b)vArraysvarevpassedvasvparametersvtovmethodsvlikevobjectvtypes.

c)vArraysvcannotvbevpassedvasvparametersvtovmethods.

d)vAllvofvthevabovevarevtrue.

e)vNonevofvthevabovevarevtrue.v-vcorrect-answersv- b)vArraysvarevpassedvasvparametersvtovmethodsvlikevobjectvtypes.

Writevthevoutputvgeneratedvbyvthevfollowingvprogram

importvjava.util.*;

publicvclassvSomeObjects

{

vpublicvstaticvvoidvmain(String[]vargs)

v{

vArrayListvlistv=vnewvArrayList();

vlist.add("ab");

vlist.add("cd");

vlist.edd("ef");

vSystem.out.println(list.size());

vSystem.out.println(list.get(1));

v}

}

a)v 2

vab

b)v 3

vab

c)v 3

e)vpush.getChildren().add(newvButtonHandler());v-vcorrect-answersv- b)vpush.setOnAction(newvButtonHandler());

Whichvofvthevfollowingvnodesv(control)vallowsvthevuservtoventervtypedvinputvfromvthevkeyboard.

a)vsliders

b)vnonevofvthevchoices

c)vcheckvboxes

d)vradiovbuttons

e)vcombovboxesv-vcorrect-answersv-b)vnonevofvthevchoices

Whichvofvthevfollowingvlayoutvmanagmentvorganizesvthevnodesvfromvleftvtovright,vstartingvnewvro wsvasvnecessary?

a)vBorderPane

b)vVBox

c)vHBox

d)vFlowPane

e)vGridPanev-vcorrect-answersv-d)vFlowPane

WhatvarevthevobjectsvneededvinvordervtovcreatevavJavavFXvGUIv(graphicalvuservinterface)vthatvrespo ndsvtovuservaction(s)?

a)vControl

b)vListener

c)vControl,veventvandvlistenervobjects

e)vEventv-vcorrect-answersv-c)vControl,veventvandvlistenervobjects

WhichvLayoutvpanevwouldvyouvusevifvyouvwantvtovaddvcontrolsvtovbevplacedvinv 2 vcolumnsvoverv 5 vro ws?

a)vHBoxvpane

b)vVBoxvpane

c)vBordervpane

d)vGridvpane

e)vTabbedPanev-vcorrect-answersv-d)vGridvpane

Invthevfollowingvcodevobject1visvtheveventvhandlervobject?

Buttonvobject1v=vnewvButton("PushvMe!");

ButtonHandlervobject2v=vnewvButtonHandler();

privatevclassvButtonHandlervimplementsvEventHandler

{v//Overridevthevabstractvmethodvhandle()

vpublicvvoidvhandle(ActionEventve)v{

v//codevtovbevcompletedv}

}

True

Falsev-vcorrect-answersv-False

AvsimplevJavaFXvprogramvexecutesvonvavstage,vwhichvrepresentsvthevwindowvinvwhichvthevapplicati onvruns.

True

Falsev-vcorrect-answersv-True