Category 1
Category 2
Category 3
100

What is another name for the superclass

a) Parent

b) Mother

c) Nephew

d) Child

Parent

100

What is the subclass of a parent class called

a) Son

b) Daughter

c) Child

d) Dog

Child

100

What keyword can be used to call the methods of a superclass that may be overridden?

a) Major

b) Superior

c) Super

d) Parent

Super

200

public class Animal {

    //makeSound is void method that prints “Animal sound” }

public class Dog extends Animal {

    //makeSound is void method that prints “Bark” }

public class Test {

    public static void main(String[] args) {

        Animal animal = new Dog();

        animal.makeSound(); } 

}

What will be printed when the program runs?

Bark

200

public class Vehicle {

    //Constructor signature → Vehicle(int speed)

    //display method prints “Speed: ” + speed }

public class Car extends Vehicle {

    //Constructor signature → Car(int speed, int horsepower)

    //display method calls super.display()

    //display method prints “Horsepower: ” + horsepower }

public class Test {

    public static void main(String[] args) {

        Car myCar = new Car(120, 300);

        myCar.display(); }  }

What is the output of the code?

Speed: 120
Horsepower: 300

200

public class Parent{

public void Massive(){

    System.out.print(“Massive”);

} }

Create a simple subclass called Child that inherits from the Parent class and includes a void method named low that prints the phrase “Low”

public class Child extends Parent{

    public void Low(){

        System.out.print(“Low”);

    }

}

300

What is the superclass for all classes in Java?

a) Class

b) Lang

c) Object

d) Util

c) Object

300

What is not inherited from superclass?

a) Instance variables

b) Constructors

c) Non-static methods

d) Static methods

b) Constructors

300

Assume S is the subclass of T. Declaring references of type T is MOST useful for which three types of declarations? (This is directly mentioned in the AP CSA Course Description.)

Formal parameters, Arrays, and ArrayLists

400

public class Animal {

    //eat is public void method that prints “Animal is eating”

}

public class Cat extends Animal {

    //eat is public void method that prints “Cat is eating”

    //meow is public void method that prints “Cat says meow”

}

Which of the following lines (can be multiple correct answers) will compile and run without error?

A. Animal a = new Cat(); a.eat();

B. Animal a = new Cat(); a.meow();

C. Cat c = new Animal(); c.eat();

D. Cat c = new Cat(); c.meow();

A and D

400

public class Shape {

    //getArea method returns double value of 0 }

public class Rectangle extends Shape {

    //Constructor signature → Rectangle(double length, double width)

//getArea method returns double of length * width }

public class Circle extends Shape {

    //Constructor signature → Circle(double radius)

    //getArea method returns double of Math.PI*radius*radius }

public class ShapeTester {

    public static void main(String[] args) {

        Shape s1 = new Rectangle(5, 4); Shape s2 = new Circle(3); Rectangle r1 = new Rectangle(2, 6); System.out.println(s1.getArea()); System.out.println(s2.getArea()); System.out.println(r1.getArea()); } }

What will be the output when the main method of ShapeTester is executed?

20.00

28.27

12.00

400

public class Animal {

    //makeSound method returns “Animal sound” }

public class Dog extends Animal {

    //makeSound method returns “Woof” }

public class Cat extends Animal {

    //makeSound method returns “Meow” }

public class AnimalTester {

    public static void main(String[] args) {

        Animal a1 = new Dog(); Animal a2 = new Cat(); Dog d1 = new Dog();

        System.out.println(a1.makeSound()); System.out.println(a2.makeSound()); System.out.println(d1.makeSound()); } }

What will be the output when the main method of AnimalTester is executed?


Woof

Meow

Woof