Deck 6: A Second Look at Classes and Objects

ملء الشاشة (f)
exit full mode
سؤال
When an object is passed as an argument, it is actually a reference to the object that is passed.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
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
سؤال
You can declare an enumerated data type inside a method.
سؤال
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 instance of a class does not have to exist in order for values to be stored in a class's static fields.
سؤال
A class's static methods do not operate on the fields that belong to any instance of the class.
سؤال
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
سؤال
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.
سؤال
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.
سؤال
CRC stands for

A) Class, Recyclability, Collaborations
B) Class, Redundancy, Collections
C) Class, Responsibilities, Collaborations
D) Code, Reuse, Constancy
سؤال
enum constants have a toString method.
سؤال
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
سؤال
A method's signature consists of

A) the method name and the parameter list
B) the return type, the method name, and the parameter list
C) the size of the method in memory
D) the return type and the method name
سؤال
__________ is the term for the relationship created by object aggregation.

A) "Has a"
B) Inner class
C) "Is a"
D) One-to-many
سؤال
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
سؤال
An enumerated data type is actually a special type of class.
سؤال
Overloading is

A) writing a method that does too much processing
B) writing a program that is too large to fit in memory
C) having two or more methods with the same name but different signatures
D) having two or more methods with the same signature
سؤال
A class that is defined inside another class is called a(n)

A) nested class
B) enumerated class
C) inner class
D) helper class
سؤال
The key word this is the name of a reference variable that an object can use to refer to itself.
سؤال
The names of the enum constants in an enumerated data type must be enclosed in quotation marks.
سؤال
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) public Rectangle(length, width)
سؤال
When a method's type is an object, what is actually returned by the calling program?

A) a reference to an object of that class
B) only the values in the object that the method accessed
C) an object of that class
D) a null reference
سؤال
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 API
C) use the default constructor to create object2 with object1 data members
D) use an assignment statement to make object2 a copy of object1
سؤال
To get the name of a calling enum constant

A) simply use the enum constant in the statement
B) use the ordinal method
C) use the displayName method
D) use the toString method
سؤال
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();
سؤال
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.
سؤال
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
سؤال
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
سؤال
Which of the following can you use to compare two enum data values?

A) the ordinal method
B) the ==, >, and < operators
C) the equals and compareTo methods
D) the moreThan, lessThan, and equalsTo methods
سؤال
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
سؤال
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) aggregate
B) inner
C) String
D) nested
سؤال
If the following is from the method section of a UML diagram, which of the statements shown 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.
سؤال
A declaration for an enumerated type begins with the __________ key word.

A) enumerated
B) enum type
C) ENUM
D) enum
سؤال
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 null value
D) an object that is contained in the class Rectangle
سؤال
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
سؤال
Assume the following declaration exists: enum Tree ( OAK, MAPLE, PINE )
What will the following code display?
System.out.println(Tree.OAK);

A) OAK
B) Tree.OAK
C) 0
D) 1
سؤال
You can use the enum key word to

A) create your own data type
B) specify the values that belong to the type
C) Both of these
D) Neither of these
سؤال
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 implicity called.
D) A compiler error will occur.
سؤال
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
سؤال
By default, a reference variable that is an instance field is initialized to the value

A) null
B) 0
C) static
D) void
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/40
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 6: A Second Look at Classes and Objects
1
When an object is passed as an argument, it is actually a reference to the object that is passed.
True
2
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
B
3
You can declare an enumerated data type inside a method.
False
4
The JVM periodically performs the __________ process to remove unreferenced objects from memory.

A) memory shuffling
B) system restore
C) garbage collection
D) memory sweeping
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
5
An instance of a class does not have to exist in order for values to be stored in a class's static fields.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
6
A class's static methods do not operate on the fields that belong to any instance of the class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
7
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
8
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
9
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
10
CRC stands for

A) Class, Recyclability, Collaborations
B) Class, Redundancy, Collections
C) Class, Responsibilities, Collaborations
D) Code, Reuse, Constancy
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
11
enum constants have a toString method.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
12
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
13
A method's signature consists of

A) the method name and the parameter list
B) the return type, the method name, and the parameter list
C) the size of the method in memory
D) the return type and the method name
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
14
__________ is the term for the relationship created by object aggregation.

A) "Has a"
B) Inner class
C) "Is a"
D) One-to-many
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
15
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
16
An enumerated data type is actually a special type of class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
17
Overloading is

A) writing a method that does too much processing
B) writing a program that is too large to fit in memory
C) having two or more methods with the same name but different signatures
D) having two or more methods with the same signature
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
19
The key word this is the name of a reference variable that an object can use to refer to itself.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
20
The names of the enum constants in an enumerated data type must be enclosed in quotation marks.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
21
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) public Rectangle(length, width)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
22
When a method's type is an object, what is actually returned by the calling program?

A) a reference to an object of that class
B) only the values in the object that the method accessed
C) an object of that class
D) a null reference
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
23
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 API
C) use the default constructor to create object2 with object1 data members
D) use an assignment statement to make object2 a copy of object1
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
24
To get the name of a calling enum constant

A) simply use the enum constant in the statement
B) use the ordinal method
C) use the displayName method
D) use the toString method
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
25
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();
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
26
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
27
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
28
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
29
Which of the following can you use to compare two enum data values?

A) the ordinal method
B) the ==, >, and < operators
C) the equals and compareTo methods
D) the moreThan, lessThan, and equalsTo methods
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
30
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
31
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) aggregate
B) inner
C) String
D) nested
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
32
If the following is from the method section of a UML diagram, which of the statements shown 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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
33
A declaration for an enumerated type begins with the __________ key word.

A) enumerated
B) enum type
C) ENUM
D) enum
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
34
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 null value
D) an object that is contained in the class Rectangle
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
35
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
36
Assume the following declaration exists: enum Tree ( OAK, MAPLE, PINE )
What will the following code display?
System.out.println(Tree.OAK);

A) OAK
B) Tree.OAK
C) 0
D) 1
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
37
You can use the enum key word to

A) create your own data type
B) specify the values that belong to the type
C) Both of these
D) Neither of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
38
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 implicity called.
D) A compiler error will occur.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
40
By default, a reference variable that is an instance field is initialized to the value

A) null
B) 0
C) static
D) void
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.