Deck 10: Inheritance
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/70
العب
ملء الشاشة (f)
Deck 10: Inheritance
1
Look at the following code. The method in line ________ will override the method in line ________. Line 1 public class ClassA
Line 2 {
Line 3 public ClassA() {}
Line 4 public int method1(int a){}
Line 5 public double method2(int b){}
Line 6 }
Line 7 public ClassB extends ClassA
Line 8 {
Line 9 public ClassB(){}
Line 10 public int method1(int b, int c){}
Line 11 public double method2(double c){}
Line 12 }
A) 10, 4
B) 11, 5
C) Both A and B
D) None of the above
Line 2 {
Line 3 public ClassA() {}
Line 4 public int method1(int a){}
Line 5 public double method2(int b){}
Line 6 }
Line 7 public ClassB extends ClassA
Line 8 {
Line 9 public ClassB(){}
Line 10 public int method1(int b, int c){}
Line 11 public double method2(double c){}
Line 12 }
A) 10, 4
B) 11, 5
C) Both A and B
D) None of the above
D
2
If two methods have the same name but different signatures, they are:
A) overridden
B) overloaded
C) superclass methods
D) subclass methods
A) overridden
B) overloaded
C) superclass methods
D) subclass methods
B
3
What is wrong with the following code?
Public class ClassB extends ClassA
{
Public ClassB()
{
Int init = 10;
Super(40);
}
}
A) Nothing is wrong with the code.
B) The method super is not defined.
C) The call to the method super must be the first statement in the constructor.
D) No values may be passed to super.
Public class ClassB extends ClassA
{
Public ClassB()
{
Int init = 10;
Super(40);
}
}
A) Nothing is wrong with the code.
B) The method super is not defined.
C) The call to the method super must be the first statement in the constructor.
D) No values may be passed to super.
C
4
In an inheritance relationship:
A) The superclass constructor always executes before the subclass constructor
B) The subclass constructor always executes before the superclass constructor
C) The constructor with the lowest overhead always executes first regardless of inheritance
D) The unified constructor always executes first regardless of inheritance
A) The superclass constructor always executes before the subclass constructor
B) The subclass constructor always executes before the superclass constructor
C) The constructor with the lowest overhead always executes first regardless of inheritance
D) The unified constructor always executes first regardless of inheritance
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
5
The super statement that calls the superclass constructor:
A) must be the first statement in the superclass's constructor
B) can appear in any method of the subclass
C) must be the first statement in the subclass's constructor
D) is deprecated and is no longer supported in newer versions of Java
A) must be the first statement in the superclass's constructor
B) can appear in any method of the subclass
C) must be the first statement in the subclass's constructor
D) is deprecated and is no longer supported in newer versions of Java
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
6
If you do not provide an access specifier for a class member, the class member is given ________ by default.
A) private
B) public
C) protected
D) package
A) private
B) public
C) protected
D) package
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
7
When declaring class data members, it is best to declare them as:
A) private members
B) public members
C) protected members
D) restricted members
A) private members
B) public members
C) protected members
D) restricted members
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
8
In UML diagrams, inheritance is shown:
A) With a line that has an open arrowhead at one end that points to the superclass
B) With a line that has an open arrowhead at one end that points to the subclass
C) With a line that has a closed arrowhead at one end that points to the superclass
D) With a line that has a closed arrowhead at one end that points to the subclass
A) With a line that has an open arrowhead at one end that points to the superclass
B) With a line that has an open arrowhead at one end that points to the subclass
C) With a line that has a closed arrowhead at one end that points to the superclass
D) With a line that has a closed arrowhead at one end that points to the subclass
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
9
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
10
If ClassC extends ClassB, which extends ClassA, this would be an example of:
A) multiple inheritance
B) a chain of inheritance
C) a family tree
D) packaging
A) multiple inheritance
B) a chain of inheritance
C) a family tree
D) packaging
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
11
Replacing inadequate superclass methods with more suitable subclass methods is known as what?
A) Method upgrading
B) Tactical inheritance
C) Method overriding
D) Method overloading
A) Method upgrading
B) Tactical inheritance
C) Method overriding
D) Method overloading
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
12
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
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
13
Look at the following code. Which line will cause a compiler error?
Line 1 public class ClassA
Line 2 {
Line 3 public ClassA() {}
Line 4 public final int method1(int a){}
Line 5 public double method2(int b){}
Line 6 }
Line 7 public ClassB extends ClassA
Line 8 {
Line 9 public ClassB(){}
Line 10 public int method1(int b){}
Line 11 public double method2(double c){}
Line 12 }
A) 4
B) 5
C) 10
D) 11
Line 1 public class ClassA
Line 2 {
Line 3 public ClassA() {}
Line 4 public final int method1(int a){}
Line 5 public double method2(int b){}
Line 6 }
Line 7 public ClassB extends ClassA
Line 8 {
Line 9 public ClassB(){}
Line 10 public int method1(int b){}
Line 11 public double method2(double c){}
Line 12 }
A) 4
B) 5
C) 10
D) 11
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
14
If a subclass constructor does not explicitly call a superclass constructor:
A) it must include the code necessary to initialize the superclass fields
B) the superclass fields will be set to the default values for their data types
C) Java will automatically call the superclass's default or no-arg constructor immediately after the code in the subclass's constructor executes
D) Java will automatically call the superclass's default or no-arg constructor just before the code in the subclass's constructor executes
A) it must include the code necessary to initialize the superclass fields
B) the superclass fields will be set to the default values for their data types
C) Java will automatically call the superclass's default or no-arg constructor immediately after the code in the subclass's constructor executes
D) Java will automatically call the superclass's default or no-arg constructor just before the code in the subclass's constructor executes
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
15
When a subclass overloads a superclass method:
A) Both methods may be called with a subclass object
B) Only the subclass method may be called with a subclass object
C) Only the superclass method may be called with a subclass object
D) Neither method may be called with a subclass object
A) Both methods may be called with a subclass object
B) Only the subclass method may be called with a subclass object
C) Only the superclass method may be called with a subclass object
D) Neither method may be called with a subclass object
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
16
What key word can you use to call a superclass constructor explicitly?
A) goto
B) this
C) super
D) extends
A) goto
B) this
C) super
D) extends
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
17
Look at the following code and determine what the call to super will do. public class ClassB extends ClassA
{
Public ClassB()
{
Super(10);
}
}
A) This cannot be determined form the code shown.
B) It will call the constructor of ClassA that receives an integer as an argument.
C) It will call the method named super and pass the value 10 to it as an argument.
D) The method super will have to be defined before we can say what will happen.
{
Public ClassB()
{
Super(10);
}
}
A) This cannot be determined form the code shown.
B) It will call the constructor of ClassA that receives an integer as an argument.
C) It will call the method named super and pass the value 10 to it as an argument.
D) The method super will have to be defined before we can say what will happen.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
18
If ClassA extends ClassB, then:
A) public and private members of ClassB are public and private, respectively, in ClassA
B) public members in ClassB are public in ClassA, but private members in ClassB cannot be directly accessed in ClassA
C) neither public or private members in ClassB can be directly accessed in ClassA
D) private members in ClassB are changed to protected members in ClassA
A) public and private members of ClassB are public and private, respectively, in ClassA
B) public members in ClassB are public in ClassA, but private members in ClassB cannot be directly accessed in ClassA
C) neither public or private members in ClassB can be directly accessed in ClassA
D) private members in ClassB are changed to protected members in ClassA
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
19
When a method is declared with the ________ modifier, it cannot be overridden in a subclass.
A) extends
B) final
C) super
D) public
A) extends
B) final
C) super
D) public
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
20
Which of the following statements declares Salaried as a subclass of PayType?
A) public class Salaried extends PayType
B) public class Salaried implements PayType
C) public class Salaried derivedFrom(Paytype)
D) public class PayType derives Salaried
A) public class Salaried extends PayType
B) public class Salaried implements PayType
C) public class Salaried derivedFrom(Paytype)
D) public class PayType derives Salaried
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
21
Look at the following code. The method in line ________ will override the method in line ________. Line 1 public class ClassA
Line 2 {
Line 3 public ClassA() {}
Line 4 public int method1(int a){}
Line 5 public int method2(int b){}
Line 6 }
Line 7 public ClassB extends ClassA
Line 8 {
Line 9 public ClassB(){}
Line 10 public int method1(int b){}
Line 11 public int method2(double c){}
Line 12 }
A) 4, 10
B) 5, 11
C) 10, 4
D) 11, 5
E) Both A and B
Line 2 {
Line 3 public ClassA() {}
Line 4 public int method1(int a){}
Line 5 public int method2(int b){}
Line 6 }
Line 7 public ClassB extends ClassA
Line 8 {
Line 9 public ClassB(){}
Line 10 public int method1(int b){}
Line 11 public int method2(double c){}
Line 12 }
A) 4, 10
B) 5, 11
C) 10, 4
D) 11, 5
E) Both A and B
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
22
Look at the following code. Which line has an error?
Line 1 public interface Interface1
Line 2 {
Line 3 int FIELDA = 55;
Line 4 public int methodA(double){}
Line 5 }
A) 1
B) 2
C) 3
D) 4
Line 1 public interface Interface1
Line 2 {
Line 3 int FIELDA = 55;
Line 4 public int methodA(double){}
Line 5 }
A) 1
B) 2
C) 3
D) 4
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
23
Look at the following code. Line 1 public class ClassA
Line 2 {
Line 3 public ClassA() {}
Line 4 public void method1(){}
Line 5 }
Line 6 public class ClassB extends ClassA
Line 7 {
Line 8 public ClassB(){}
Line 9 public void method1(){}
Line 10 }
Line 11 public class ClassC extends ClassB
Line 12 {
Line 13 public ClassC(){}
Line 14 public void method1(){}
Line 15 }
Which method1 will be executed as a result of the following statements?
ClassA item1 = new ClassC();
Item1.method1();
A) Line 4
B) Line 9
C) Line 14
D) This is an error and will cause the program to crash.
Line 2 {
Line 3 public ClassA() {}
Line 4 public void method1(){}
Line 5 }
Line 6 public class ClassB extends ClassA
Line 7 {
Line 8 public ClassB(){}
Line 9 public void method1(){}
Line 10 }
Line 11 public class ClassC extends ClassB
Line 12 {
Line 13 public ClassC(){}
Line 14 public void method1(){}
Line 15 }
Which method1 will be executed as a result of the following statements?
ClassA item1 = new ClassC();
Item1.method1();
A) Line 4
B) Line 9
C) Line 14
D) This is an error and will cause the program to crash.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
24
In the following code, what will the call to super do?
Public class ClassB extends ClassA
{
Public ClassB()
{
Super(40);
System.out.println("This is the last statement "+
"in the constructor.");
}
}
A) This cannot be determined from the code.
B) It will call the method super and pass the value 40 to it as an argument.
C) It will call the constructor of ClassA that receives an integer as an argument.
D) The method super will have to be defined before we can say what will happen.
Public class ClassB extends ClassA
{
Public ClassB()
{
Super(40);
System.out.println("This is the last statement "+
"in the constructor.");
}
}
A) This cannot be determined from the code.
B) It will call the method super and pass the value 40 to it as an argument.
C) It will call the constructor of ClassA that receives an integer as an argument.
D) The method super will have to be defined before we can say what will happen.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
25
Look at the following code. What is missing from ClassA?
Line 1 public interface MyInterface
Line 2 {
Line 3 int FIELDA = 55;
Line 4 public int methodA(double);
Line 5 }
Line 6 public class ClassA implements MyInterface
Line 7 {
Line 8 FIELDA = 60;
Line 9 public int methodB(double) { }
Line 10 }
A) It does not override methoda.
B) It does not have a constructor.
C) It does not overload methoda.
D) Nothing is missing. It is a complete class.
Line 1 public interface MyInterface
Line 2 {
Line 3 int FIELDA = 55;
Line 4 public int methodA(double);
Line 5 }
Line 6 public class ClassA implements MyInterface
Line 7 {
Line 8 FIELDA = 60;
Line 9 public int methodB(double) { }
Line 10 }
A) It does not override methoda.
B) It does not have a constructor.
C) It does not overload methoda.
D) Nothing is missing. It is a complete class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
26
What is wrong with the following code?
Public class ClassB extends ClassA
{
Public ClassB()
{
Super(40);
System.out.println("This is the last statement " +
"in the constructor.");
}
}
A) Nothing is wrong with the code.
B) The method super is not defined.
C) The call to the method super must be the first statement in the constructor.
D) No values may be passed to super.
Public class ClassB extends ClassA
{
Public ClassB()
{
Super(40);
System.out.println("This is the last statement " +
"in the constructor.");
}
}
A) Nothing is wrong with the code.
B) The method super is not defined.
C) The call to the method super must be the first statement in the constructor.
D) No values may be passed to super.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
27
When one object is a specialized version of another object, there is this type of relationship between them.
A) "has a"
B) "is a"
C) direct
D) "contains a"
A) "has a"
B) "is a"
C) direct
D) "contains a"
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
28
In the following statement, which is the subclass?
Public class ClassA extends ClassB implements ClassC
A) ClassA
B) ClassB
C) ClassC
D) Cannot tell
Public class ClassA extends ClassB implements ClassC
A) ClassA
B) ClassB
C) ClassC
D) Cannot tell
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
29
Given the following code which of the following is TRUE?
Public class ClassB implements ClassA{}
A) ClassA must override each method in ClassB.
B) ClassB must override each method in ClassA.
C) ClassB inherits from ClassA.
D) ClassA inherits from ClassB.
Public class ClassB implements ClassA{}
A) ClassA must override each method in ClassB.
B) ClassB must override each method in ClassA.
C) ClassB inherits from ClassA.
D) ClassA inherits from ClassB.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
30
Look at the following code. Line 1 public class ClassA
Line 2 {
Line 3 public ClassA() {}
Line 4 public void method1(int a){}
Line 5 }
Line 6 public class ClassB extends ClassA
Line 7 {
Line 8 public ClassB(){}
Line 9 public void method1(){}
Line 10 }
Line 11 public class ClassC extends ClassB
Line 12 {
Line 13 public ClassC(){}
Line 14 public void method1(){}
Line 15 }
Which method will be executed as a result of the following statements?
ClassB item1 = new ClassA();
Item1.method1();
A) Line 4
B) Line 9
C) Line 14
D) This is an error and will cause the program to crash.
Line 2 {
Line 3 public ClassA() {}
Line 4 public void method1(int a){}
Line 5 }
Line 6 public class ClassB extends ClassA
Line 7 {
Line 8 public ClassB(){}
Line 9 public void method1(){}
Line 10 }
Line 11 public class ClassC extends ClassB
Line 12 {
Line 13 public ClassC(){}
Line 14 public void method1(){}
Line 15 }
Which method will be executed as a result of the following statements?
ClassB item1 = new ClassA();
Item1.method1();
A) Line 4
B) Line 9
C) Line 14
D) This is an error and will cause the program to crash.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
31
If a superclass does not have a default constructor or a no-arg constructor:
A) then a class that inherits from it, must initialize the superclass values.
B) then a class that inherits from it, must call one of the constructors that the superclass does have.
C) then a class that inherits from it, does not inherit the data member fields from the superclass.
D) then a class that inherits from it, must contain the default constructor for the superclass.
A) then a class that inherits from it, must initialize the superclass values.
B) then a class that inherits from it, must call one of the constructors that the superclass does have.
C) then a class that inherits from it, does not inherit the data member fields from the superclass.
D) then a class that inherits from it, must contain the default constructor for the superclass.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
32
A subclass may call an overridden superclass method by:
A) prefixing its name with the super key word and a dot (.)
B) prefixing its name with the name of the superclass in parentheses
C) using the extends keyword before the method is called
D) calling the superclass method first and then calling the subclass method
A) prefixing its name with the super key word and a dot (.)
B) prefixing its name with the name of the superclass in parentheses
C) using the extends keyword before the method is called
D) calling the superclass method first and then calling the subclass method
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
33
In the following statement, which is the superclass?
Public class ClassA extends ClassB implements ClassC
A) ClassA
B) ClassB
C) ClassC
D) Cannot tell
Public class ClassA extends ClassB implements ClassC
A) ClassA
B) ClassB
C) ClassC
D) Cannot tell
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
34
Look at the following code. Which line will cause a compiler error?
Line 1 public class ClassA
Line 2 {
Line 3 public ClassA() {}
Line 4 public int method1(int a){}
Line 5 public final int method2(double b){}
Line 6 }
Line 7 public ClassB extends ClassA
Line 8 {
Line 9 public ClassB(){}
Line 10 public int method1(int b){}
Line 11 public int method2(double c){}
Line 12 }
A) 4
B) 5
C) 10
D) 11
Line 1 public class ClassA
Line 2 {
Line 3 public ClassA() {}
Line 4 public int method1(int a){}
Line 5 public final int method2(double b){}
Line 6 }
Line 7 public ClassB extends ClassA
Line 8 {
Line 9 public ClassB(){}
Line 10 public int method1(int b){}
Line 11 public int method2(double c){}
Line 12 }
A) 4
B) 5
C) 10
D) 11
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
35
A subclass can directly access:
A) all members of the superclass
B) only public and private members of the superclass
C) only protected and private members of the superclass
D) only public and protected members of the superclass
A) all members of the superclass
B) only public and private members of the superclass
C) only protected and private members of the superclass
D) only public and protected members of the superclass
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
36
All fields declared in an interface:
A) are final and static
B) have protected access
C) must be initialized in the class implementing the interface
D) have private access
A) are final and static
B) have protected access
C) must be initialized in the class implementing the interface
D) have private access
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
37
If a class contains an abstract method:
A) you cannot create an instance of the class
B) the method will have only a header, but not a body, and end with a semicolon
C) the method must be overridden in subclasses
D) All of the above
A) you cannot create an instance of the class
B) the method will have only a header, but not a body, and end with a semicolon
C) the method must be overridden in subclasses
D) All of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
38
Look at the following code. Which line in ClassA has an error?
Line 1 public interface MyInterface
Line 2 {
Line 3 int FIELDA = 55;
Line 4 public int methodA(double);
Line 5 }
Line 6 public class ClassA implements MyInterface
Line 7 {
Line 8 FIELDA = 60;
Line 9 public int methodA(double) { }
Line 10 }
A) 6
B) 7
C) 8
D) 9
Line 1 public interface MyInterface
Line 2 {
Line 3 int FIELDA = 55;
Line 4 public int methodA(double);
Line 5 }
Line 6 public class ClassA implements MyInterface
Line 7 {
Line 8 FIELDA = 60;
Line 9 public int methodA(double) { }
Line 10 }
A) 6
B) 7
C) 8
D) 9
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
39
Protected members are:
A) not quite private
B) not quite public
C) both A and B
D) neither A nor B
A) not quite private
B) not quite public
C) both A and B
D) neither A nor B
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
40
In the following statement, which is the interface?
Public class ClassA extends ClassB implements ClassC
A) ClassA
B) ClassB
C) ClassC
D) Cannot tell
Public class ClassA extends ClassB implements ClassC
A) ClassA
B) ClassB
C) ClassC
D) Cannot tell
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
41
This is a special type of expression used to create an object that implements a functional interface.
A) lambda
B) beta
C) alpha
D) sigma
A) lambda
B) beta
C) alpha
D) sigma
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
42
What is wrong with the following code?
IntCalculator square = new IntCalculator() {
Public int calculate(int number)
{
Return number * number;
}}
A) The outer braces are not needed.
B) The inner braces are not needed.
C) The new key word is not needed.
D) The statement does not end with a semicolon.
IntCalculator square = new IntCalculator() {
Public int calculate(int number)
{
Return number * number;
}}
A) The outer braces are not needed.
B) The inner braces are not needed.
C) The new key word is not needed.
D) The statement does not end with a semicolon.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
43
This is a variable whose value is never changed, but it isn't declared with the final key word.
A) virtually constant variable
B) effectively final variable
C) default variable
D) anonymous inner variable
A) virtually constant variable
B) effectively final variable
C) default variable
D) anonymous inner variable
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
44
In an interface all methods have:
A) private access
B) protected access
C) public access
D) packaged access
A) private access
B) protected access
C) public access
D) packaged access
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
45
Protected class members are denoted in a UML diagram with the symbol
A) *
B) #
C) +
D) -
A) *
B) #
C) +
D) -
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
46
This annotation tells the Java compiler that a method is meant to override a method in the superclass.
A) @Override
B) @Overload
C) @Protected
D) @Inherited
A) @Override
B) @Overload
C) @Protected
D) @Inherited
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
47
When a subclass extends a superclass, the public members of the superclass become public members of the subclass.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
48
If a class contains an abstract method:
A) you must create an instance of the class
B) the method will have only a header, but not a body, and end with a semicolon
C) the method cannot be overridden in subclasses
D) All of the above.
A) you must create an instance of the class
B) the method will have only a header, but not a body, and end with a semicolon
C) the method cannot be overridden in subclasses
D) All of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
49
Inheritance involves a subclass, which is the general class, and a superclass, which is the specialized class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
50
In a class hierarchy:
A) the more general classes are toward the bottom of the tree and the more specialized are toward the top
B) the more general classes are toward the top of the tree and the more specialized are toward the bottom
C) the more general classes are toward the left of the tree and the more specialized are toward the right
D) the more general classes are toward the right of the tree and the more specialized are toward the left
A) the more general classes are toward the bottom of the tree and the more specialized are toward the top
B) the more general classes are toward the top of the tree and the more specialized are toward the bottom
C) the more general classes are toward the left of the tree and the more specialized are toward the right
D) the more general classes are toward the right of the tree and the more specialized are toward the left
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
51
Like a family tree, a ________ shows the inheritance relationship between classes.
A) flowchart
B) class map
C) class hierarchy
D) binary tree
A) flowchart
B) class map
C) class hierarchy
D) binary tree
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
52
Private members of the superclass cannot be accessed by the subclass.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
53
An anonymous inner class must:
A) implement an interface
B) extend another class
C) either A or B
D) both A and B
A) implement an interface
B) extend another class
C) either A or B
D) both A and B
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
54
What is required for an interface method that has a body?
A) The method header must begin with the key word default.
B) A class that implements the interface must override the method.
C) The @Default annotation must precede the method header.
D) All of the above
A) The method header must begin with the key word default.
B) A class that implements the interface must override the method.
C) The @Default annotation must precede the method header.
D) All of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
55
Look at the following code: Line 1 public class ClassA
Line 2 {
Line 3 public ClassA() {}
Line 4 public void method1(int a){}
Line 5 }
Line 6 public class ClassB extends ClassA
Line 7 {
Line 8 public ClassB(){}
Line 9 public void method1(){}
Line 10 }
Line 11 public class ClassC extends ClassB
Line 12 {
Line 13 public ClassC(){}
Line 14 public void method1(){}
Line 15 }
Which method1 will be executed when the following statements are executed?
ClassA item1 = new ClassB();
Item1.method1();
A) Line 4
B) Line 9
C) Line 14
D) This is an error and will cause the program to crash.
Line 2 {
Line 3 public ClassA() {}
Line 4 public void method1(int a){}
Line 5 }
Line 6 public class ClassB extends ClassA
Line 7 {
Line 8 public ClassB(){}
Line 9 public void method1(){}
Line 10 }
Line 11 public class ClassC extends ClassB
Line 12 {
Line 13 public ClassC(){}
Line 14 public void method1(){}
Line 15 }
Which method1 will be executed when the following statements are executed?
ClassA item1 = new ClassB();
Item1.method1();
A) Line 4
B) Line 9
C) Line 14
D) This is an error and will cause the program to crash.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
56
It is not possible for a superclass to call a subclass's method.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
57
Which of the following is an example of a lambda expression?
A) int x = x * factor;
B) IntCalculator = new divider(x, 2);
C) IntCalculator multiplier = x -> x * factor;
D) All of the above
A) int x = x * factor;
B) IntCalculator = new divider(x, 2);
C) IntCalculator multiplier = x -> x * factor;
D) All of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
58
Which of the following statements correctly specifies three interfaces?
A) public class ClassA implements Interface1, Interface2, Interface3
B) public class ClassA implements [Interface1, Interface2, Interface3]
C) public class ClassA implements (Interface1, Interface2, Interface3)
D) public class ClassA implements Interface1 Interface2 Interface3
A) public class ClassA implements Interface1, Interface2, Interface3
B) public class ClassA implements [Interface1, Interface2, Interface3]
C) public class ClassA implements (Interface1, Interface2, Interface3)
D) public class ClassA implements Interface1 Interface2 Interface3
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
59
Look at the following code: Line 1 public class ClassA
Line 2 {
Line 3 public ClassA() {}
Line 4 public void method1(int a){}
Line 5 }
Line 6 public class ClassB extends ClassA
Line 7 {
Line 8 public ClassB(){}
Line 9 public void method1(){}
Line 10 }
Line 11 public class ClassC extends ClassB
Line 12 {
Line 13 public ClassC(){}
Line 14 public void method1(){}
Line 15 }
Which method will be executed when the following statements are executed?
ClassC item1 = new ClassA();
Item1.method1();
A) Line 4
B) Line 9
C) Line 14
D) This is an error and will cause the program to crash.
Line 2 {
Line 3 public ClassA() {}
Line 4 public void method1(int a){}
Line 5 }
Line 6 public class ClassB extends ClassA
Line 7 {
Line 8 public ClassB(){}
Line 9 public void method1(){}
Line 10 }
Line 11 public class ClassC extends ClassB
Line 12 {
Line 13 public ClassC(){}
Line 14 public void method1(){}
Line 15 }
Which method will be executed when the following statements are executed?
ClassC item1 = new ClassA();
Item1.method1();
A) Line 4
B) Line 9
C) Line 14
D) This is an error and will cause the program to crash.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
60
Which of the following is TRUE about protected access?
A) Protected members may be accessed by methods in the same package or in a subclass, even when the subclass is in a different package.
B) Protected members may be accessed by methods in the same package or in a subclass, but only if the subclass is in the same package.
C) Protected members cannot be accessed by methods in any other classes.
D) Protected members are actually named constants.
A) Protected members may be accessed by methods in the same package or in a subclass, even when the subclass is in a different package.
B) Protected members may be accessed by methods in the same package or in a subclass, but only if the subclass is in the same package.
C) Protected members cannot be accessed by methods in any other classes.
D) Protected members are actually named constants.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
61
All methods in an abstract class must also be declared abstract.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
62
An abstract class is not instantiated, but serves as a superclass for other classes.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
63
A compiler error will result if an anonymous inner class tries to use a variable that is not final, or not effectively final.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
64
If two methods in the same class have the same name but different signatures, the second overrides the first.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
65
In an inheritance relationship, the subclass constructor always executes before the superclass constructor.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
66
Every class is either directly or indirectly derived from the Object class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
67
A functional interface is simply an interface that has one abstract method.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
68
If a method in a subclass has the same signature as a method in the superclass, the subclass method overloads the superclass method.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
69
Every class has a toString method and an equals method inherited from the Object class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck
70
When an interface variable references an object, you can use the interface variable to call any and all of the methods in the class implementing the interface.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 70 في هذه المجموعة.
فتح الحزمة
k this deck