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
,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
,c)vifvthevinstancevdatavarevaccessiblevoutsidevofvthevobjectvdirectly
d)vthevnumbervofvmethodsvinvthevclass
e)vthevnumbervofvinstancevdatavinvthevclassv-vcorrect-answersv-a)vhowvanvobjectvisvinitialized
Javavmethodsvcanvreturnvonlyvprimitivevtypesv(int,vdouble,vfloat,vchar,vboolean,vetc).
True
Falsev-vcorrect-answersv-False
AllvJavavclassesvmustvcontainvavmainvmethodvwhichvisvthevfirstvmethodvexecutedvwhenvthevJavavcla
ssvisvcalledvupon.
True
Falsev-vcorrect-answersv-False
usevthevfollowingvclassvdefinition
importvjava.text.DecimalFormat;
publicvclassvStudent
{vprivatevStringvname;
v privatevStringvmajor;
v privatevdoublevgpa;
v privatevintvhours;
v publicvStudent(StringvnewName,vStringvnewMajor,vdoublevnewGPA,vintvnewHours)
v v { namev=vnewName;
v majorv=vnewMajor;
v gpav=vnewGPA;
, v hoursv=vnewHours;
v }
v publicvStringvtoString(v)
v v { DecimalFormatvdfv=vnewvDecimalFormat("0.000");
v returnvnamev+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,v2v*v3);
b)vfoo(0,v0.1);
c)vfoo(0);
d)vfoo(1v+v2,v3v*v0.1);
e)vfoo(v);v-vcorrect-answersv-a)vfoo(0v/v1,v2v*v3);
Usevthevfollowingvpartialvclassvdefinitions:v
publicvclassvA1v
{v