Deck 11: Object-Oriented Programming: Inheritance
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/51
العب
ملء الشاشة (f)
Deck 11: Object-Oriented Programming: Inheritance
1
Which of the following pairs demonstrates the has-a relationship between the first and the second terms
A) car, vehicle
B) house, window
C) teacher, person
D) None of the above
A) car, vehicle
B) house, window
C) teacher, person
D) None of the above
B
2
Inheritance is the process of building a class with object references of other classes.
False
Inheritance is the process of taking a class and extending its behaviors and capabilities.Building a class from preexisting object references is known as composition.
Inheritance is the process of taking a class and extending its behaviors and capabilities.Building a class from preexisting object references is known as composition.
3
A derived class cannot access the members of its base class.
A) private
B) static
C) protected
D) None of the above.
A) private
B) static
C) protected
D) None of the above.
A
4
Constructors are not inherited.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
5
Inheritance is represented by a(n)________ relationship.
A) "uses"
B) "is-a"
C) "has-a"
D) None of the above.
A) "uses"
B) "is-a"
C) "has-a"
D) None of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
6
An object of one class cannot be an object of another class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
7
Identify which of the following examples could be considered a base class for the Computer class
A) machine
B) hard-drive
C) software
D) keyboard
A) machine
B) hard-drive
C) software
D) keyboard
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
8
A class inherited from two or more levels up in the hierarchy is known as a
A) indirect base class
B) direct base class
C) superclass
D) None of the above
A) indirect base class
B) direct base class
C) superclass
D) None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
9
Which of the following is not a base/derived class relationship
A) Ford/Taurus
B) University/Boston University
C) Sailboat/Tugboat
D) Country/USA
A) Ford/Taurus
B) University/Boston University
C) Sailboat/Tugboat
D) Country/USA
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
10
A derived class can effect state changes in base class private members only through public,protected,internal methods provided in the base class and inher
ited into the derived class.
ited into the derived class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
11
A base class may have only one derived class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
12
Which of the following pairs demonstrates the is-a relationship between the first and the second terms
A) car, engine
B) book, table of contents
C) baseball, sport
D) None of the above
A) car, engine
B) book, table of contents
C) baseball, sport
D) None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
13
An advantage of inheritance is that:
A) all methods can be inherited
B) all instance variables can be uniformly accessed by base classes and derived classes
C) Objects of a derived class can be treated like objects of their base class
D) None of the above.
A) all methods can be inherited
B) all instance variables can be uniformly accessed by base classes and derived classes
C) Objects of a derived class can be treated like objects of their base class
D) None of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
14
A class that inherits from another class is referred to as the derived class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
15
A derived class is often larger and more general than its base class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
16
The process of abstraction allows you to focus on the commonalities among objects in the system.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
17
Members of a base class that are private are not inherited by derived classes.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
18
Every object of a base class is an object of that class's derived classes.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
19
Multiple inheritance,widely used in C#,is the process of inheriting from more than one class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
20
All classes in C# have object as either a direct or indirect base class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
21
Which base class members are inherited by all derived classes of that base class
A) private instance variables and methods
B) protected instance variables and methods
C) private constructors
D) protected constructors
A) private instance variables and methods
B) protected instance variables and methods
C) private constructors
D) protected constructors
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
22
Base class methods with this level of access cannot be called from derived classes.
A) private
B) public
C) protected
D) package
A) private
B) public
C) protected
D) package
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
23
Consider the classes below,declared in the same file:
Class A
{
Int a;
Public A()
{
A = 7;
}
}
Class B : A
{
Int b;
Public B()
{
B = 8;
}
}
Which of the statements below is false
A) Both variables a and b are instance variables.
B) After the constructor for class B is executed, the variable a will have the value 7.
C) After the constructor for class B is executed, the variable b will have the value 8.
D) A reference to class A can be treated as a reference to class B.
Class A
{
Int a;
Public A()
{
A = 7;
}
}
Class B : A
{
Int b;
Public B()
{
B = 8;
}
}
Which of the statements below is false
A) Both variables a and b are instance variables.
B) After the constructor for class B is executed, the variable a will have the value 7.
C) After the constructor for class B is executed, the variable b will have the value 8.
D) A reference to class A can be treated as a reference to class B.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
24
To avoid duplicating code (and possibly errors),use ________,rather than ________.
A) inheritance, the "copy-and-paste" approach.
B) the "copy-and-past" approach, inheritance.
C) a class that explicitly extends object, a class that does not extend object. d. a class that does not extend object, a class that explicitly extends object.
A) inheritance, the "copy-and-paste" approach.
B) the "copy-and-past" approach, inheritance.
C) a class that explicitly extends object, a class that does not extend object. d. a class that does not extend object, a class that explicitly extends object.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
25
Which of the following classes is the root of the class hierarchy
A) object
B) Point
C) ToString
D) None of the above
A) object
B) Point
C) ToString
D) None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
26
The protected members of a class may be accessed in their base class or any classes derived from that base class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
27
Overriding a method differs from overloading a constructor because:
A) For an overloaded constructor, the base class constructor will always be called first.
B) For an overridden constructor, the base class constructor will always be called first.
C) Overloaded methods have the same signature.
D) Overridden methods have the same signature.
A) For an overloaded constructor, the base class constructor will always be called first.
B) For an overridden constructor, the base class constructor will always be called first.
C) Overloaded methods have the same signature.
D) Overridden methods have the same signature.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
28
When a derived class constructor calls its base class constructor,what happens if the base class's constructor does not assign a value to an instance variable
A) a syntax error occurs
B) a compile-time error occurs
C) a run-time error occurs
D) the program compiles and runs correctly because the instance variables are initialized to their default values
A) a syntax error occurs
B) a compile-time error occurs
C) a run-time error occurs
D) the program compiles and runs correctly because the instance variables are initialized to their default values
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
29
How can a derived class call a base class constructor
A)implicitly
B) explicitly
C) a and b
D) the derived class cannot call the base class constructor
A)implicitly
B) explicitly
C) a and b
D) the derived class cannot call the base class constructor
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
30
Every class in C#,except __________,extends an existing class.
A) Integer
B) object
C) String
D) Class
A) Integer
B) object
C) String
D) Class
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
31
When a program creates a derived-class object,the object constructor is the last constructor called and the first whose body finishes executing.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
32
A base class's constructors are inherited into its derived classes.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
33
When a derived-class member overrides a base-class member,the base-class member can be accessed from the derived-class by using the keyword
A) base
B) top
C) super
D) None of the above
A) base
B) top
C) super
D) None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
34
A method must be declared
__________ for it to be overridden by derived classes.
A) overrides
B) overridable
C) virtual
D) None of the above
__________ for it to be overridden by derived classes.
A) overrides
B) overridable
C) virtual
D) None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
35
Using protected instance variables can cause derived-class methods to be written to depend on base-class implementation.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
36
A "copy-and-paste" approach is a simple and efficient way from a software-engineering perspective of providing func
tionality that exists in other classes.
tionality that exists in other classes.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
37
private fields of a base class can be accessed in a derived class
A) by calling private methods declared in the base class
B) by calling public or protected methods declared in the base class
C) directly
D) All of the above
A) by calling private methods declared in the base class
B) by calling public or protected methods declared in the base class
C) directly
D) All of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
38
The first task of any derived-class constructor is to call its base-class con
structor.
structor.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
39
Which statement is true when a base class has protected instance variables
A) A derived class object can assign an invalid value to the base class's instance variables, thus leaving the object in an inconsistent state.
B) Derived class methods are more likely to be written so that they depend on the base class's data implementation.
C) We may need to modify all the derived classes of the base class if the base class implementation changes.
D) All of the above.
A) A derived class object can assign an invalid value to the base class's instance variables, thus leaving the object in an inconsistent state.
B) Derived class methods are more likely to be written so that they depend on the base class's data implementation.
C) We may need to modify all the derived classes of the base class if the base class implementation changes.
D) All of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
40
Derived classes provide the functionality and features inherited by base classes.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
41
A base class is often designed by factoring out commonalities among a set of classes.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
42
When creating derived classes,you must use discretion in choosing the proper base class.Ideally,the base class will not contain excessive capabilities or information.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
43
If a base class constructor is overridden,the original constructor can no longer be called explicitly by the derived class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
44
Which of the following statements is (are)true
A)We can use inheritance to customize existing software.
B)A base class specifies commonality.
C)A base class can be modified without modifying derived classes
D)A derived class can be modified without modifying its derived class.
A) All of the above
B) None of the above
C) A, B and C
D) A, B and D
A)We can use inheritance to customize existing software.
B)A base class specifies commonality.
C)A base class can be modified without modifying derived classes
D)A derived class can be modified without modifying its derived class.
A) All of the above
B) None of the above
C) A, B and C
D) A, B and D
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
45
Inheritance preserves the integrity of a base class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
46
When a base class method is overridden in a derived class,it is common to have the derived
class version call the base class version and do some additional work.
class version call the base class version and do some additional work.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
47
Method Equals will accurately compare any two objects.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
48
To enhance performance and reduce errors,it's a good idea to make derived classes larger than they need to be.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
49
The default Equals implementation determines:
A) whether two references refer to the same object in memory.
B) whether two references have the same type.
C) whether two objects have the same instance variables.
D) whether two objects have the same instance variable values.
A) whether two references refer to the same object in memory.
B) whether two references have the same type.
C) whether two objects have the same instance variables.
D) whether two objects have the same instance variable values.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
50
A key to improving the software development process is encouraging soft
ware reuse.
ware reuse.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck
51
The default implementation of method ToString of object returns a string representing ________.
A) the object's type
B) the object class name
C) namespace_name.object_class_name
D) None of the above
A) the object's type
B) the object class name
C) namespace_name.object_class_name
D) None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 51 في هذه المجموعة.
فتح الحزمة
k this deck