Questions from Starting Out With Java


Q: What import statement will you need in a program that performs file

What import statement will you need in a program that performs file operations?

See Answer

Q: What class do you use to write data to a file?

What class do you use to write data to a file?

See Answer

Q: Convert the following pseudocode to Java code. Be sure to declare

Convert the following pseudocode to Java code. Be sure to declare the appropriate variables. Store 20 in the speed variable. Store 10 in the time variable. Multiply speed by time and store the result...

See Answer

Q: Write code that does the following: opens a file named MyName

Write code that does the following: opens a file named MyName.txt, writes your first name to the file, and then closes the file.

See Answer

Q: How many times will "Hello World" be printed in the

How many times will "Hello World" be printed in the following program segment? int count = 10; while (count < 1) { System.out.println("Hello World"); count++; }

See Answer

Q: What classes do you use to read data from a file?

What classes do you use to read data from a file?

See Answer

Q: Write code that does the following: opens a file named MyName

Write code that does the following: opens a file named MyName.txt, reads the first line from the file and displays it, and then closes the file.

See Answer

Q: You are opening an existing file for output. How do you

You are opening an existing file for output. How do you open the file without erasing it, and at the same time make sure that new data that is written to the file is appended to the end of the file’...

See Answer

Q: What clause must you write in the header of a method that

What clause must you write in the header of a method that performs a file operation?

See Answer

Q: Assume x is an int variable, and rand references a Random

Assume x is an int variable, and rand references a Random object. What does the following statement do? x = rand.nextInt ();

See Answer