Comp 110 - California State University, Northridge



Comp 110 Name ___________________

Quiz #8

Circle the best answer for each of the following questions. There is no penalty for guessing.

1. Which of the following statements is false with respect to classes in Java?

a) A class is a template or blue print that defines what an object’s data and methods will be.

b) A class uses variables to define data fields.

c) A class uses methods to define behaviors.

d) All classes must have a main method

2. Which of the following statements is false with respect to objects in Java?

a) An object is an instance of a class.

b) The state of an object is defined by a set of methods.

c) Objects are accessed via object reference variables.

d) Objects represent entities in the real world.

3. Arrays are treated as objects in Java.

a) True

b) False

4. Which of the following statements is false about constructors in Java?

a) The name of a constructor must be different from the defining class.

b) A class can be declared without a constructor.

c) Constructors play the role of initializing objects.

d) Constructors do not have a return type.

5. After an object is created its data can be accessed and its methods invoked using the dot operator (.), e.g., myCircle.radius or myCircle.getArea().

a) True

b) False

6. Which is the following is true about reference variables?

a) The value of a reference variable is a reference to where an object is located.

b) If a reference variable does not reference any object it has the value null.

c) If you set one reference variable equal to another, they will reference the same object.

d) All of the above statements are true.

7. What is the printout of the following code?

public class Foo {

private boolean x;

public static void main(String[] args) {

Foo foo = new Foo();

System.out.println(foo.x);

}

}

a) true

b) false

c) null

d) 0

8. The getTime method of the Date class returns the elapsed time in seconds since Jan 1, 1970 GMT.

a) True

b) False

9. The Date class is in which Java package?

a) java.lang

b) javax.swing

c) java.util

d) java.calendar

10. When you create a Random object, you have to specify a seed or use the default seed, and if two Random objects have the same seed they will generate identical sequences of numbers.

a) True

b) False

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download