Java Program - Object-Oriented Programming II - Quiz 1 | CMSC 132, Quizzes of Computer Science

Material Type: Quiz; Class: OBJECT-ORIENTED PROG II; Subject: Computer Science; University: University of Maryland; Term: Unknown 1989;

Typology: Quizzes

Pre 2010

Uploaded on 02/13/2009

koofers-user-o4y-1
koofers-user-o4y-1 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CMSC 132 Quiz 1 Worksheet
The first quiz for the course will be on Friday, June 9 in lecture. The following list provides more
information about the quiz:
The quiz will be a written quiz (no computer).
Closed book, closed notes quiz.
Answers must be neat and legible. We recommend that you use pencil and eraser.
The following exercises cover the material to be included in this quiz. Solutions to these exercises
will not be provided, but you are welcome to discuss your solutions with the TA or instructor
during office hours.
Problem I
1. Write a Java program that copies the contents of a text file (source file) to another
text file. The program must ask for a source file name as long as an invalid file
name (e.g., a name for a file that does not exist) is provided.
2. Write a Java program that reads a sequence of integer values and computes the
average. The program will give the user the choice of reading data either from the
standard input (System.in) or from a file. In addition, the program will give the
user the choice of sending the output to the standard output (System.out) or a
specific file.
3. Implement a method named compareStrArrays that has the following prototype:
public static boolean compareStrArrays(String[][] array1, String[][] array2);
The method will return true if the arrays have the same dimensions and the same
String values. Keep in mind that each array can have rows with different lengths.

Partial preview of the text

Download Java Program - Object-Oriented Programming II - Quiz 1 | CMSC 132 and more Quizzes Computer Science in PDF only on Docsity!

CMSC 132 Quiz 1 Worksheet

The first quiz for the course will be on Friday, June 9 in lecture. The following list provides more information about the quiz:

  • The quiz will be a written quiz (no computer).
  • Closed book, closed notes quiz.
  • Answers must be neat and legible. We recommend that you use pencil and eraser.

The following exercises cover the material to be included in this quiz. Solutions to these exercises will not be provided, but you are welcome to discuss your solutions with the TA or instructor during office hours.

Problem I

  1. Write a Java program that copies the contents of a text file (source file) to another text file. The program must ask for a source file name as long as an invalid file name (e.g., a name for a file that does not exist) is provided.
  2. Write a Java program that reads a sequence of integer values and computes the average. The program will give the user the choice of reading data either from the standard input (System.in) or from a file. In addition, the program will give the user the choice of sending the output to the standard output (System.out) or a specific file.
  3. Implement a method named compareStrArray s that has the following prototype:

public static boolean compareStrArrays(String[][] array1, String[][] array2);

The method will return true if the arrays have the same dimensions and the same String values. Keep in mind that each array can have rows with different lengths.