Name:     ID: 
 
Email: 

Test2

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

 1. 

Semantics consists of the rules for combining words into statements.
 

 2. 

When compared to natural languages, programming languages have large vocabularies.
 

 3. 

To manipulate an object in Java a programmer will send the object a message.
 

 4. 

Primitive data types must be instantiated before being used.
 

 5. 

Both the value of a variable and the type of data it contains can change during execution of a program.
 

 6. 

It is illegal to declare several variables in a single declaration, i.e. int a, b, c;
 

 7. 

The division statement of  10/4 will be evaluated to 2.
 

 8. 

User defined symbols are case sensitive in Java.
 

 9. 

The purpose of comments in a program is to document every line of code.
 

 10. 

Sending a message to a variable representing an object before it has been instantiated causes a "null pointer exception".
 

 11. 

Inserting debugging output statements into code is a useful way to find syntax errors.
 

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

 12. 

What is the set of all the words and symbols in the Java programming language?
a.
Program
c.
Syntax
b.
Vocabulary
d.
Semantics
 

 13. 

Of the following, which is NOT a difference between natural languages and programming languages?
a.
Size
c.
Literalness
b.
Semantics
d.
Rigidity
 

 14. 

Which of the following is NOT a primitive data type in Java?
a.
integer
c.
boolean
b.
string
d.
character
 

 15. 

How many bytes does the primitive data type double require?
a.
64
c.
4
b.
2
d.
8
 

 16. 

How many numeric data types does Java include?
a.
4
c.
6
b.
2
d.
8
 

 17. 

Which of the following is correct Java for writing exponential, or scientific notation?
a.
3.14
c.
5.124E5
b.
5 x 10 -1
d.
none of the above
 

 18. 

Which keyword in Java declares a variable whose value cannot change?
a.
final
c.
constant
b.
const
d.
new
 

 19. 

Which of the following operators has the highest precedence?
a.
Assignment ( = )
c.
Method Selector ( . )
b.
Unary Plus ( + )
d.
Subtraction ( - )
 

 20. 

The expression 3 + 2 * 5 - 1 yields:
a.
24
c.
11
b.
12
d.
20
 

 21. 

Which of the following mixed-mode arithmetic expressions yields 8.0?
a.
5 / 2 * 4.0
c.
5.0 / 2 * 4
b.
5 / 2.0 * 4
d.
5.0 / 2.0 * 4
 

 22. 

What is the string concatenation operator?
a.
+
c.
-
b.
*
d.
"
 

 23. 

What string results from the expression "1 + 2 = " + 1 + 2
a.
"3 = 3"
c.
"1 + 2 = 12"
b.
"1 + 2 = 3"
d.
"3 = 12"
 

 24. 

Which of the following is the escape sequence for a newline?
a.
\"
c.
\\
b.
\t
d.
\n
 

 25. 

Which String class method returns a string's length?
a.
size()
c.
stringLength()
b.
length()
d.
width()
 

 26. 

What keyword indicates a method does not return a value?
a.
double
c.
void
b.
final
d.
null
 

 27. 

Which of the following user-defined symbols is invalid?
a.
_name
c.
$income
b.
number3
d.
9innings
 

 28. 

In the statement import x.y.z;  what does the x represent?
a.
the name of a class
c.
a variable
b.
a subsection of the package
d.
the name of the overall package
 

 29. 

Which type of error occurs when an instruction tries to divide by 0?
a.
Logic error
c.
Run-time error
b.
Syntax error
d.
No error
 

Completion
Complete each statement.
 

 30. 

_____________ defines the rules for interpreting the meaning of statements.
 

 

 31. 

A _________ is an item whose value can change during the execution of a program.
 

 

 32. 

A programmer can collect a class or group of classes in a ____________.
 

 

 33. 

The KeyboardReader class method ______________ returns the entire input line.
 

 

 34. 

A(n) _________ is a step-by-step procedure for solving a problem.
 

 

 35. 

_________ errors occur when the instruction does not do what was intended.
 

 

Short Answer
 

 36. 

Name four Java primitive data types.
 

 37. 

Give an example of a string literal and a floating point literal.
 

 38. 

Write a variable declaration statement for an integer value with the name employeeNumber
 

 39. 

What does the modulus operator ( % ) yield?
 

 40. 

Casting the floating point number 3.8 to an integer using (int)3.8, yields what value?
 

 41. 

What comprises a methods signature?
 

 42. 

Name the three types of programming errors.
 



 
         Start Over