AND ANSWERS
When the this variable is used to call a constructor
A) it must be the first statement in the constructor making the call.
B) You cannot use the variable in a constructor call.
C) it can be anywhere in the constructor making the call.
D) it must be the last statement in the constructor making the call. - Answer- A
You can declare an enumerated data type inside of a method.
T/F - Answer- False
By default, a reference variable that is an instance field is initialized to the value
A) void.
B) null.
C) static.
D) 0. - Answer- B
You cannot use the fully-qualified name of an enum constant for
A)
a case expression.
B)
an argument to a method.
C)
a boolean expression.
D)
,All of these - Answer- A
A class that is defined inside of another class is called a(n)
A) enumerated class.
B) inner class.
C) nested class.
D) helper class. - Answer- B
A declaration for an enumerated type begins with this key word.
A) ENUM
B) enum type
C) enum
D) enumerated - Answer- C
When a method in the ________ class returns a reference to a field object, it should
return a reference to a copy of the field object to prevent "security holes."
A) nested
B) inner
C) String
D) aggregate - Answer- D
If object1 and object2 are objects of the same class, to make object2 a copy of object1
A) write a method for the class that will make a field by field copy of object1 data
members into object2 data members.
B) use an assignment statement to make object2 a copy of object1.
C) use the default constructor to create object2 with object1 data members.
D) use the copy method that is a part of the Java API. - Answer- A
Overloading is
,A) writing a program that is too large to fit in memory.
B) having two or more methods with the same name, but different signatures.
C) having two or more methods with the same signature.
D) writing a method that does too much processing. - Answer- B
An instance of a class does not have to exist in order for values to be stored in a class's
static fields.
T/F - Answer- True
The only limitation that static methods have is
A) they cannot refer to nonstatic members of the class.
B) they must be declared outside of the class.
C) they can refer to only nonstatic members of the class.
D) they can only be called from static members of the class. - Answer- A
The names of the enum constants in an enumerated data type must be enclosed in
quotation marks.
T/F - Answer- False
Of the following, which would be considered the no-arg constructor for the Rectangle
class?
A) public Rectangle(int len, int width)
B) public Rectangle(double len, double width)
C) public Rectangle()
D) All of these - Answer- C
When an object is passed as an argument, it is actually a reference to the object that is
passed.
T/F - Answer- True
When you write an enumerated type declaration, you
, A) are actually creating a special kind of class.
B) do not enclose the enum constants in quotation marks.
C) should use the standard convention of writing the enum constants in uppercase.
D) All of these - Answer- D
When you make a copy of the aggregate object and of the objects it references,
A) a compiler error will occur.
B) you are performing a nested copy.
C) you are performing a deep copy.
D) you are performing a shallow copy. - Answer- C
This is a special language used to write computer programs. - Answer- programming
language
The contents of a variable cannot be changed while the program is running.
T/F - Answer- False
When an object's internal data is hidden from outside code and access to that data is
restricted to the object's methods, the data is protected from accidental corruption.
T/F - Answer- True
A characteristic of ________ is that only an object's methods are able to directly access
and make the changes to the object's data - Answer- data hiding
The Java Virtual Machine is a program that reads Java byte code instructions and
executes them as they are read
T/F - Answer- True
The original name for Java was - Answer- Oak
Which of the following commands will compile a program named ReadIt? - Answer-
javac ReadIt.java