Deck 8: A Second Look at Classes and Objects
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/50
العب
ملء الشاشة (f)
Deck 8: A Second Look at Classes and Objects
1
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
C) the key word static after the access specifier and field's data type
D) it in a static field block
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
C) the key word static after the access specifier and field's data type
D) it in a static field block
B
2
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 will terminate
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 will terminate
B
3
Which of the following is NOT true about static methods?
A) It is necessary for an instance of the class to be created to execute the method.
B) They are created by placing the key word static after the access specifier in the method header.
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 collect and store data.
A) It is necessary for an instance of the class to be created to execute the method.
B) They are created by placing the key word static after the access specifier in the method header.
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 collect and store data.
A
4
The term for the relationship created by object aggregation is:
A) has a
B) is a
C) Sub-class object
D) Inner class
A) has a
B) is a
C) Sub-class object
D) Inner class
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
5
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
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
6
If object1 and object2 are objects of the same class, to make object2 a copy of object1:
A) assign object1 to object2, such as object2 = object1;
B) write a copy method that will make a field by field copy of object1 data members into object2 data members
C) use the Java copy method that is a part of the Java language
D) use the default constructor to create object2 with object1 data members
A) assign object1 to object2, such as object2 = object1;
B) write a copy method that will make a field by field copy of object1 data members into object2 data members
C) use the Java copy method that is a part of the Java language
D) use the default constructor to create object2 with object1 data members
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
7
In Java, it is possible to write a method that will return:
A) a whole number
B) a monetary value
C) a string of characters
D) a reference to an object
E) All of the above
A) a whole number
B) a monetary value
C) a string of characters
D) a reference to an object
E) All of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
8
You cannot use the == operator to compare the contents of:
A) objects
B) strings
C) integers
D) Boolean values
A) objects
B) strings
C) integers
D) Boolean values
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
9
When a field is declared static, there will be:
A) a copy of the field in each class object
B) only one copy of the field in memory
C) a copy of the field for each static method in the class
D) only two copies of the field in memory
A) a copy of the field in each class object
B) only one copy of the field in memory
C) a copy of the field for each static method in the class
D) only two copies of the field in memory
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
10
Java automatically stores this value in all uninitialized static member variables:
A) 0
B) -1
C) null
D) False
A) 0
B) -1
C) null
D) False
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
11
To compare two objects in a class:
A) use the == operator, e.g. 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) Since objects consist of several fields, you cannot compare them
A) use the == operator, e.g. 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) Since objects consist of several fields, you cannot compare them
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
12
Static methods can only operate on ________ fields.
A) instance
B) static
C) global
D) local
A) instance
B) static
C) global
D) local
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
13
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 receives two objects from the Stock class and returns a boolean value.
B) This is a public method that accepts a Stock object as its argument and returns a boolean value.
C) This is a private method that returns a boolean value.
D) This is a public method that returns a Stock object.
+ equals(object2:Stock) : boolean
A) This is a private method that receives two objects from the Stock class and returns a boolean value.
B) This is a public method that accepts a Stock object as its argument and returns a boolean value.
C) This is a private method that returns a boolean value.
D) This is a public method that returns a Stock object.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
14
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) Only the values in the object that the method accessed
D) Nothing, the return type is strictly for documentation in this situation.
A) An object of that class
B) A reference to an object of that class
C) Only the values in the object that the method accessed
D) Nothing, the return type is strictly for documentation in this situation.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
15
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) value
B) assessment
C) record
D) state
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
16
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 the method.
B) They are created 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.
A) It is not necessary for an instance of the class to be created to execute the method.
B) They are created 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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
17
The only limitation that static methods have is:
A) they can refer to only non-static members of the class
B) they can only be called from static members of the class
C) they must be declared as public methods
D) they cannot refer to non-static members of the class
A) they can refer to only non-static members of the class
B) they can only be called from static members of the class
C) they must be declared as public methods
D) they cannot refer to non-static members of the class
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
18
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();
C) getNumberOfAccounts(account20);
D) None of the above, you cannot call a static method.
A) getNumberOfAccounts();
B) SavingsAccount.getNumberOfAccounts();
C) getNumberOfAccounts(account20);
D) None of the above, you cannot call a static method.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
19
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 it references
C) is a bogus term, it has no meaning
D) is always a private method
A) is an assignment of that object to another object
B) is an operation that copies an aggregate object, and all the objects it references
C) is a bogus term, it has no meaning
D) is always a private method
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
20
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;
B) numAccounts = numberOfAccounts;
C) numAccounts = SavingsAccount.numberOfAccounts;
D) None of the above, you cannot reference a static data member.
A) numAccounts = account20.numAccounts;
B) numAccounts = numberOfAccounts;
C) numAccounts = SavingsAccount.numberOfAccounts;
D) None of the above, you cannot reference a static data member.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
21
An instance of a class does not have to exist in order for values to be stored in a class's static fields.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
22
The whole-part relationship created by object aggregation is more often called:
A) a has a relationship
B) an inner class relationship
C) an extra class relationship
D) an inside class relationship
A) a has a relationship
B) an inner class relationship
C) an extra class relationship
D) an inside class relationship
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
23
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());
System.out.println(object1);
System.out.println(object1.toString());
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
24
A single copy of a class's static field is shared by all instances of the class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
25
Look at 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
E) Tree.MAPLE
What is the ordinal value of the MAPLE enum constant?
A) 0
B) 1
C) 2
D) 3
E) Tree.MAPLE
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
26
Enumerated types have this method, which returns the position of an enum constant in the declaration list.
A) toString
B) position
C) ordinal
D) location
A) toString
B) position
C) ordinal
D) location
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
27
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
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
28
A declaration for an enumerated type begins with this key word.
A) enumerated
B) enum_type
C) enum
D) ENUM
A) enumerated
B) enum_type
C) enum
D) ENUM
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
29
The this key word is the name of a reference variable that is available to all static methods.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
30
Assuming the following declaration exists: enum Tree { OAK, MAPLE, PINE }
What will the following code display?
System.out.println(Tree.OAK);
A) Tree.OAK
B) 0
C) 1
D) OAK
E) Nothing. This statement will cause an error.
What will the following code display?
System.out.println(Tree.OAK);
A) Tree.OAK
B) 0
C) 1
D) OAK
E) Nothing. This statement will cause an error.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
31
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
32
When an object is passed as an argument, it is actually a reference to the object that is passed.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
33
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.
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.
+ 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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
34
The JVM periodically performs this process to remove unreferenced objects from memory.
A) memory sweeping
B) garbage collection
C) memory shuffling
D) system restore
A) memory sweeping
B) garbage collection
C) memory shuffling
D) system restore
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
35
Look at the following declaration: enum Tree { OAK, MAPLE, PINE }
What is the fully-qualified name of the PINE enum constant?
A) PINE
B) enum.PINE
C) Tree.PINE
D) Tree(PINE)
E) PINE.Tree
What is the fully-qualified name of the PINE enum constant?
A) PINE
B) enum.PINE
C) Tree.PINE
D) Tree(PINE)
E) PINE.Tree
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
36
You cannot use the fully-qualified name of an enum constant for this.
A) a switch expression
B) an argument to a method
C) a case expression
D) all of these
A) a switch expression
B) an argument to a method
C) a case expression
D) all of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
37
What will be returned from a method, if the following is the method header?
Public Rectangle getRectangle()
A) An object of the class Rectangle
B) The address of an object of the class Rectangle
C) The values stored in the data members of the Rectangle object the method changed
D) A graph of a rectangle
Public Rectangle getRectangle()
A) An object of the class Rectangle
B) The address of an object of the class Rectangle
C) The values stored in the data members of the Rectangle object the method changed
D) A graph of a rectangle
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
38
CRC stands for:
A) Code, Reuse, Constancy
B) Class, Responsibilities, Collaborations
C) Class, Redundancy, Collections
D) Class, Recyclability, Collaborations
A) Code, Reuse, Constancy
B) Class, Responsibilities, Collaborations
C) Class, Redundancy, Collections
D) Class, Recyclability, Collaborations
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
39
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 method will display unreadable binary data on the screen.
B) A compiler error will occur.
C) The account object's toString method will be implicitly called.
D) A runtime error will occur.
What is TRUE about the following statement?
System.out.println(account);
A) The method will display unreadable binary data on the screen.
B) A compiler error will occur.
C) The account object's toString method will be implicitly called.
D) A runtime error will occur.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
40
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 must be the last statement in the constructor making the call
C) it can be anywhere in the constructor making the call
D) you cannot use the this variable in a constructor call
A) it must be the first statement in the constructor making the call
B) it must be the last statement in the constructor making the call
C) it can be anywhere in the constructor making the call
D) you cannot use the this variable in a constructor call
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
41
A class's static methods do not operate on the fields that belong to any instance of the class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
42
An enumerated data type is actually a special type of class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
43
The key word this is the name of a reference variable that an object can use to refer to itself.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
44
When an object reference is passed to a method, the method may change the values in the object.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
45
You can declare an enumerated data type inside of a method.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
46
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
47
Enum constants have a toString method.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
48
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
49
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
50
The names of the enum constants in an enumerated data type must be enclosed in quotation marks.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck