• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 3 fuera de 18 páginas
Examen

Ap Computer Science Unit 9 Questions And Complete Solutions

Document preview thumbnail
Vista previa 3 fuera de 18 páginas

AP COMPUTER SCIENCE UNIT 9 QUESTIONS AND COMPLETE SOLUTIONS

Vista previa del contenido

AP COMPUTER SCIENCE UNIT 9
QUESTIONS AND COMPLETE
SOLUTIONS


Consider athe afollowing aclass adefinitions.
public aclass aBike
{
private aint anumWheels a= a2;

// aNo aconstructor adefined
}

public aclass aEBike aextends aBike
{
private aint anumBatteries;

public aEBike(int abatteries)
{
numBatteries a= abatteries;
}
}
The afollowing acode asegment aappears ain aa amethod ain aa aclass aother athan aBike aor
aEBike.
EBike aeB a= anew aEBike(4);
Which aof athe afollowing abest adescribes athe aeffect aof aexecuting athe acode asegment?
A
An aimplicit acall ato athe azero-parameter aBike aconstructor ainitializes athe ainstance
avariable anumWheels. aThe ainstance avariable anumBatteries ais ainitialized ausing athe
avalue aof athe aparameter abatteries.
B
An aimplicit acall ato athe aone-parameter aBike aconstructor awith athe aparameter apassed
ato athe aEBike aconstructor ainitializes athe ainstance avariable anumWheels. aThe
ainstance avariable anumBatteries ais ainitialized ausing athe avalue aof athe aparameter
abatteries.
C
Because asuper ais anot aexplicitly acalled afrom athe aEBike ac a- a(correct aanswer) a-A

,An aimplicit acall ato athe azero-parameter aBike aconstructor ainitializes athe ainstance
avariable anumWheels. aThe ainstance avariable anumBatteries ais ainitialized ausing athe
avalue aof athe aparameter abatteries.


Consider athe afollowing aclass adefinitions.
public aclass aBird
{
private aint abeakStrength;

public aBird(int ainput)
{
beakStrength a= ainput;
}

public avoid asetBeakStrength(int astrength)
{
beakStrength a= astrength;
}
}

public aclass aHawk aextends aBird
{
private aint atalonStrength;

public aHawk(int atalon, aint abeak)
{
super(beak);
talonStrength a= atalon;
}
}
The afollowing astatement aappears ain aa amethod ain aanother aclass.
Bird ab a= anew aHawk(5, a8);
Which aof athe afollowing abest adescribes athe aeffect aof aexecuting athe astatement?
A
The aBird avariable ab ais ainstantiated aas aa aHawk. aThe ainstance avariable
atalonStrength ais ainitialized awith athe avalue afrom athe aparameter atalon. aThe aHawk
aconstructor acannot aset athe ainstance avariable abeakStrength abecause aa asubclass
adoes anot ahave aaccess ato aa aprivate avariable ain aits asuperclass.
B
The aBird avariable ab ais ainstantiated aas aa aHawk. aThe acall asuper(beak) areturns aa
avalue afrom athe ainstance avariable abeakStrength ain a- a(correct aanswer) a-D
The aBird avariable ab ais ainstantiated aas aa aHawk. aThe acall asuper(beak) ainvokes athe
aBird aconstructor aand ainitializes athe ainstance avariable abeakStrength awith athe avalue
afrom athe aparameter abeak. aThe ainstance avariable atalonStrength ais athen ainitialized
awith athe avalue afrom athe aparameter atalon.

, Consider athe afollowing aclass adefinitions.
public aclass aBook
{
private aString abookTitle;

public aBook()
{
bookTitle a= a"";
}

public aBook(String atitle)
{
bookTitle a= atitle;
}
}
public aclass aTextBook aextends aBook
{
private aString asubject;

public aTextBook(String atheSubject)
{
subject a= atheSubject;
}
}
The afollowing acode asegment aappears ain aa amethod ain aa aclass aother athan aBook aor
aTextBook.
Book ab a= anew aTextBook("Psychology");
Which aof athe afollowing abest adescribes athe aeffect aof aexecuting athe acode asegment?
A
The aTextBook aconstructor ainitializes athe ainstance avariable asubject awith athe avalue
aof athe aparameter atheSubject, aand athen ainvokes athe azero-parameter aBook
aconstructor, awhich ainitializes athe ainstance avariable abookTitle ato a"".
B
The aTextBook aconstructor ainitializes athe ainstance avariable asubject awith athe avalue
aof athe aparameter atheSubject, aand athen ainvokes athe aone-parameter aBook
aconstructor awith atheSubject aas athe aparameter, awhi a- a(correct aanswer) a-C
There ais aan aimplicit acall ato athe azero-parameter aBook aconstructor. aThe ainstance
avariable abookTitle ais athen ainitialized ato a"". aThen, athe ainstance avariable asubject ais
ainitialized awith athe avalue aof athe aparameter atheSubject.


Consider athe afollowing aclass adefinitions.
public aclass aDrink
{
// aimplementation anot ashown
}
public aclass aCoffee aextends aDrink

Información del documento

Subido en
28 de agosto de 2024
Número de páginas
18
Escrito en
2024/2025
Tipo
Examen
Contiene
Preguntas y respuestas
$17.49

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
Lectpotter
4.8
(186)
Vendido
143
Seguidores
9
Artículos
2647
Última venta
6 días hace


Reseñas de compradores verificados




Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes