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
- Write your last name in the upper right hand corner of each page of this exam.
- Below your last name, write the name you prefer to be called in class in parentheses.
- For each multiple choice question, circle the letter of the correct answer(s).
- Follow the instructions for the coding exercise that are provided in that section of the exam.
- 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.
Mark Points ++ 26 + 25 ✓+ 24 ✓ 23 ✓- 21 - 19 -- 17 0 0
Please, do your own work. And Don’t Panic!
(This is not the end of the world.)
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?
- a run-time error message
- a compile-time error message
- machine instructions
- portable byte code
- a core dump
- 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?
- Remove the word
public. - Insert the word
staticbefore the wordclass. - Change the class name to
Foobar. - All of the above changes (a, b, and c) are required.
- Any combination of a, b, and c above will work.
- None of the above.
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?
FirstProgram.javaFirstProgram.classFirstProgram.txtFirstProgram.srcFirstProgram.javFirstProgram.css
Which of the following changes could be made to the program above such that it still compiles and executes?
- Change the name of the class from
FirstProgramtoMyFirstProgramand change the name of the file toMyFirstProgram.class. - Change the name of the parameter from
argstoarguments. - Change the name of the method
System.out.printtoSystem.out.println. - Remove the word
static. - Convert all characters to uppercase.
- 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?
- edit, save, execute
- create, execute, run
- create, execute, debug
- compile, debug, execute
- create, compile, execute
- none of the above
The program javac.exe is a what?
- compiler
- interpreter
- class loader
- editor
- IDE
- none of the above
The program java.exe is a what?
- compiler
- interpreter
- class loader
- debugger
- editor
- IDE
The program javac.exe usually produces which type(s) of files?
- .java files
- .js files
- .class files
- .css files
- .html files
- none of the above
The program java.exe usually produces which type(s) of files?
- .java files
- .js files
- .class files
- .css files
- .html files
- none of the above
The program javadoc.exe usually produces which type(s) of files?
- .java files
- .js files
- .class files
- .css files
- .html files
- 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?
- values and operations
- ones and zeros
- names and values
- operations and methods
- functions and parameters
- none of the above
What are the two possible values of a Java variable that is of type boolean?
- high, low
- one, zero
- 1, 0
- yes, no
- good, bad
- 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)?
- byte
- short
- int
- long
- double
- float
Which of the following are true about Donald Ervin Knuth?
- Knuth’s father was a Catholic school teacher.
- Knuth’s mother worked in real estate in New York City.
- When Knuth was in high school, about half of his classmates went on to college.
- Knuth’s family didn’t have a car until he was in the seventh grade.
- Knuth’s father rode a bicycle to work.
- 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?
- The Elements of Computer Programming
- Computer Science - An Interdisciplinary Approach
- The Science of Computer Programming
- The Art of Computer Programming
- Things a Computer Scientist Rarely Talks About
- none of the above
Coding Exercise
In the space below, write a Java program. The program must meet the following requirements.
- It must be possible to successfully compile and execute the program when the source code is saved in a file named CodingExercise.java.
- When executed using the command
java CodingExercise Adam, the program must output the textWelcome, Adam! - When executed using the command
java CodingExercise Eve, the program must output the textWelcome, 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.