Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

AP COMPUTER SCIENCE UNIT 9 QUESTIONS AND COMPLETE SOLUTIONS

Rating
5.0
(1)
Sold
-
Pages
18
Grade
A+
Uploaded on
28-08-2024
Written in
2024/2025

AP COMPUTER SCIENCE UNIT 9 QUESTIONS AND COMPLETE SOLUTIONS

Institution
AP COMPUTER SCIENCE UNIT 9
Course
AP COMPUTER SCIENCE UNIT 9

Content preview

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

Written for

Institution
AP COMPUTER SCIENCE UNIT 9
Course
AP COMPUTER SCIENCE UNIT 9

Document information

Uploaded on
August 28, 2024
Number of pages
18
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$17.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF


Also available in package deal

Thumbnail
Package deal
OFFER!!!OFFER!! package deal for AP Chemistry Unit 9 exams with complete rationales 100% pass
-
5 2025
$ 23.57 More info

Reviews from verified buyers

Showing all reviews
1 year ago

5.0

1 reviews

5
1
4
0
3
0
2
0
1
0
Trustworthy reviews on Stuvia

All reviews are made by real Stuvia users after verified purchases.

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Lectpotter Strayer University
View profile
Follow You need to be logged in order to follow users or courses
Sold
128
Member since
1 year
Number of followers
9
Documents
2586
Last sold
6 days ago
REALITIEXAMS

Nursing Being my main profession line, My mission is to be your LIGHT in the dark. If you're worried or having trouble in nursing school, I really want my notes to be your guide! I know they have helped countless others get through and that's all I want for YOU! On this page, you find all documents, package deals, and flashcards offered by seller Lectpotter I have essential guides that are Almost A+ graded, I am a very friendly person:

Read more Read less
4.8

186 reviews

5
174
4
1
3
7
2
0
1
4

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions