COMP 328 Final Guide COMP 328 Final Guide | Page 2
4: Which of the following is a Scanner method?
a.nextLine
b.nextText
c.nextWord
d.readNext
5: Every Java application is required to have
a. at least one public static method.
b.at least one data member.
c. a String variable which holds the name of the application.
d.a content pane and several GUI components.
6: Which of the following statements about creating arrays and initializing their elements is
false?
a. The new keyword should be used to create an array.
b. When an array is created, the number of elements must be placed in square brackets
following the type of element being stored.
c. The elements of an array have unknown values just after the array has been created.
d. A for loop is an excellent way to initialize the elements of an array.
7: Assume the following class declaration.
class MyClass
{
int a;
String q;
public void firstMethod()
{
int b, ;