CS 7643 QUIZ 1 EXAM REVIEW SOLVED QUESTIONS COMPLETE ANSWERS GRADED A PLUS
Question:
A literal string is called a(n) ____.
Answer:
anonymous object
Question:
In order to use a variable both with a try or catch block and afterward, you must declare the variable
before the ____ block begins.
Answer:
try
Question:
The ____ option must be used when running a program in order to see the results of assert
statements.
Answer:
-ea
Question:
A(n) ____ is a Java language feature that can help you detect logic errors that do not cause a
program to terminate, but nevertheless produce incorrect results.
Answer:
assertion
,Question:
What is the output of the following code: loopCount = 1;while(loopCount < 3){
System.out.println("Hello"); loopCount = loopCount + 1; }
Answer:
Hello Hello
Question:
A ____ chooses among alternative courses of action based on some value within a program.
Answer:
decision structure
Question:
A logical structure called a(n) ____ structure is when one step follows another unconditionally.
Answer:
sequence
Question:
Since the ArrayList class is part of the java.util package, you can use the java.util.*; import
statement to access it.
Answer:
True
Question:
An ArrayList's ____ is the number of items it can hold without having to increase its size.
Answer:
capacity
, Question:
The disadvantage to using the conditional operator is that it ____.
Answer:
can be difficult to read
Question:
Which of the following correctly declares and initializes a String object?
Answer:
String greeting = "Hello";
Question:
Which of the following println statements will display the last myScores element in an array of 10?
Answer:
System.out.println(vals[9]);
Question:
Which Java statement creates a jagged array with six rows?
Answer:
double [][] sales = new double[6][]
Question:
The logical OR operator
Answer:
||
Question:
Question:
A literal string is called a(n) ____.
Answer:
anonymous object
Question:
In order to use a variable both with a try or catch block and afterward, you must declare the variable
before the ____ block begins.
Answer:
try
Question:
The ____ option must be used when running a program in order to see the results of assert
statements.
Answer:
-ea
Question:
A(n) ____ is a Java language feature that can help you detect logic errors that do not cause a
program to terminate, but nevertheless produce incorrect results.
Answer:
assertion
,Question:
What is the output of the following code: loopCount = 1;while(loopCount < 3){
System.out.println("Hello"); loopCount = loopCount + 1; }
Answer:
Hello Hello
Question:
A ____ chooses among alternative courses of action based on some value within a program.
Answer:
decision structure
Question:
A logical structure called a(n) ____ structure is when one step follows another unconditionally.
Answer:
sequence
Question:
Since the ArrayList class is part of the java.util package, you can use the java.util.*; import
statement to access it.
Answer:
True
Question:
An ArrayList's ____ is the number of items it can hold without having to increase its size.
Answer:
capacity
, Question:
The disadvantage to using the conditional operator is that it ____.
Answer:
can be difficult to read
Question:
Which of the following correctly declares and initializes a String object?
Answer:
String greeting = "Hello";
Question:
Which of the following println statements will display the last myScores element in an array of 10?
Answer:
System.out.println(vals[9]);
Question:
Which Java statement creates a jagged array with six rows?
Answer:
double [][] sales = new double[6][]
Question:
The logical OR operator
Answer:
||
Question: