Deck 8: A Second Look at Classes and Objects

ملء الشاشة (f)
exit full mode
سؤال
When an object reference is passed to a method, the method may change the values in the object.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
An instance of a class does not have to exist in order for values to be stored in a class's static fields.
سؤال
__________ is the term for the relationship created by object aggregation.

A) "Has a"
B) Inner class
C) "Is a"
D) One-to-many
سؤال
Static methods can only operate on __________ fields.

A) instance
B) static
C) global
D) local
سؤال
An enumerated data type is actually a special type of class.
سؤال
The key word this is the name of a reference variable that an object can use to refer to itself.
سؤال
If you write a toString method for a class, Java will automatically call the method any time you concatenate an object of the class with a string.
سؤال
If a class has a method named finalize, it is called automatically just before a data member that has been identified as final of the class is destroyed by the garbage collector.
سؤال
enum constants have a toString method.
سؤال
If a class has a method named finalize, it is called automatically just before an instance of the class is destroyed by the garbage collector.
سؤال
A single copy of a class's static field is shared by all instances of the class.
سؤال
A class's static methods do not operate on the fields that belong to any instance of the class.
سؤال
The only limitation that static methods have is __________.

A) they must be declared outside of the class
B) they cannot refer to nonstatic members of the class
C) they can only be called from static members of the class
D) they can refer only to nonstatic members of the class
سؤال
Both instance fields and instance methods are associated with a specific instance of a class, and they cannot be used until an instance of the class is created.
سؤال
The key word this is the name of a reference variable that is available to all static methods.
سؤال
The names of the enum constants in an enumerated data type must be enclosed in quotation marks.
سؤال
You can declare an enumerated data type inside a method.
سؤال
A class that is defined inside another class is called a(n) __________.

A) nested class
B) enumerated class
C) inner class
D) helper class
سؤال
When an object is passed as an argument, it is actually a reference to the object that is passed.
سؤال
If you write a toString method to display the contents of an object, object1, for a class, Class1, then the following two statements are equivalent:
System.out.println(object1);
System.out.println(object1.toString());
سؤال
Java automatically stores a __________ value in all uninitialized static member variables.

A) 0
B) -1
C) null
D) false
سؤال
In Java it is possible to write a method that will return __________.

A) a whole number
B) a reference to an object
C) a string of characters
D) Any of these
سؤال
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
C) the values in the object that the method accessed
D) nothing - the return type is simply for documentation in this situation
سؤال
Enumerated types have the __________ method which returns the position of an enum constant in the declaration list.

A) position
B) location
C) ordinal
D) index
سؤال
You cannot use the == operator to compare the contents of __________.

A) objects
B) strings
C) integers
D) Boolean values
سؤال
The whole-part relationship created by object aggregation is more often called a(n) __________ relationship.

A) "has a"
B) inner class
C) extra class
D) inside class
سؤال
CRC stands for __________.

A) Class, Recyclability, Collaborations
B) Class, Redundancy, Collections
C) Class, Responsibilities, Collaborations
D) Code, Reuse, Constancy
سؤال
When the this variable is used to call a constructor__________.

A) it must be the first statement in the constructor making the call
B) it can be anywhere in the constructor making the call
C) it must be the last statement in the constructor making the call
D) None of these. You cannot use the this variable in a constructor call.
سؤال
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) Any of these
سؤال
When you make a copy of the aggregate object and of the objects that it references, __________.

A) you are performing a shallow copy
B) you are performing a nested copy
C) you are performing a deep copy
D) a compiler error will occur
سؤال
When a field is declared static there will be __________.

A) a copy of the field for each method in the class
B) a copy of the field in each class object
C) only one copy of the field in memory
D) two reference copies of the field for each method in the class
سؤال
A declaration for an enumerated type begins with the __________ key word.

A) enumerated
B) enum type
C) ENUM
D) enum
سؤال
A deep copy of an object __________.

A) is an assignment of that object to another object
B) is an operation that copies an aggregate object and all the objects that it references
C) is a bogus term and means nothing
D) is always a private method
سؤال
The "has a" relationship is sometimes called a(n) __________ because one object is part of a greater whole.

A) enterprise
B) possession
C) mutual relationship
D) whole-part relationship
سؤال
When a reference variable is passed as an argument to a method __________.

A) a copy of the variable's value is passed into the method's parameter
B) the method has access to the object that the variable references
C) the method becomes a static method
D) the program terminates
سؤال
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
B) a compiler error will result if it is the first statement of the constructor
C) nothing will happen
D) the this variable cannot be used as a constructor call
سؤال
The JVM periodically performs the __________ process to remove unreferenced objects from memory.

A) memory shuffling
B) system restore
C) garbage collection
D) memory sweeping
سؤال
An object's __________ is simply the data that is stored in the object's fields at any given moment.

A) value
B) assessment
C) record
D) state
سؤال
A static field is created by placing the key word static __________.

A) after the access specifier and the field's data type
B) after the access specifier and before the field's data type
C) after the field name
D) in brackets, before the field's data type
سؤال
Which of the following is not true about static methods?

A) It is not necessary for an instance of the class to be created to execute a static method.
B) They are called by placing the key word static after the access specifier in the method header.
C) They are called from an instance of the class.
D) They are often used to create utility classes that perform operations on data but have no need to collect and store data.
سؤال
Given the following method header, what will be returned from the method? public Rectangle getRectangle()

A) the address of an object of the Rectangle class
B) the values stored in the data members of the Rectangle object
C) a graph of a rectangle
D) an object of the class Rectangle
سؤال
If the following is from the method section of a UML diagram, which of the statements below is true? + add(object2:Stock) : Stock

A) This is a private method named add that accepts and returns objects of the Stock class.
B) This is a private method named Stock that adds two objects.
C) This is a public method named add that accepts and returns references to objects in the Stock class.
D) This is a public method named Stock that adds two objects.
سؤال
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) account20.getNumberOfAccounts();
B) SavingsAccount.getNumberOfAccounts();
C) getNumberOfAccounts();
D) SavingsAccount.account20.getNumberOfAccounts();
سؤال
Which of the following is not true about static methods?

A) They are created by placing the key word static after the access specifier in the method header.
B) It is necessary for an instance of the class to be created to execute the method.
C) They are called directly from the class.
D) They are often used to create utility classes that perform operations on data but have no need to store and collect data.
سؤال
If you have defined a class, 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;
B) numAccounts = numOfAccounts;
C) numAccounts = SavingsAccount.numberOfAccounts;
D) numAccounts = account20;
سؤال
Assume the class BankAccount has been created and the following statement correctly creates an instance of the class. BankAccount account = new BankAccount(5000.00);
What is true about the following statement?
System.out.println(account);

A) A runtime error will occur.
B) The method will display unreadable binary data on the screen.
C) The account object's toString method will be implicitly called.
D) A compiler error will occur.
سؤال
Given the following declaration: enum Tree ( OAK, MAPLE, PINE )
What is the ordinal value of the MAPLE enum constant?

A) 0
B) 1
C) 2
D) 3
سؤال
Given the following declaration: enum Tree ( OAK, MAPLE, PINE )
What is the fully-qualified name of the PINE enum constant?

A) enum.PINE
B) PINE
C) Tree.PINE
D) enum.Tree.PINE
سؤال
If you attempt to perform an operation with a null reference variable __________.

A) the resulting operation will always be zero
B) the results will be unpredictable
C) the program will terminate
D) Java will create an object to reference the variable
سؤال
If the following is from the method section of a UML diagram, which of the statements below is true?
+ equals(object2:Stock) : boolean

A) This is a public method that accepts a Stock object as its argument and returns a boolean value.
B) This is a public method that returns a reference to a String object.
C) This is a private method that receives two objects from the Stock class and returns a boolean value.
D) This is a private method that returns a boolean value.
سؤال
To compare two objects in a class, __________.

A) use the == operator (for example, object1 == object2)
B) write a method to do a byte-by-byte compare of the two objects
C) write an equals method that will make a field by field compare of the two objects
D) This cannot be done since objects consist of several fields.
سؤال
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 the copy method that is a part of the Java language
C) use the default constructor to create object2 with object1 data members
D) use an assignment statement to make object2 a copy of object1
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/52
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 8: A Second Look at Classes and Objects
1
When an object reference is passed to a method, the method may change the values in the object.
True
2
An instance of a class does not have to exist in order for values to be stored in a class's static fields.
True
3
__________ is the term for the relationship created by object aggregation.

A) "Has a"
B) Inner class
C) "Is a"
D) One-to-many
A
4
Static methods can only operate on __________ fields.

A) instance
B) static
C) global
D) local
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
5
An enumerated data type is actually a special type of class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
6
The key word this is the name of a reference variable that an object can use to refer to itself.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
7
If you write a toString method for a class, Java will automatically call the method any time you concatenate an object of the class with a string.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
8
If a class has a method named finalize, it is called automatically just before a data member that has been identified as final of the class is destroyed by the garbage collector.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
9
enum constants have a toString method.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
10
If a class has a method named finalize, it is called automatically just before an instance of the class is destroyed by the garbage collector.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
11
A single copy of a class's static field is shared by all instances of the class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
12
A class's static methods do not operate on the fields that belong to any instance of the class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
13
The only limitation that static methods have is __________.

A) they must be declared outside of the class
B) they cannot refer to nonstatic members of the class
C) they can only be called from static members of the class
D) they can refer only to nonstatic members of the class
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
14
Both instance fields and instance methods are associated with a specific instance of a class, and they cannot be used until an instance of the class is created.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
15
The key word this is the name of a reference variable that is available to all static methods.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
16
The names of the enum constants in an enumerated data type must be enclosed in quotation marks.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
17
You can declare an enumerated data type inside a method.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
18
A class that is defined inside another class is called a(n) __________.

A) nested class
B) enumerated class
C) inner class
D) helper class
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
19
When an object is passed as an argument, it is actually a reference to the object that is passed.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
20
If you write a toString method to display the contents of an object, object1, for a class, Class1, then the following two statements are equivalent:
System.out.println(object1);
System.out.println(object1.toString());
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
21
Java automatically stores a __________ value in all uninitialized static member variables.

A) 0
B) -1
C) null
D) false
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
22
In Java it is possible to write a method that will return __________.

A) a whole number
B) a reference to an object
C) a string of characters
D) Any of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
23
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
C) the values in the object that the method accessed
D) nothing - the return type is simply for documentation in this situation
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
24
Enumerated types have the __________ method which returns the position of an enum constant in the declaration list.

A) position
B) location
C) ordinal
D) index
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
25
You cannot use the == operator to compare the contents of __________.

A) objects
B) strings
C) integers
D) Boolean values
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
26
The whole-part relationship created by object aggregation is more often called a(n) __________ relationship.

A) "has a"
B) inner class
C) extra class
D) inside class
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
27
CRC stands for __________.

A) Class, Recyclability, Collaborations
B) Class, Redundancy, Collections
C) Class, Responsibilities, Collaborations
D) Code, Reuse, Constancy
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
28
When the this variable is used to call a constructor__________.

A) it must be the first statement in the constructor making the call
B) it can be anywhere in the constructor making the call
C) it must be the last statement in the constructor making the call
D) None of these. You cannot use the this variable in a constructor call.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
29
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) Any of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
30
When you make a copy of the aggregate object and of the objects that it references, __________.

A) you are performing a shallow copy
B) you are performing a nested copy
C) you are performing a deep copy
D) a compiler error will occur
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
31
When a field is declared static there will be __________.

A) a copy of the field for each method in the class
B) a copy of the field in each class object
C) only one copy of the field in memory
D) two reference copies of the field for each method in the class
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
32
A declaration for an enumerated type begins with the __________ key word.

A) enumerated
B) enum type
C) ENUM
D) enum
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
33
A deep copy of an object __________.

A) is an assignment of that object to another object
B) is an operation that copies an aggregate object and all the objects that it references
C) is a bogus term and means nothing
D) is always a private method
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
34
The "has a" relationship is sometimes called a(n) __________ because one object is part of a greater whole.

A) enterprise
B) possession
C) mutual relationship
D) whole-part relationship
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
35
When a reference variable is passed as an argument to a method __________.

A) a copy of the variable's value is passed into the method's parameter
B) the method has access to the object that the variable references
C) the method becomes a static method
D) the program terminates
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
36
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
B) a compiler error will result if it is the first statement of the constructor
C) nothing will happen
D) the this variable cannot be used as a constructor call
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
37
The JVM periodically performs the __________ process to remove unreferenced objects from memory.

A) memory shuffling
B) system restore
C) garbage collection
D) memory sweeping
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
38
An object's __________ is simply the data that is stored in the object's fields at any given moment.

A) value
B) assessment
C) record
D) state
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
39
A static field is created by placing the key word static __________.

A) after the access specifier and the field's data type
B) after the access specifier and before the field's data type
C) after the field name
D) in brackets, before the field's data type
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
40
Which of the following is not true about static methods?

A) It is not necessary for an instance of the class to be created to execute a static method.
B) They are called by placing the key word static after the access specifier in the method header.
C) They are called from an instance of the class.
D) They are often used to create utility classes that perform operations on data but have no need to collect and store data.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
41
Given the following method header, what will be returned from the method? public Rectangle getRectangle()

A) the address of an object of the Rectangle class
B) the values stored in the data members of the Rectangle object
C) a graph of a rectangle
D) an object of the class Rectangle
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
42
If the following is from the method section of a UML diagram, which of the statements below is true? + add(object2:Stock) : Stock

A) This is a private method named add that accepts and returns objects of the Stock class.
B) This is a private method named Stock that adds two objects.
C) This is a public method named add that accepts and returns references to objects in the Stock class.
D) This is a public method named Stock that adds two objects.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
43
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) account20.getNumberOfAccounts();
B) SavingsAccount.getNumberOfAccounts();
C) getNumberOfAccounts();
D) SavingsAccount.account20.getNumberOfAccounts();
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
44
Which of the following is not true about static methods?

A) They are created by placing the key word static after the access specifier in the method header.
B) It is necessary for an instance of the class to be created to execute the method.
C) They are called directly from the class.
D) They are often used to create utility classes that perform operations on data but have no need to store and collect data.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
45
If you have defined a class, 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;
B) numAccounts = numOfAccounts;
C) numAccounts = SavingsAccount.numberOfAccounts;
D) numAccounts = account20;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
46
Assume the class BankAccount has been created and the following statement correctly creates an instance of the class. BankAccount account = new BankAccount(5000.00);
What is true about the following statement?
System.out.println(account);

A) A runtime error will occur.
B) The method will display unreadable binary data on the screen.
C) The account object's toString method will be implicitly called.
D) A compiler error will occur.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
47
Given the following declaration: enum Tree ( OAK, MAPLE, PINE )
What is the ordinal value of the MAPLE enum constant?

A) 0
B) 1
C) 2
D) 3
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
48
Given the following declaration: enum Tree ( OAK, MAPLE, PINE )
What is the fully-qualified name of the PINE enum constant?

A) enum.PINE
B) PINE
C) Tree.PINE
D) enum.Tree.PINE
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
49
If you attempt to perform an operation with a null reference variable __________.

A) the resulting operation will always be zero
B) the results will be unpredictable
C) the program will terminate
D) Java will create an object to reference the variable
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
50
If the following is from the method section of a UML diagram, which of the statements below is true?
+ equals(object2:Stock) : boolean

A) This is a public method that accepts a Stock object as its argument and returns a boolean value.
B) This is a public method that returns a reference to a String object.
C) This is a private method that receives two objects from the Stock class and returns a boolean value.
D) This is a private method that returns a boolean value.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
51
To compare two objects in a class, __________.

A) use the == operator (for example, object1 == object2)
B) write a method to do a byte-by-byte compare of the two objects
C) write an equals method that will make a field by field compare of the two objects
D) This cannot be done since objects consist of several fields.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
52
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 the copy method that is a part of the Java language
C) use the default constructor to create object2 with object1 data members
D) use an assignment statement to make object2 a copy of object1
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 52 في هذه المجموعة.