Question: Add code to both constructors. The code creates and array of references which is initialized to null when we use new. Then, we add objects

Add code to both constructors. The code creates and array of references which is
initialized to null when we use new. Then, we add objects or type
TrueFalseQuestion to the array. Type and undestand the comments inside the 2nd
constructor.
package lab2;
import java.util.Date;
public class TrueFalseQuiz
{
int currectQuestion;
TrueFalseQuestion [] trueFalseQuestions;
public TrueFalseQuiz()
{
trueFalseQuestions = new TrueFalseQuestion [5];
trueFalseQuestions [0]=
new TrueFalseQuestion("The Pacific Ocean is larger than the Atlantic Ocean",
true, new Date());
trueFalseQuestions [1]=
new TrueFalseQuestion("The Suez Canal connects the Red Sea and the Indian Ocean.",
false, new Date());
trueFalseQuestions [2]=
new TrueFalseQuestion("The source of the Nile River is in Egypt.",
false, new Date());
trueFalseQuestions [3]=
new TrueFalseQuestion("Lake Baikal is the world's oldest and deepest freshwater lake.",
true, new Date ());
trueFalseQuestions [4]=
new TrueFalseQuestion("The Amazon River is the longest river in the Americas.",
true, new Date());
this. currectQuestion =0;
}
public TrueFalseQuiz(String[] questions, boolean [] trueFalse )
{
//>create an array of REFERENCES of size questions. length
llthe references are intialized to null
 Add code to both constructors. The code creates and array of

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To complete the task you need to add code to both constructors of the TrueFalseQuiz class so that the array of references to TrueFalseQuestion objects ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!