logo

APSU Notes


Quiz 9

Question 1

What is a default constructor?

A public method that takes no arguments and initializes instance variables.

Question 2

Which of the following is a correct header for a constructor for a class called Employee?

1
public Employee(String name)

Question 3

Only one constructor may be defined per class.

False

Question 4

If no constructors are defined for a class, Java will automatically define a default constructor.

True

Question 5

Given a class called Rectangle with a constructor that takes two doubles as arguments representing the dimensions, which of the following is the correct way to invoke that constructor?

1
Rectangle rect = new Rectangle(8.2, 3.5);

Question 6

What is the difference between a static variable and an instance variables?

A static variable is shared by all objects of a class. Every object has its own version of an instance variable.

Question 7

Which of the following is not allowed in Java?

A static method calling a nonstatic method of the same class without an object to call it on.

Question 8

An import statement is required to use the java Math class.

False

Question 9

What is a wrapper class?

A class that provides methods for manipulating a primitive type.

Question 10

Every wrapper class has a default constructor.

False