What is a driver program?
A program that does nothing but test a specific method.
What is decomposition?
A design strategy that breaks a task down into several subtasks.
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.
A stub is a simplified version of a method that is sufficient for testing purposes.
True
Calling a method on a variable with a value of null
will result in an error message.
True
Which of the following is not part of the signature of a method?
The return type of a method.
Regular methods may be overloaded, but a constructor may not be overloaded.
False
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)
Two methods may have the same name if they have different number of arguments.
True
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.