You are on page 1of 5

Score for this attempt: 10 out of 10

Submitted Feb 27 at 5:45pm


This attempt took less than 1 minute.

1 / 1 pts
Question 1

An item that separates other items is known as a ________.

partition

delimiter

sentinel

terminator

1 / 1 pts
Question 2

The variable used to keep a running total in a loop is called a(n)


________.

accumulator

sentinel

summation

integer

1 / 1 pts
Question 3

Assume that inputFile references a Scanner object that was


used to open a file. Which of the following while loops is the correct
way to read data from the file until the end of the file is reached?

while (inputFile.nextLine == " ")

{ ... }
while (inputFile != null)

{ ... }

while (!inputFile.EOF)

{ ... }

while (inputFile.hasNext())

{ ... }

1 / 1 pts
Question 4

When working with the PrintWriter class, which of the


following import statements should you have near the top of your
program?

import javax.swing.*;

import javac.io.*;

import java.io.*;

import java.file.*;

1 / 1 pts
Question 5

Which of the following statements opens a file


named MyFile.txtand allows you to read data from it?

Scanner inputFile = new Scanner("MyFile.txt");

File file = new File("MyFile.txt");

Scanner inputFile = new Scanner(file);

File Scanner = new File("MyFile.txt");


PrintWriter inputFile = new
PrintWriter("MyFile.txt");

1 / 1 pts
Question 6

Which of the following is the method you can use to determine whether
a file exists?

the File class's canOpen method

the Scanner class's exists method

the File class's exists method

the PrintWriter class's fileExists method

1 / 1 pts
Question 7

What will be the values of x and y as a result of the following code?


int x = 25, y = 8;
x += y++;

x = 34, y = 9

x = 25, y = 8

x = 33, y = 8

x = 33, y = 9

1 / 1 pts
Question 8
How many times will the following do-while loop be executed?

1 / 1 pts
Question 9

What will be the value of x after the following code is executed?


int x, y = 4, z = 6;
x = (y++) * (++z);

24

28

30

35

1 / 1 pts
Question 10

What will be the value of x after the following code is executed?


90

110

210

this is an infinite loop

Quiz Score: 10 out of 10

You might also like