Name:     ID: 
 
    Email: 

AP Computer Science Quiz 2

True/False
Indicate whether the sentence or statement is true or false.
 

 1. 

A reference variable can be compared to the null value.
 

 2. 

Method names have the same syntax as other Java identifiers.
 

 3. 

Suppose the Boolean variables P, Q, and R have values of false, true, and false, respectively. The value of the expression P && ( Q || R ) would be true.
 

 4. 

In the expression (p || q), if p is true, then there is no need to evaluate q.
 

 5. 

In a printf statement, a format specifier in the format string and the corresponding expression must match in position and type.
 

 6. 

The String class’s format method takes the same arguments as the printf method.
 

 7. 

In a try-catch statement, all of the code within the try block will always be executed.
 

 8. 

An HTML <P> tag must have a corresponding </P> tag.
 

 9. 

You should use other markup tags within a chunk of preformatted text in an HTML document.
 

 10. 

Applets can access local files on a machine.
 

Multiple Choice
Identify the letter of the choice that best completes the statement or answers the question.
 

 11. 

The combining of data and behavior into a single software package is called ____.
a.
encapsulation
c.
instantiation
b.
invocation
d.
information hiding
 

 12. 

Class definitions usually begin with the keyword ____, indicating that the class is accessible to all potential clients.
a.
accessible
c.
private
b.
public
d.
global
 

 13. 

At the root (base) of Java’s class hierarchy is a class called ____.
a.
Java
c.
Class
b.
Object
d.
Root
 

 14. 

____ variables can be declared in a method to provide temporary working storage for data in the method.
a.
Global
c.
Instance
b.
Local
d.
Internal
 

 15. 

A loop ____ is an assertion that expresses a relationship between variables that remains constant throughout all iterations of the loop.
a.
constant
c.
variant
b.
inconstant
d.
invariant
 

 16. 

Java 5.0 includes the method ____ for formatting output.
a.
print
c.
printf
b.
println
d.
printFormatted
 

 17. 

Format specifier codes begin with the ____ character.
a.
%
c.
$
b.
#
d.
&
 

 18. 

Consider the following code:

   int idNum = 758;
    double wage = 10.5;
    printf(“The wage for employee %d is $%.2f per hour.”,
        idNum, wage);

The output of the printf statement would be ____.
a.
The wage for employee 10.50 is $758 per hour.
b.
The wage for employee 758 is $10.50 per hour.
c.
The wage for employee 758 is $10.5 per hour.
d.
The wage for employee 758.00 is $10 per hour.
 

 19. 

In HTML, ____ are used to indicate the format of textual elements or links to other nodes.
a.
format specifiers
c.
markup tags
b.
format flags
d.
markup specifiers
 

 20. 

Which of the following illustrates the minimal HTML structure for an HTML document?
a.
<HEAD>
<TITLE> the title goes here </TITLE>
</HEAD>
<BODY>
the text for the document goes here
</BODY>
b.
<HTML>
<HEAD>
<TITLE> the title goes here </TITLE>
</HEAD>
</HTML>
c.
<HTML>
<HEAD>
<TITLE> the title goes here </TITLE>
</HEAD>
<BODY>
the text for the document goes here
</BODY>
</HTML>
d.
<HTML>
<BODY>
the text for the document goes here
</BODY>
</HTML>
 

 21. 

In HTML, the escape sequence for an ampersand (&) is ____.
a.
&&
c.
&amp
b.
&amp;
d.
&&;
 

 22. 

There are ____ types of lists that can be displayed in an HTML page.
a.
2
c.
4
b.
3
d.
5
 

 23. 

The HTML markup tag for a link is ____.
a.
<LINK>
c.
<ANCHOR>
b.
<A>
d.
<L>
 

 24. 

A(n) ____ path name specifies the exact position of a file in the computer’s directory structure.
a.
absolute
c.
final
b.
relative
d.
complete
 

 25. 

The JApplet method ____ can be used to locate and return the URL of the applet’s Web server.
a.
getServer()
c.
getURL()
b.
getDocumentBase()
d.
getHost()
 



 
Submit          Reset Help