Java Fundamentals  «Prev  Next»
 

Working with Objects | Classes - Quiz


Each question is worth one point. Select the best answer for each question.
1. A class is identified as the child of a parent class by using:
Please select the best answer.
  A. The class keyword
  B. The extends keyword
  C. The child keyword

2. From the perspective of the Java compiler, what distinguishes two overloaded methods from each other?
Please select the best answer.
  A. Their names
  B. Their bodies
  C. Their parameters


122
3. What is unique about the default constructor for a class compared to other constructors for the class?
Please select the best answer.
  A. It always returns a type void.
  B. It is named the same as the class in which it appears.
  C. It takes no parameters.

4. Given the Planet class, identify the code to instantiate a Planet object with the name "Jupiter" and the color "Color.red".
import java.awt.Color;
public class Planet {
  String name;
  Color  color;
  public Planet(String n, Color c) {
    name  = n;
    color = c;
  }
}

Please select the best answer.
  A. Planet p = Planet("Jupiter", Color.red);
  B. Planet = new Planet("Jupiter", Color.red);
  C. Planet p = new Planet("Jupiter", Color.red);

122

5. What does a class that is derived from another class inherit from the parent class?
Please select the best answer.
  A. Properties only
  B. Methods only
  C. Properties and methods

6. If a class doesn't explicitly declare a parent class:
Please select the best answer.
  A. It derives from the Default class
  B. It derives from the Object class
  C. It doesn't derive from any class

122
7. Replacing an inherited method with a newer version is known as:
Please select the best answer.
  A. Overloading the method
  B. Overriding the method
  C. Overwriting the method

Your score is 0.0