Classes & Objects
Instance Methods
Static & This
Inheritance & Polymorphism
Miscellaneous
100

Given the Rectangle Class with a Constructor that takes in two ints, write a line of code that would create an instance of the Rectangle class named rec1 with ints 3 and 7. 

Rectangle rec1 = new Rectangle(3, 7);

100

What is the common name of the method you use to get the value of a private instance variable? 

The getter method

100

The "static" keyword in front of a variable means that it is a general variable that applies to the whole class, and not any object made from that class.  

What is the "static" keyword used for most often (or one common use for it)? 

To create a variable that keeps track of the number of objects created. 

100

Where do we use the "extends" keyword? 

"extends" is used in the class declaration after the class name and before the name of the superclass it descends from. 
100

What country did the first Starbucks open outside of North America? 

Japan

200

What is missing from this class definition? 

public class Student {

    public Student(int age) {

        this.age = age; 

    }

}

private int age;

needs to be declared in the class definition before the Constructor. 

200

Given an instance of the Pizza class with private instance variable String topping, write a setter method for topping. 

public String getTopping()
{
    return topping;
}

200

Must use "this" in constructor (this.height = height) when the parameters have the same name as instance variables.  

OR   

Must change parameters so they are not the same as instance variables (height = myHeight;)

200

What does the "super" keyword do in the Constructor or a subclass? 

The "super" keyword in a Constructor of a subclass calls the superclass's Constructor.  The parameters will decide which Constructor will be called if it is overloaded. 

200

What was the first Disney animated feature movie that was not based on an already existing story? 

The Lion King (though it has some loose connection to Hamlet, it is NOT an adaptation of it)

300

Given a Book class with private instance variables String title and int pageCount, write a Constructor that would create an instance of the Book class. 

public Book(String title, int pageCount)
{
    this.title = title;
    this.pageCount = pageCount;
}

300

What would a blank default constructor for the Rectangle class look like? 

public Rectangle() {}

300

Which of these variables exist only from lines 3 to 5? 

1.    public class Example{
2.       private int a = 0;
3.       public int mystery1(int b) {
4.             int c = 5 + a;
5.             return c;
6.        }
7.    }
        

b

B starts on line 3 where it is declared, and ends when the box where it was created is closed by line 6. 

300

Write an example of polymorphism for a superclass "Animal" and subclass "Dog".  

Creating an object named "spot" built with the default Constructor.  

The object "spot" should then call the "talk()" method. 

Animal spot = new Dog();
spot.talk();

300

What is the human body's heaviest organ? 

The skin! 

400

r1.height = 5;

400

Given an instance of the Movie class called "Shrek", what is the proper way to set the value of "length" to 92 after it has been instantiated? 

https://docs.google.com/document/d/1sAM9AMtnq665oJb2FGK-L-78KifD35InLoPhC24h_n8/edit?tab=t.0#heading=h.lmvwflrrmjge

It is impossible to set "length", since it is private and there is no setter method.

400

What methods of class Mystery can be called without an instance of the class?

public class Foo {    
    public static void sum()    {
            ...    
    }

     public static void average()    {
            ...
    }
     public void count()
    {
            ...
    }
}

Only "sum" and "average" can be called without creating an instance of the class because they are static. 

400

Which of the following will be inherited from a superclass?  (Choose all that apply) 

A. the public instance variables of the superclass

B. the private instance variables of the superclass

C. the Constructors of the superclass

D. any getter or setter methods from the superclass

E. non-getter and non-setter instance methods from the superclass 

F. the toString method from the superclass

A, D, E, and F will all be inherited.  

Everything is inherited from a superclass EXCEPT for Constructors and private instance variables. 

400

What is the best selling book of all time (after the Bible)?  - as of Feb 2025

A Tale of Two Cities with over 200 million! 

Other books that have sold more than 100 million copies include: 

The Little Prince, The Alchemist, Harry Potter and the Philosopher's Stone, And Then There Were None, Dream of the Red Chamber, The Hobbit, and Alice's Adventures in Wonderland

500

[Choose all that are correct] Which of the following are correct ways to create an instance of Rectangle: 

A. Rectangle rec1 = new Rectangle(3, 7);

B.  Rectangle rec1 = new Rectangle(4);

C. Rectangle rec1;
     rec1 = new Rectangle(2, 5);

D. Rectangle rec1 = new Rectangle("Square", 8);

E. Rectangle rec1;
    new rec1 = Rectangle(6, 10);

 

A, B, and C

500

What happens when the default constructor is called for an objects (assume there is no code in the default constructor and it has been properly written in the class)? 

All of the instance variables of the class will get their default values (ints will be 0, Strings will be null, etc.)

500

What are the only two mammals that lay eggs? 

(If you get both right, you get the points!  If you only get one right, others can steal!)

Echidna and Platypus

M
e
n
u