Pages

Exam1-APCSA-17-18

This exam consists of 15 multiple choice questions and one coding exercise. For each multiple choice question there is at least one correct answer, and there might be more than one correct answer.

Instructions

  1. Write your last name in the upper right hand corner of each page of this exam.
  2. Below your last name, write the name you prefer to be called in class in parentheses.
  3. For each multiple choice question, circle the letter of the correct answer(s).
  4. Follow the instructions for the coding exercise that are provided in that section of the exam.
Each multiple choice question will be graded as follows.
  • Five points will be awarded if and only if all of the correct answers and none of the incorrect answers are circled.
  • Two points will be deducted for each correct answer that is not circled.
  • Three points will be deducted for each incorrect answer that is circled.
  • No more than five points will be deducted per question.

The coding exercise is worth 25 points. Partial credit will be awarded. The following grading scale, which is analogous to the scale use for grading programming assignments, will be used when scoring the coding exercise.

MarkPoints
++26
+25
✓+24
23
✓-21
-19
--17
00

Please, do your own work. And Don’t Panic!

(This is not the end of the world.)















When the command javac Foobar.java was executed as shown in the text box below, the file Foobar.java    contained the following two lines of Java source code.

public class FooBar {
}

PS C:\Users\John\Java> javac Foobar.java
javac.exe : Foobar.java:1: error: class FooBar is public, should be declared in a file named FooBar.java
At line:1 char:6
+ javac <<<<  Foobar.java
    + CategoryInfo          : NotSpecified: (Foobar.java:1: ...med FooBar.java:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 
public class FooBar {
       ^

1 error

The text produced by the javac command shown above is an example of what?

  1. a run-time error message
  2. a compile-time error message
  3. machine instructions
  4. portable byte code
  5. a core dump
  6. none of the above

What source code changes could be made so that when the command javac Foobar.java is executed again a file named Foobar.class is produced instead of the text shown above?

  1. Remove the word public.
  2. Insert the word static before the word class.
  3. Change the class name to Foobar.
  4. All of the above changes (a, b, and c) are required.
  5. Any combination of a, b, and c above will work.
  6. None of the above.











The following program is saved in a file such that it successfully compiles.
public class FirstProgram {
  public static void main(String[] args) {
    System.out.print("Hello, World!");
  }
}

The file that contains the source code shown above may be named what?

  1. FirstProgram.java
  2. FirstProgram.class
  3. FirstProgram.txt
  4. FirstProgram.src
  5. FirstProgram.jav
  6. FirstProgram.css

Which of the following changes could be made to the program above such that it still compiles and executes?

  1. Change the name of the class from FirstProgram to MyFirstProgram and change the name of the file to MyFirstProgram.class.
  2. Change the name of the parameter from args to arguments.
  3. Change the name of the method System.out.print to System.out.println.
  4. Remove the word static.
  5. Convert all characters to uppercase.
  6. none of the above

The authors of Computer Science - An Interdisciplinary Approach break the process of developing a Java program into three steps. What are those three steps?

  1. edit, save, execute
  2. create, execute, run
  3. create, execute, debug
  4. compile, debug, execute
  5. create, compile, execute
  6. none of the above

The program javac.exe is a what?

  1. compiler
  2. interpreter
  3. class loader
  4. editor
  5. IDE
  6. none of the above

The program java.exe is a what?

  1. compiler
  2. interpreter
  3. class loader
  4. debugger
  5. editor
  6. IDE

The program javac.exe usually produces which type(s) of files?

  1. .java files
  2. .js files
  3. .class files
  4. .css files
  5. .html files
  6. none of the above

The program java.exe usually produces which type(s) of files?

  1. .java files
  2. .js files
  3. .class files
  4. .css files
  5. .html files
  6. none of the above

The program javadoc.exe usually produces which type(s) of files?

  1. .java files
  2. .js files
  3. .class files
  4. .css files
  5. .html files
  6. none of the above

The authors of Computer Science - An Interdisciplinary Approach formally define the idea of a data type as set of X and a set of Y, where X and Y are what?

  1. values and operations
  2. ones and zeros
  3. names and values
  4. operations and methods
  5. functions and parameters
  6. none of the above


What are the two possible values of a Java variable that is of type boolean?

  1. high, low
  2. one, zero
  3. 1, 0
  4. yes, no
  5. good, bad
  6. none of the above

Which of the following primitive Java data types are used to represent real numbers (i.e. numbers that may have digits to the right of the decimal point)?

  1. byte
  2. short
  3. int
  4. long
  5. double
  6. float

Which of the following are true about Donald Ervin Knuth?

  1. Knuth’s father was a Catholic school teacher.
  2. Knuth’s mother worked in real estate in New York City.
  3. When Knuth was in high school, about half of his classmates went on to college.
  4. Knuth’s family didn’t have a car until he was in the seventh grade.
  5. Knuth’s father rode a bicycle to work.
  6. Knuth mother was able to retire early because of investments she made in stocks.

What is the title of the famous series of books about computer programming written by Donald Ervin Knuth?

  1. The Elements of Computer Programming
  2. Computer Science - An Interdisciplinary Approach
  3. The Science of Computer Programming
  4. The Art of Computer Programming
  5. Things a Computer Scientist Rarely Talks About
  6. none of the above











Coding Exercise

In the space below, write a Java program. The program must meet the following requirements.

  1. It must be possible to successfully compile and execute the program when the source code is saved in a file named CodingExercise.java.
  2. When executed using the command java CodingExercise Adam, the program must output the text
    Welcome, Adam!
  3. When executed using the command java CodingExercise Eve, the program must output the text
    Welcome, Eve!

You are strongly encouraged to practice writing your program on another piece of paper. When you are satisfied with your work, neatly copy it into the space below. Correctness, neatness, style, clarity, and simplicity are examples of important factors that will be considered when your work is subjectively evaluated.