Creating Classes, Objects, and Methods
Creating Classes, Objects, and Methods
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 1
(Answer all questions in this section)
1. Which of the following creates a class named Diver with one constructor, and 2
instance variables maxDepth and certified?
Mark for
Review
(1) Points
(*)
Mark for
Review
(1) Points
class (*)
classpath
method
package
Mark for
Review
(1) Points
Mark for
Review
(1) Points
Mark for
Review
(1) Points
instance variables
instance methods
constructors
comments
all of the above (*)
6. Which of the following creates a Object from the Animal class listed below?
Mark for
Review
(1) Points
Mark for
Review
(1) Points
True
False (*)
8. Which of the following creates an object from the Car class listed below?
Mark for
Review
(1) Points
9. The following statement compiles and executes. What can you say for sure?
submarine.dive(depth);
Mark for
Review
(1) Points
10Which of the following creates a method that compiles with no errors in the class?
.
Mark for
Review
(1) Points
(*)
Mark for
Review
(1) Points
35
36
37 (*)
38
12The return value of a method can only be a primitive type and not an object. True
. or false?
Mark for
Review
(1) Points
True
False (*)
13Which of the following calls the method moveUp in the class below:
.
Mark for
Review
(1) Points
Mark for
Review
(1) Points
True (*)
False
15The constructor of a class has the same name as the class. True or false?
.
Mark for
Review
(1) Points
True (*)
False
Mark for
Review
(1) Points
17What operator do you use to call an object's constructor method and create a new
. object?
Mark for
Review
(1) Points
new (*)
class
instanceOf
18Consider:
.
public class MyClass{ public MyClass(){/*code*/} // more code...}
To instantiate MyClass, what would you write?
Mark for
Review
(1) Points
Mark for
Review
(1) Points
The operating system periodically deletes all of the Java files available on the
system.
20Which of the following keywords are used to access the instance variables of an
. object from within the class code for that object?
Mark for
Review
(1) Points
public
private
protected
this (*)
Mark for
Review
(1) Points
(*)
22Which constructor code populates the instance variables of the class correctly?
.
Mark for
Review
(1) Points
(*)