Sei sulla pagina 1di 4

FAZWAATIQABTMOHDJUHARI(0317757)

th

QUIZ#4(26

April2015)

Q1: Every class in Java, except ________, extends an existing


class.
a.Integer.
b.Object.
c.String.
d.Class.
Q2: Overriding a method differs from overloading a method
because:
a.Overloadedmethodshavethesamesignature.
b.Overriddenmethodshavethesamesignature.
c.Bothoftheabove.
d.Neitheroftheabove.
Q3:Superclassmethodswiththislevelofaccesscannotbecalled
fromsubclasses.
a.private.
b.public.
c.protected.
d.package.
Q4:Superclassmethodswiththislevelofaccesscannotbecalled
fromsubclasses.
a.private.
b.public.
c.protected.
d.package.
Q5:Whichofthefollowingkeywordsallowsasubclasstoaccessa
superclass method even when the subclass has overridden the
superclassmethod?
a.base.
b.this.
c.public.

d.super.

Q6:Considertheclassesbelow,declaredinthesamefile:
classA
{
inta;
publicA()
{
a=7;
}
}
classBextendsA
{
intb;
publicB()
{
b=8;
}
}
Whichofthestatementsbelowisfalse?
a.Bothvariablesaandbareinstancevariables.
b.AftertheconstructorforclassBexecutes,thevariableawill
havethevalue7.
c.AftertheconstructorforclassBexecutes,thevariablebwill
havethevalue8.
d.AreferenceoftypeAcanbetreatedasareferenceoftypeB.
Q7: Which of the following is the superclass constructor call
syntax?
a.keywordsuper,followedbyadot(.).
b.keywordsuper,followedbyasetofparenthesescontainingthe
superclassconstructorarguments.
c.keywordsuper,followedbyadotandthesuperclassconstructor
name.
d.Noneoftheabove.
Q8:Whenasubclassconstructorcallsitssuperclassconstructor,

what happens if the superclass constructor does not assign a


valuetoaninstancevariable?
a.Asyntaxerroroccurs.
b.Acompiletimeerroroccurs.
c.Aruntimeerroroccurs.
d.The program compiles and runs because the instance variables
areinitialisedtotheirdefaultvalues.
Q9:ThedefaultequalsimplementationofclassObjectdetermines:
a.whethertworeferencesrefertothesameobjectinmemory.
b.whethertworeferenceshavethesametype.
c.whethertwoobjectshavethesameinstancevariables.
d.whethertwoobjectshavethesameinstancevariablevalues.

Q10:Whichofthefollowingstatementsaboutinterfacesisfalse?
a.Aninterfacedescribesasetofmethodsthatcanbecalledon
anobject,providingadefaultimplementationforthemethods.
b.Aninterfacedescribesasetofmethodsthatcanbecalledon
anobject,notprovidingconcreteimplementationforthemethods.
c. Interfaces are useful when attempting to assign common
functionalitytopossiblyunrelatedclasses.
d. Once a class implements an interface, all objects of that
classhaveanisarelationshipwiththeinterfacetype.
Q11:Polymorphismallowsforspecificstobedealtwithduring:
a.execution.
b.compilation.
c.programming.
d.debugging.
Q12:A(n)_________classcannotbeinstantiated.
a.final.
b.concrete.
c.abstract.
d.polymorphic.
Q13: If the superclass contains only abstract method
declarations,thesuperclassisusedfor:

a.implementationinheritance.
b.interfaceinheritance.
c.Both.
d.Neither.

Q14: Which of the following could be used to declare abstract


methodmethod1inabstractclassClass1(method1returnsanint
andtakesnoarguments)?
a.publicintmethod1();
b.publicintabstractmethod1();
c.publicabstractintmethod1();
d.publicintnonfinalmethod1();
Q15:Considertheabstractsuperclassbelow:
publicabstractclassFoo
{
privateinta;
publicintb;
publicFoo(intaVal,intbVal)
{
a=aVal;
b=bVal;
}//endFooconstructor
publicabstractintcalculate();
}//endclassFoo
AnyconcretesubclassthatextendsclassFoo:
a.Mustimplementamethodcalledcalculate.
b.Willnotbeabletoaccesstheinstancevariablea.
c.Neither(a)nor(b).
d.Both(a)and(b).

Potrebbero piacerti anche