How many and what kind of variables (primitive or object) are created in the code below?
```
> World worldObj = new World(); // worldObj is an object variable
> Turtle turtle1 = new Turtle(worldObj); // turtle1 is an object variable
> turtle1.forward(30);
> Turtle turtle2 = new Turtle(worldObj); // turtle2 is an object variable
> turtle2.turnRight();
> turtle2.forward(30);
```
This creates 3 object variables.
You might also like to view...
Which of the following statements is false?
a. You should not call methods from constructors. b. Nested if statements can be useful for validating values. c. Logical operators can express nested if statements more concisely. d. One problem with calling methods from constructors is that it can lead to duplicated validation code.
Which of the following statements creates a Slider with a range of 1 to 20 with a starting value of 1?
a. Slider slider = new Slider(0, 20, 1); b. Slider slider = new slider(0.0, 20.0, 1.0); c. Slider slider = new Slider(1.0, 20.0, 1.0); d. Slider slider = new Slider(1.0, 20);
Find the errors in the following code segments and explain how to correct them.
``` switch (n) { case 1: cout << "The number is 1" << endl; case 2: cout << "The number is 2" << endl; break; default: cout << "The number is not 1 or 2" << endl; } ```
Class definitions usually begin with the keyword private.
Answer the following statement true (T) or false (F)