Use the following information to answer questions 19 - 20. The Die class from chapter 4 has two constructors defined as follows. Assume MIN_FACES is an int equal to 4. public Die( ) public Die(int faces) { { numFaces = 6; if(faces < MIN_FACES) numFaces = 6; faceValue = 1; else numFaces = faces; } faceValue = 1; }


Use the following information to answer questions 19 - 20. The Die class from chapter 4 has two constructors defined as follows. Assume MIN_FACES is an int equal to 4.


public Die( ) public Die(int faces)

{ {

numFaces = 6; if(faces < MIN_FACES) numFaces = 6;

faceValue = 1; else numFaces = faces;

} faceValue = 1;

}

1) The instruction Die d = new Die(10); results in


a) The Die d having numFaces = 6 and faceValue = 1

b) The Die d having numFaces = 10 and faceValue = 1

c) The Die d having numFaces = 10 and faceValue = 10

d) The Die d having numFaces = 6 and faceValue = 10

e) A syntax error

Answer: b. Explanation: Since an int parameter is passed to the constructor, the second constructor is executed, which sets numFaces = 10 (since numFaces >= MIN_FACES) and faceValue = 1.

2) The instruction Die d = new Die(10, 0); results in


a) The Die d having numFaces = 6 and faceValue = 1

b) The Die d having numFaces = 10 and faceValue = 1

c) The Die d having numFaces = 10 and faceValue = 10

d) The Die d having numFaces = 6 and faceValue = 10

e) A syntax error

Answer: e. Explanation: The Die class has two constructors, one that receives no parameters and one that receives a single int parameter. The instruction above calls the Die constructor with 2 int parameters. Since no constructor matches this number of parameters exists, a syntax error occurs.