Greenfoot Ch 4 Practice

11 Questions | Attempts: 212
Share

SettingsSettingsSettings
Greenfoot Quizzes & Trivia

Review over Ch 4 and notes


Questions and Answers
  • 1. 
    A constructor must be called to create an object
    • A. 

      True

    • B. 

      False

  • 2. 
    Common characteristics of a constructor’s signature
    • A. 

      Same name as the class

    • B. 

      No return type

    • C. 

      Public modifier

  • 3. 
    This is a valid constructor public  void AnimalWorld()     {            // Create a new world with 400x300 cells         // with a cell size of 1x1 pixels.         super(400, 300, 1);     }
    • A. 

      True

    • B. 

      False

  • 4. 
    This is a valid constructor public Elephant()     {         imageDown = new GreenfootImage("elephant.png");         imageUp = new GreenfootImage("elephant2.png");         setImage(imageDown);     }
    • A. 

      True

    • B. 

      False

  • 5. 
    Given the following constructor, what is the correct way to add an elephant object from this constructor at coordinates, 50,50? public Elephant()     {         imageDown = new GreenfootImage("elephant.png");         imageUp = new GreenfootImage("elephant2.png");         setImage(imageDown);     }
    • A. 

      Elephant();

    • B. 

      New Elephant()

    • C. 

      This is an invalid constructor.

    • D. 

      AddObject(new Elephant(), 50,50)

  • 6. 
    An instance variable is sometimes called a ________
  • 7. 
    You may not be accessed directly by any code outside the class (can’t get to it with the ‘.’)  and is not inherited by subclasses.
    • A. 

      Private

    • B. 

      Protected

    • C. 

      Public

  • 8. 
    It may not be accessed directly by any code outside the class (can’t get to it with the ‘.’) and it is inherited by subclasses.
    • A. 

      Private

    • B. 

      Protected

    • C. 

      Public

  • 9. 
    It may be accessed directly by any code outside the class and it is inherited by subclasses.
    • A. 

      Private

    • B. 

      Protected

    • C. 

      Public

  • 10. 
    Constructors are sometimes used to initialize instance variables – especially if they represent objects.
    • A. 

      True

    • B. 

      False

  • 11. 
    Attempt to always use local variables except when the variable exhibits a natural “has-a” relationship to the object For Example:  A car has a make, model, type, color
    • A. 

      True

    • B. 

      False

Back to Top Back to top
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.