This site is retired and is no longer updated since November 2021. Please visit our new website at https://www.teamscode.org for up-to-date information!
Overview Lesson #4

Below is a list of all the lessons this overview lesson will cover.

  1. Objects
  2. Object-Oriented Programming
  3. Inheritance
  4. Inheritance Principles
  5. Abstract Classes
  6. Interfaces
  7. Polymorphism

Lesson Quiz

Each question in this quiz corresponds to that lesson, so if you miss a specific problem, go back to that problem’s lesson to review.

1. What is one main difference between objects and primitives?

a. Objects don’t use variable assignment.
b. Programmers can create new objects from custom-defined classes but cannot create new primitives.
c. All objects are mutable while all primitives are immutable.
d. Casting works on primitives but not on objects.

2. Which of the following is not a benefit of object-oriented programming?

a. Classes created in other programs can easily be reused for other uses.
b. Knowledge of an object’s implementation is not necessary for its usage.
c. Object-oriented programming projects are typically much smaller and take less time to create.
d. Programmers can create objects that hide certain aspects in order to avoid others from changing values necessary to the object.

3. What is a superclass?

a. A class that has a subclass which inherits some of its methods/fields.
b. A class that hides information from the user.
c. A class that inherits methods/fields from another class.
d. A class that can be accessed without creating an instance of that class.

4. If the GoldenRetriever class extends the Dog class, which of the following code segments would cause a error?

a. GoldenRetriever goldenRetriever = new Dog();
b. Dog goldenRetriever = new GoldenRetriever();
c. Both a. and b. would cause an error.

5. Is the following line of code valid?

    BankAccount myAccount = new BankAccount(); // BankAccount is an abstract class
a. Yes
b. No

6. Which of the following is true about interfaces?

a. An interface extending another interface is responsible for implementing all of its methods.
b. Interface methods can have access modifiers such as public, private, and protected.
c. Interfaces are the same as abstract classes.
d. Interfaces do not have constructors.

7. What is polymorphism?

a. The mechanism of the correct method being selected for a specific object out of a class hierarchy.
b. The process of making a decision during compile-time.
c. The process of creating a class hierarchy which can be used to more easily share code among classes.
d. Creating a class that represents an abstract concept by not fully implementing all of the methods.

Written by Chris Elliott

Notice any mistakes? Please email us at learn@teamscode.com so that we can fix any inaccuracies.