Name: 
 

Java set 1



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

 1. 

The assignment operator ( = ) can be combined with the arithmetic operators ( +, -, *, / ) to provide extended assignment operators, i.e. +=, -=, *=, /=.
 

 2. 

m++, m=m+1, and m+=1 are all equivalent expressions.
 

 3. 

If a single statement follows an if or else statement the braces are not necessary, i.e.
if( ... )
   statement
else
   statement
 

 4. 

A class can include only one constructor.
 

 5. 

A method can only have one return statement.
 

 6. 

Constructors are methods.
 

 7. 

Constructors can not be overloaded.
 

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

 8. 

The process of creating a new object is called:
a.
encapsulation
c.
instantiation
b.
class
d.
new
 

 9. 

Which characteristic of an object says that at any moment its instance variables have particular values.
a.
state
c.
identity
b.
behavior
d.
instantiation
 

 10. 

What is the name of a method that indicates how to initialize a new object?
a.
initializer
c.
mutator
b.
constructor
d.
accessor
 

 11. 

What are activated when the keyword new is used and at no other time.
a.
accessors
c.
constructors
b.
mutators
d.
methods
 

 12. 

What is the result of the integer expression 9/4?
a.
1
c.
2.25
b.
2
d.
an error will occur
 

 13. 

Which operator has the lowest precedence?
a.
+
c.
*
b.
/
d.
unary -
 

 14. 

Which of the following is an assignment statement?
a.
int number;
c.
34*11
b.
int number = 23;
d.
total = num1 + num2;
 

 15. 

Which Java operator is used to create objects?
a.
new
c.
instantiate
b.
create
d.
obj
 

 16. 

Which of the following is an expression?
a.
count + 1
c.
factor * weight
b.
3 + 7
d.
All of the above
 

 17. 

What must appear to the left of the assignment operator in an assignment expression?
a.
a variable
c.
a literal
b.
an expression
d.
a class
 

 18. 

Which of the following represents a legal declaration?
a.
double width, int height;
c.
double width, height;
b.
double width, double height;
d.
double: width; height;
 

Completion
Complete each statement.
 

 19. 

Constructors with empty parameter lists are called ___________ constructors.
 

 

Short Answer
 

 20. 

What is the concatenation operator?
 

 21. 

Name two visibility modifiers.
 

 22. 

What modifier is used to declare a constant?
 



 
Check Your Work     Start Over