Deck 9: Inheritance
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/40
العب
ملء الشاشة (f)
Deck 9: Inheritance
1
Which of the following statements declares Salaried as a subclass of PayType?
A) public class Salaried implements PayType
B) public class PayType derives Salaried
C) public class Salaried extends PayType
D) public class Salaried derivedFrom(Paytype)
A) public class Salaried implements PayType
B) public class PayType derives Salaried
C) public class Salaried extends PayType
D) public class Salaried derivedFrom(Paytype)
C
2
In object-oriented programming, ________ allows you to extend the capabilities of a class by creating another class that is a specialized version of it.
A) prototyping
B) code reusability
C) inheritance
D) data hiding
A) prototyping
B) code reusability
C) inheritance
D) data hiding
C
3
When one object is a specialized version of another object, there is this type of relationship between them.
A) "is a"
B) "contains a"
C) "has a"
D) "consists of"
A) "is a"
B) "contains a"
C) "has a"
D) "consists of"
A
4
If a subclass constructor does not explicitly call a superclass constructor,
A) the superclass's fields will be set to the default values for their data types.
B) Java will automatically call the superclass's default constructor immediately after the code in the subclass's constructor executes.
C) it must include the code necessary to initialize the superclass fields.
D) Java will automatically call the superclass's default constructor just before the code in the subclass's constructor executes.
A) the superclass's fields will be set to the default values for their data types.
B) Java will automatically call the superclass's default constructor immediately after the code in the subclass's constructor executes.
C) it must include the code necessary to initialize the superclass fields.
D) Java will automatically call the superclass's default constructor just before the code in the subclass's constructor executes.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
5
When an "is a" relationship exists between objects, it means that the specialized object has
A) some of the characteristics of the general class, but not all, plus additional characteristics.
B) some of the characteristics of the general object, but not all.
C) none of the characteristics of the general object.
D) all the characteristics of the general object, plus additional characteristics that make it special.
A) some of the characteristics of the general class, but not all, plus additional characteristics.
B) some of the characteristics of the general object, but not all.
C) none of the characteristics of the general object.
D) all the characteristics of the general object, plus additional characteristics that make it special.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
6
A(n) ________ is a method that appears in a superclass, but expects to be overridden in a subclass.
A) abstract method
B) protected method
C) static method
D) overloaded method
A) abstract method
B) protected method
C) static method
D) overloaded method
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
7
In the following statement, which is the subclass?
Public class ClassA extends ClassB implements ClassC
A) ClassA
B) ClassB
C) ClassC
D) ClassB and ClassC
Public class ClassA extends ClassB implements ClassC
A) ClassA
B) ClassB
C) ClassC
D) ClassB and ClassC
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
8
This shows the inheritance relationships among classes in a manner that is similar to a family tree.
A) UML diagram
B) CRC card
C) flowchart
D) class hierarchy
A) UML diagram
B) CRC card
C) flowchart
D) class hierarchy
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
9
In a class hierarchy,
A) the more general classes are toward the right of the tree and the more specialized classes are toward the left.
B) the more general classes are toward the left of the tree and the more specialized classes are toward the right.
C) the more general classes are toward the bottom of the tree and the more specialized classes are toward the top.
D) the more general classes are toward the top of the tree and the more specialized classes are toward the bottom.
A) the more general classes are toward the right of the tree and the more specialized classes are toward the left.
B) the more general classes are toward the left of the tree and the more specialized classes are toward the right.
C) the more general classes are toward the bottom of the tree and the more specialized classes are toward the top.
D) the more general classes are toward the top of the tree and the more specialized classes are toward the bottom.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
10
A class becomes abstract when you place the ________ key word in the class definition.
A) super
B) extends
C) final
D) abstract
A) super
B) extends
C) final
D) abstract
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
11
You can use this operator to determine whether an object is an instance of a particular class.
A) equals
B) instanceof
C) >>
D) isa
A) equals
B) instanceof
C) >>
D) isa
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
12
All fields declared in an interface
A) have protected access.
B) must be initialized in the class implementing the interface.
C) have private access.
D) are treated as final and static.
A) have protected access.
B) must be initialized in the class implementing the interface.
C) have private access.
D) are treated as final and static.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
13
A ________ member's access is somewhere between private and public.
A) package
B) final
C) protected
D) static
A) package
B) final
C) protected
D) static
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
14
A subclass can directly access
A) only protected and private members of the superclass.
B) all members of the superclass.
C) only public and private members of the superclass.
D) only public and protected members of the superclass.
A) only protected and private members of the superclass.
B) all members of the superclass.
C) only public and private members of the superclass.
D) only public and protected members of the superclass.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
15
When a class does not use the extends key word to inherit from another class, Java automatically extends it from the ________ class.
A) Object
B) subclass
C) superclass
D) public
A) Object
B) subclass
C) superclass
D) public
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
16
If you do not provide an access specifier for a class member, the class member is given ________ access by default.
A) private
B) public
C) protected
D) package
A) private
B) public
C) protected
D) package
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
17
When a method is declared with the ________ modifier, it cannot be overridden in a subclass.
A) final
B) super
C) void
D) public
A) final
B) super
C) void
D) public
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
18
In the following statement, which is the superclass?
Public class ClassA extends ClassB implements ClassC
A) ClassA
B) ClassB
C) ClassC
D) ClassB and ClassC
Public class ClassA extends ClassB implements ClassC
A) ClassA
B) ClassB
C) ClassC
D) ClassB and ClassC
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
19
This key word indicates that a class inherits from another class.
A) final
B) super
C) implements
D) extends
A) final
B) super
C) implements
D) extends
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
20
In Java, a reference variable is ________ because it can reference objects of types different from its own, as long as those types are related to its type through inheritance.
A) static
B) dynamic
C) polymorphic
D) public
A) static
B) dynamic
C) polymorphic
D) public
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
21
In ________, inheritance is shown with a line that has an open arrowhead at one end that points to the superclass.
A) pseudocode
B) UML diagrams
C) CRC cards
D) hierarchy charts
A) pseudocode
B) UML diagrams
C) CRC cards
D) hierarchy charts
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
22
You show inheritance in a UML diagram by connecting two classes with a line that has an open arrowhead that points to the subclass.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
23
You can write a super statement that calls a superclass constructor, but only in the subclass's constructor.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
24
All methods specified by an interface are
A) private.
B) public.
C) protected.
D) static.
A) private.
B) public.
C) protected.
D) static.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
25
Because the subclass is more specialized than the superclass, it is sometimes necessary for the subclass to replace inadequate superclass methods with more suitable ones.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
26
If a method in a subclass has the same signature as a method in the superclass, the subclass method ________ the superclass method.
A) inherits
B) overrides
C) overloads
D) implements
A) inherits
B) overrides
C) overloads
D) implements
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
27
Which of the following statements correctly specifies two interfaces?
A) public class ClassA implements [Interface1, Interface2]
B) public class ClassA implements (Interface1, Interface2)
C) public class ClassA implements Interface1 | Interface2
D) public class ClassA implements Interface1, Interface2
A) public class ClassA implements [Interface1, Interface2]
B) public class ClassA implements (Interface1, Interface2)
C) public class ClassA implements Interface1 | Interface2
D) public class ClassA implements Interface1, Interface2
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
28
In a UML diagram, you show a realization relationship by connecting a class and an interface with a
A) dashed line that has an open arrowhead at one end.
B) line that has an open diamond at one end.
C) dashed line.
D) line that has an open arrowhead at one end.
A) dashed line that has an open arrowhead at one end.
B) line that has an open diamond at one end.
C) dashed line.
D) line that has an open arrowhead at one end.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
29
An abstract class is not instantiated itself, but serves as a superclass for other classes.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
30
When an "is a" relationship exists between objects, it means that the specialized object has all of the characteristics of the general object, plus additional characteristics that make it special.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
31
When a subclass overrides a superclass method, only the subclass's version of the method can be called with a subclass object.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
32
Because every class directly or indirectly inherits from the Object class, every class inherits the Object class's members.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
33
When a class implements an interface, an inheritance relationship known as ________ is established.
A) implemented heritage
B) interface inheritance
C) realized inheritance
D) abstract inheritance
A) implemented heritage
B) interface inheritance
C) realized inheritance
D) abstract inheritance
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
34
A protected member of a class may be directly accessed by
A) methods of the same class.
B) methods of a subclass.
C) methods in the same package.
D) All of the above
A) methods of the same class.
B) methods of a subclass.
C) methods in the same package.
D) All of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
35
When a class contains an abstract method, you cannot create an instance of the class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
36
In an inheritance relationship, the subclass constructor always executes before the superclass constructor.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
37
If a method in a subclass has the same signature as a method in the superclass, the subclass method overrides the superclass method.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
38
In the following statement, which is the interface?
Public class ClassA extends ClassB implements ClassC
A) ClassA
B) ClassB
C) ClassC
D) ClassA, ClassB, and ClassC
Public class ClassA extends ClassB implements ClassC
A) ClassA
B) ClassB
C) ClassC
D) ClassA, ClassB, and ClassC
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
39
Protected class members can be denoted in a UML diagram with the ________ symbol.
A) +
B) -
C) *
D) #
A) +
B) -
C) *
D) #
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
40
If ClassC is derived from ClassB, which is derived from ClassA, this would be an example of
A) a chain of inheritance.
B) linear inheritance.
C) multiple interfaces.
D) cascading classes.
A) a chain of inheritance.
B) linear inheritance.
C) multiple interfaces.
D) cascading classes.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck