CIS 234 Final Study Guide (All Quizzes #1-4 Q's)
A common extension for plain text files is:
.txt
Which of the following is a symbol for a single line comment in Java?
//
AWT stands for which of the following:
Abstract Windows Toolkit
What is the name of the class that contains the following code: public Clock (Date date, Mode mode) { }
Clock
Attempting to write a file that does not exist will:
Create the file
The following questions apply to the code fragment shown below: //Return a greeting depending upon //the time of day. String greetings(Date date){ int hour = date.getHours(); String message = ""; if (hour < 12) { message = "Good morning"; else { if (hour < 18) { message = "Good afternoon"; else { message = "Good evening"; return message; } What type of argument(s) are provided?
Date
Which class is used to connect a buffered reader to a file?
FileReader
Which object is used to write text to a text file?
FileWriter
The following questions apply to the code fragment shown below: //Return a greeting depending upon //the time of day. String greetings(Date date){ int hour = date.getHours(); String message = ""; if (hour < 12) { message = "Good morning"; else { if (hour < 18) { message = "Good afternoon"; else { message = "Good evening"; return message; } What value is returned when hour is 12?
Good afternoon
Which of the following exceptions is likely to be thrown when reading a file?
IOException
The following questions apply to the code fragment shown below: //Return a greeting depending upon //the time of day. String greetings(Date date){ int hour = date.getHours(); String message = ""; if (hour < 12) { message = "Good morning"; else { if (hour < 18) { message = "Good afternoon"; else { message = "Good evening"; return message; } What type of method is shown?
Instance
Which is NOT a basic control structure?
Modification
The following questions apply to the code fragment shown below: //Return a greeting depending upon //the time of day. String greetings(Date date){ int hour = date.getHours(); String message = ""; if (hour < 12) { message = "Good morning"; else { if (hour < 18) { message = "Good afternoon"; else { message = "Good evening"; return message; } Which of the following represent constants?
None
The priority among the following operators, from first to last, is:
Not, And, Or
The following questions apply to the code fragment shown below: //Return a greeting depending upon //the time of day. String greetings(Date date){ int hour = date.getHours(); String message = ""; if (hour < 12) { message = "Good morning"; else { if (hour < 18) { message = "Good afternoon"; else { message = "Good evening"; return message; } What is the name of the method?
String
The following questions apply to the code fragment shown below: //Return a greeting depending upon //the time of day. String greetings(Date date){ int hour = date.getHours(); String message = ""; if (hour < 12) { message = "Good morning"; else { if (hour < 18) { message = "Good afternoon"; else { message = "Good evening"; return message; } What type of value is returned?
String
By default, attempting to write an existing text file will cause:
The existing content to be overwritted
Block scope means that a variable:
can't be used outside of the set of braces that it's declared in
A template that defines the methods and characteristics to included in a particular type of object is a(n):
class
Which method flushes any remaining data from the buffer and closes the stream?
close()
Assuming Agent is a parent class and SecretAgent is its child, what is the result of the following statement? Agent employee = new SecretAgent();
compiles normally
The default startup method for a class is known as its:
constructor
The following questions apply to the code fragment shown below: //Return a greeting depending upon //the time of day. String greetings(Date date){ int hour = date.getHours(); String message = ""; if (hour < 12) { message = "Good morning"; else { if (hour < 18) { message = "Good afternoon"; else { message = "Good evening"; return message; } What are the arguments for this method?
date
The following questions apply to the code fragment shown below: //Return a greeting depending upon //the time of day. String greetings(Date date){ int hour = date.getHours(); String message = ""; if (hour < 12) { message = "Good morning"; else { if (hour < 18) { message = "Good afternoon"; else { message = "Good evening"; return message; } Which of the following represent local variables?
date, hour, message
Which structure is an example of a Test Before?
do while
Which keyword is used in a class declaration to create a subclass?
extends
You can use a Scanner object to:
get the next token in an input line
The following questions apply to the code fragment shown below: //Return a greeting depending upon //the time of day. String greetings(Date date){ int hour = date.getHours(); String message = ""; if (hour < 12) { message = "Good morning"; else { if (hour < 18) { message = "Good afternoon"; else { message = "Good evening"; return message; } Which of the following represent instance variables?
greetings
The following questions apply to the code fragment shown below: //Return a greeting depending upon //the time of day. String greetings(Date date){ int hour = date.getHours(); String message = ""; if (hour < 12) { message = "Good morning"; else { if (hour < 18) { message = "Good afternoon"; else { message = "Good evening"; return message; } What is the signature for this method?
greetings (Date date)
Another name for an object that belongs to a particular class is a(n):
instance
Which method verifies that a file exists before reading its content?
isFile()
A block of code that perform a particular task is called a(n):
method
Which of the following statements would create a File object to read the c:\files\data.txt file?
new File("c:/files/data.tx");
packageExtending a parent class and then including a new version of its methods in the child class is:
overriding
Which is the default visibility when none is stated?
package
Groups of related classes are organized into:
packages
Which method is used to read a line of text from a buffered reader?
readLine()
Which keyword is used to refer to a parent class?
super
Which Java keyword refers to the current object?
this
Which operator returns true if either expressions is true?
|