Enumerated types have this method, which returns the position of an enum constant in the declaration list. a. location |
c. ordinal |
An object’s ________ is simply the data that is stored in the object’s fields at any given moment. a. assessment |
c. state |
A static field is created by placing: a. the key word static after the field name |
b. the key word static after the access specifier and before the field’s data type |
CRC stands for: a. Class, Redundancy, Collections |
d. Class, Responsibilities, Collaborations |
The term for the relationship created by object aggregation is: a. is a |
c. has a |
Java automatically stores this value in all uninitialized static member variables: a. false |
d. 0 |
When a reference variable is passed as an argument to a method: a. the method becomes a static method |
d. the method has access to the object that the variable references |
If the following is from the method section of a UML diagram, which of the following statements is TRUE? + add(object2:Stock): Stock a. This is a private method named add that accepts and returns objects of the Stock class. |
c. This is a public method named add that accepts and returns references to objects in the Stock class. |
To compare two objects in a class: a. use the == operator, e.g. object1 == object2 |
b. write an equals method that will make a field by field compare of the two objects |
If object1 and object2 are objects of the same class, to make object2 a copy of object1: a. use the default constructor to create object2 with object1 data members |
b. write a copy method that will make a field by field copy of object1 data members into object2 data members |
Assuming the following declaration exists: enum Tree { OAK, MAPLE, PINE } What will the following code display? System.out.println(Tree.OAK); a. Tree.OAK |
d. OAK |
A deep copy of an object: a. is an operation that copies an aggregate object, and all the objects it references |
a. is an operation that copies an aggregate object, and all the objects it references |
Assume the class BankAccount has been created, and the following statement correctly creates an instance of the class: BankAccount account = new BankAccount(5000.0); What is TRUE about the following statement? System.out.println(account); a. The account object’s toString method will be implicitly called. |
a. The account object’s toString method will be implicitly called. |
A declaration for an enumerated type begins with this key word. a. enumerated |
c. enum |
Static methods can only operate on ________ fields. a. local |
c. static |
If you have defined a class named SavingsAccount with a public static data member named numberOfAccounts, and created a SavingsAccount object referenced by the variable account20, which of the following will assign numberOfAccounts to numAccounts? a. numAccounts = account20.numAccounts; |
c. numAccounts = SavingsAccount.numberOfAccounts; |
If the this variable is used to call a constructor: a. a compiler error will result, if it is not the first statement of the constructor |
a. a compiler error will result, if it is not the first statement of the constructor |
If you have defined a class SavingsAccount with a public static method getNumberOfAccounts(), and created a SavingsAccount object referenced by the variable account20, which of the following will call the getNumberOfAccounts()method? a. getNumberOfAccounts(); |
b. SavingsAccount.getNumberOfAccounts(); |
Look at the following declaration: enum Tree { OAK, MAPLE, PINE } What is the fully-qualified name of the PINE enum constant? a. enum.PINE |
d. Tree.PINE |
The only limitation that static methods have is: a. they can refer to only non-static members of the class |
d. they cannot refer to non-static members of the class |
If you attempt to perform an operation with a null reference variable: a. the program will terminate |
a. the program will terminate |
In Java, it is possible to write a method that will return: a. a whole number |
e. All of these |
If the following is from the method section of a UML diagram, which of the following statements is TRUE? + equals(object2:Stock) : boolean a. This is a private method that returns a boolean value. |
b. This is a public method that accepts a Stock object as its argument and returns a boolean value. |
The whole-part relationship created by object aggregation is more often called: a. an inner class relationship |
c. a has a relationship |
The JVM periodically performs this process to remove unreferenced objects from memory. a. garbage collection |
a. garbage collection |
When a field is declared static, there will be: a. only two copies of the field in memory |
b. only one copy of the field in memory |
When the this variable is used to call a constructor: a. it must be the first statement in the constructor making the call |
a. it must be the first statement in the constructor making the call |
When a method’s return type is a class, what is actually returned to the calling program? a. An object of that class |
b. A reference to an object of that class |
Look at the following declaration: enum Tree { OAK, MAPLE, PINE } What is the ordinal value of the MAPLE enum constant? a. 0 |
b. 1 |
What will be returned from a method, if the following is the method header? public Rectangle getRectangle() a. The address of an object of the class Rectangle |
a. The address of an object of the class Rectangle |
Java Ch. 8 Quiz
Share This
Unfinished tasks keep piling up?
Let us complete them for you. Quickly and professionally.
Check Price