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
Document preview thumbnail
Preview 3 out of 19 pages
Exam (elaborations)

AP Computer Science A Unit 9 Progress Check: MCQ / Review Questions & Certified Solutions / 100% Correct / Already Graded A+.

Document preview thumbnail
Preview 3 out of 19 pages

Consider the following class declarations. public class Dog { private String name; public Dog() { name = "NoName"; } } public class Poodle extends Dog { private String size; public Poodle(String s) { size = s; } } The following statement appears in a method in another class. Poodle myDog = new Poodle("toy"); Which of the following best describes the result of executing the statement? B. The Poodle variable myDog is instantiated as a Poodle. The instance variable size is initialized to "toy". An implicit call to the no-argument Dog constructor is made, initializing the instance variable name to "NoName".

Content preview

AP Computer Science A Unit 9 Progress Check: MCQ /
Review Questions & Certified Solutions / 100% Correct /
Already Graded A+.




Consider the following class B. The Poodle variable myDog is instantiated as a Poodle. The instance
declarations. variable size is initialized to "toy". An implicit call to the no-argument Dog
constructor is made, initializing the instance variable name to "NoName".
public class Dog
{
private String name;


public Dog()
{
name = "NoName";
}
}


public class Poodle extends
Dog
{ private String size;


public Poodle(String s)
{ size =
s;
}
}
The following statement appears
in a method in another class.
Poodle myDog = new
Poodle("toy");
Which of the following best
describes the result of executing the
statement?




Terms in this set (18)

,Consider the following class A. BallCap myHat = new BallCap("L", "Denver");
declarations. public class Hat System.out.println(myHat);
{ private String size;


public Hat(String s)
{ size =
s;
}


public String toString()
{ return "Size " + size + " hat";
}
}


public class BallCap extends
Hat
{
private String team;


public BallCap(String mySize,
String myTeam)
{
super(mySize); team
= myTeam;
}


public String toString()
{ return super.toString() + " with " +
team + " logo";
}
}
A code segment located in a different
class is intended to produce the
following output. Size L hat with
Denver logo Which of the following
code segments will produce this
output?

, Consider the following class E. Line 8 causes a compile-time error because the getCompass method is not
declarations. defined for objects of type MultiTool.
public class MultiTool
{ private int blade;
private int screwdriver;


public MultiTool(int b, int s)
{
blade = b; screwdriver =
s;
}
}


public class DeluxeMultiTool
extends MultiTool
{
private boolean compass;


public DeluxeMultiTool(int b, int s,
boolean c)
{ super(b, s);
compass = c;
}


public String getCompass()
{
return compass + "";
}
}
The following code segment
appears in a method in another
class.
ArrayList<MultiTool> toolList = new
ArrayList<MultiTool>();
MultiTool tool1 = new
DeluxeMultiTool(4, 2, false); //
Line 2
DeluxeMultiTool tool2 = new
DeluxeMultiTool(3, 1, true); //
Line 3 toolList.add(tool1); //
Line 4 toolList.add(tool2); //
Line 5 for (MultiTool tool :
toolList)
{
System.out.println(tool.getComp
ass()); // Line 8
}
The code segment does not
compile. Which of the following
best explains the cause of the
error?

Document information

Uploaded on
April 28, 2025
Number of pages
19
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$23.49
Purchased by 0 students

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

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.
ExamsTest
4.4
(1516)
Sold
3785
Followers
16
Items
966
Last sold
6 days ago


Reviews from verified buyers




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