logo

APSU Notes


Quiz 10

Question 1

What is a driver program?

A program that does nothing but test a specific method.

Question 2

What is decomposition?

A design strategy that breaks a task down into several subtasks.

Question 3

Why does the following code cause a compiler error?

1
2
3
4
5
6
7
public int min(int num1, int num2)
{
    if (num1 < num2)
        return num1
    else if (num2 < num1)
        return num2
}

The method doesn’t return a value in some cases.

Question 4

A stub is a simplified version of a method that is sufficient for testing purposes.

True

Question 5

Calling a method on a variable with a value of null will result in an error message.

True

Question 6

Which of the following is not part of the signature of a method?

The return type of a method.

Question 7

Regular methods may be overloaded, but a constructor may not be overloaded.

False

Question 8

Given the following method header:

1
public double computeArea(double length, double width)

Which of the following would be legal overloaded method in the same class?

1
public double computeArea(double length)

Question 9

Two methods may have the same name if they have different number of arguments.

True

Question 10

Given the following constructors:

1
2
3
public Rectangle (int width, double length)

public Rectangle (double width, int length)

Which constructor will the following statement call?

1
Rectangle rect = new Rectangle(4, 6)

Java will generate an error.