_Ale
Jeremiah
AP Computer Science A Unit 9 Progress Check: MCQ
Practice questions for this set
Learn 1/7 Study with Learn
C. Object myBook is created using the one-argument Book constructor, which uses
super to set myBook's title attribute to "Adventure Story". Object yourBook is created
using super to call to the Publication no-argument constructor to set yourBook's title
attribute to "Generic".
Choose matching term
Consider the following class declarations.
public class Publication
{
private String title;
public Publication()
{
title = "Generic";
}
public Publication(String t)
{
title = t;
}
}
1
public class Book extends Publication
{
public Book()
{
AP Computer super();A
Science Unit 9 Progress Check: MCQ
}
1/20
,8/27/24, 5:54 PM
public Book(String t)
{
super(t);
}
}
The following code segment appears in a method in another class.
Book myBook = new Book("Adventure Story"); // Line 1
Book yourBook = new Book(); // Line 2
Which of the following best describes the result of executing the code segment?
Consider the following classes.
public class Bird
{
public void sing()
{
System.out.println("Cheep");
}
}
public class Duck extends Bird
{
public void sing()
{
System.out.println("Quack");
}
}
2 public class Chicken extends Bird
{
// No methods defined
}
public class Rooster extends Chicken
{
public void sing()
{
System.out.println("Cockadoodle doo");
}
}
The following statement appears in a method in another class.
someBird.sing();
Under which of the following conditions will the statement compile and run without error?
I. When someBird has been declared as type Duck
II. When someBird has been declared as type Chicken
III. When someBird has been declared as type Rooster
AP Computer Science A Unit 9 Progress Check: MCQ
2/20
, 8/27/24, 5:54 PM
Consider the following class declarations.
public class Person
{
public void laugh()
{
System.out.print("Hahaha");
}
}
public class EvilPerson extends Person
{
public void laugh()
{
3 System.out.print("Mwahahaha");
}
}
public class Henchman extends EvilPerson
{
// No methods defined
}
The following code segment appears in a method in another class.
alice.laugh();
Under which of the following conditions will the code segment print "Mwahahaha" ?
I. When alice has been declared as type Person
II. When alice has been declared as type EvilPerson
III. When alice has been declared as type Henchman
Consider the following class declarations.
public class Dog
{
private String name;
public Dog()
{
name = "NoName";
}
}
4 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?
Don't know?
Terms in this set (18)
AP Computer Science A Unit 9 Progress Check: MCQ
3/20