Exam 4: Writing Classes

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

Java methods can return only primitive types (int, double, float, char, boolean, etc).

Free
(True/False)
4.8/5
(35)
Correct Answer:
Verified

False

An example of passing message to a String where the message has a String parameter would occur in which of the following messages?

Free
(Multiple Choice)
4.8/5
(31)
Correct Answer:
Verified

C

Write a statement to instantiate a cube with a length of 3, width of 3, and height of 3.

Free
(Short Answer)
4.9/5
(29)
Correct Answer:
Verified

Box cube = new Box(3);

What happens if you declare a class constructor to have a void return type?

(Multiple Choice)
4.8/5
(33)

Formal parameters are those that appear in the method call and actual parameters are those that appear in the method header.

(True/False)
4.7/5
(54)

Write the statement to instantiate an Box object, blueBox, with a length of 6, width of 4, and height of 2.

(Short Answer)
4.8/5
(32)

To define a class that will represent a car, which of the following definitions is most appropriate?

(Multiple Choice)
4.9/5
(34)

A class' constructor usually defines

(Multiple Choice)
4.7/5
(40)

The relationship between a class and an object is best described as

(Multiple Choice)
4.9/5
(32)

Having multiple class methods of the same name where each method has a different number of or type of parameters is known as

(Multiple Choice)
4.9/5
(35)

A constructor may contain a return statement so long as no value (or expression) is returned.

(True/False)
4.8/5
(48)

The expressions that are passed to a method in an invocation are called

(Multiple Choice)
4.8/5
(28)

If a method does not have a return statement, then

(Multiple Choice)
4.9/5
(47)

The following method header definition will result in a syntax error: public void aMethod( );

(True/False)
4.9/5
(45)

Consider a method defined with the header: public void doublefoo(double x). Which of the following method calls is legal?

(Multiple Choice)
4.7/5
(42)

Assume method0 calls method1 and method2, method1 calls method3 which calls method4 and method5. Explain the chain of method calls (what order methods are called and from which method).

(Essay)
4.9/5
(38)

While multiple objects of the same class can exist, in a given program there can be only one version of each class.

(True/False)
4.9/5
(38)

In a UML diagram for a class

(Multiple Choice)
4.9/5
(32)

Visibility modifiers include

(Multiple Choice)
4.9/5
(37)

Write a toString method that returns the player's name, position and batting average formatted to have 1 digit to the left of the decimal and 3 digits to the right of the decimal. Assume DecimalFormat has been imported.

(Essay)
4.8/5
(38)
Showing 1 - 20 of 56
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)