Deck 9: Inheritance

ملء الشاشة (f)
exit full mode
سؤال
You are creating a class inheritance hierarchy about motor vehicles that will contain classes named Vehicle, Auto, and Motorcycle.Which of the following statements is correct?
A.Vehicle should be the default class, while Auto and Motorcycle should be the subclasses.
B.Vehicle should be the superclass, while Auto and Motorcycle should be the subclasses.
C.Vehicle should be the subclass, while Auto and Motorcycle should be the superclasses.
D.Vehicle should be the subclass, while Auto and Motorcycle should be the default classes.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
Consider the classes shown below: Consider the classes shown below:   A.Line 1 only B.Line 2 only C.Lines 1 and 2 D.Neither line will compile without error<div style=padding-top: 35px>
A.Line 1 only
B.Line 2 only
C.Lines 1 and 2
D.Neither line will compile without error
سؤال
Consider the following inheritance hierarchy diagram: Consider the following inheritance hierarchy diagram:   Which of the following statements is correct? A.Auto class inherits from LandVehicle class, and LandVehicle class inherits from Vehicle class. B.Auto class inherits from LandVehicle class, and Vehicle class inherits from LandVehicle class. C.LandVehicle class inherits from Auto class, and LandVehicle class inherits from Vehicle class. D.LandVehicle class inherits from Auto class, and Vehicle class inherits from LandVehicle class.<div style=padding-top: 35px> Which of the following statements is correct?
A.Auto class inherits from LandVehicle class, and LandVehicle class inherits from Vehicle class.
B.Auto class inherits from LandVehicle class, and Vehicle class inherits from LandVehicle class.
C.LandVehicle class inherits from Auto class, and LandVehicle class inherits from Vehicle class.
D.LandVehicle class inherits from Auto class, and Vehicle class inherits from LandVehicle class.
سؤال
All hamsters are rodents and all rodents are mammals.What hierarchy best captures this information?
A.Hamster is a superclass of Rodent and Rodent is a superclass of Mammal
B.Mammal is a superclass of Rodent and Rodent is a superclass of Hamster
C.Mammal is a superclass of Rodent and Hamster
D.Hamster is a superclass of Rodent and Mammal
سؤال
Which class represents a more specific entity in an inheritance hierarchy?
A.Default class
B.Superclass
C.Subclass.
D.Inheritance class.
سؤال
Which of the following statements about inheritance is correct?
A.You can always use a superclass object in place of a subclass object.
B.You can always use a subclass object in place of a superclass object.
C.A superclass inherits data and behavior from a subclass.
D.A superclass inherits only behavior from a subclass.
سؤال
Consider the following code snippet: Consider the following code snippet:   Which of the following statements is correct? A.The subclass is shadowing a superclass method. B.The subclass is overloading a superclass method. C.The subclass is overriding a superclass method. D.The subclass is defining its own distinct method.<div style=padding-top: 35px> Which of the following statements is correct?
A.The subclass is shadowing a superclass method.
B.The subclass is overloading a superclass method.
C.The subclass is overriding a superclass method.
D.The subclass is defining its own distinct method.
سؤال
Consider the following inheritance hierarchy diagram: Consider the following inheritance hierarchy diagram:   Which of the following statements is correct? A.Auto is a superclass of LandVehicle, and LandVehicle is a superclass of Vehicle. B.Auto is a superclass of LandVehicle, and LandVehicle is a subclass of Vehicle. C.Auto is a subclass of LandVehicle, and LandVehicle is a superclass of Vehicle. D.Auto is a subclass of LandVehicle, and LandVehicle is a subclass of Vehicle.<div style=padding-top: 35px> Which of the following statements is correct?
A.Auto is a superclass of LandVehicle, and LandVehicle is a superclass of Vehicle.
B.Auto is a superclass of LandVehicle, and LandVehicle is a subclass of Vehicle.
C.Auto is a subclass of LandVehicle, and LandVehicle is a superclass of Vehicle.
D.Auto is a subclass of LandVehicle, and LandVehicle is a subclass of Vehicle.
سؤال
Consider the hierarchy of classes shown below. Consider the hierarchy of classes shown below.   What is the direct superclass of the class ScriptedShow? A.Comedy B.RealityShow C.Object D.TelevisionShow<div style=padding-top: 35px> What is the direct superclass of the class ScriptedShow?
A.Comedy
B.RealityShow
C.Object
D.TelevisionShow
سؤال
Insert the missing code in the following code fragment.This fragment is intended to call the Vessel class's method. Insert the missing code in the following code fragment.This fragment is intended to call the Vessel class's method.   A.SpeedBoat.vesselLength(26.0); B.Vessel.vesselLength(26.0); C.vesselLength = 26.0; D.setVesselClass(26.0);<div style=padding-top: 35px>
A.SpeedBoat.vesselLength(26.0);
B.Vessel.vesselLength(26.0);
C.vesselLength = 26.0;
D.setVesselClass(26.0);
سؤال
Consider the classes shown below: Consider the classes shown below:   A.-7 24 B.24 24 C.-7 -7 D.24 -7<div style=padding-top: 35px>
A.-7 24
B.24 24
C.-7 -7
D.24 -7
سؤال
Consider the hierarchy of classes shown below. <strong>Consider the hierarchy of classes shown below.   Which represent valid class headers that would be found in this hierarchy? </strong> A)   B)   C)   D)   <div style=padding-top: 35px> Which represent valid class headers that would be found in this hierarchy?

A) <strong>Consider the hierarchy of classes shown below.   Which represent valid class headers that would be found in this hierarchy? </strong> A)   B)   C)   D)   <div style=padding-top: 35px>
B) <strong>Consider the hierarchy of classes shown below.   Which represent valid class headers that would be found in this hierarchy? </strong> A)   B)   C)   D)   <div style=padding-top: 35px>
C) <strong>Consider the hierarchy of classes shown below.   Which represent valid class headers that would be found in this hierarchy? </strong> A)   B)   C)   D)   <div style=padding-top: 35px>
D) <strong>Consider the hierarchy of classes shown below.   Which represent valid class headers that would be found in this hierarchy? </strong> A)   B)   C)   D)   <div style=padding-top: 35px>
سؤال
What is a class called that represents the most general entity in an inheritance hierarchy?
A.Default class.
B.Superclass.
C.Subclass.
D.Inheritance class.
سؤال
All rodents are mammals and all canines are mammals.No canines are rodents and no rodents are canines.What hierarchy best captures this information?
A.Mammal is a superclass of Rodent and Mammal
B.Rodent is a superclass of Mammal and Canine is a superclass of Mammal
C.Mammal is a superclass of Rodent and Rodent is a superclass of Canine
D.Mammal is a superclass of Canine and Canine is a superclass of Rodent
سؤال
Consider the classes shown below: Consider the classes shown below:   A.100 100 B.-14 21 C.21 21 D.-14 100<div style=padding-top: 35px>
A.100 100
B.-14 21
C.21 21
D.-14 100
سؤال
Consider the classes shown below: Consider the classes shown below:   A.-14 21 B.21 21 C.21 100 D.100 100<div style=padding-top: 35px>
A.-14 21
B.21 21
C.21 100
D.100 100
سؤال
Consider the classes shown below: Consider the classes shown below:   A.100 100 B.-14 100 C.-14 -14 D.100 -14<div style=padding-top: 35px>
A.100 100
B.-14 100
C.-14 -14
D.100 -14
سؤال
Consider the classes shown below: Consider the classes shown below:   A.Line 1 only B.Line 2 only C.Lines 1 and 2 D.Neither line will compile without error<div style=padding-top: 35px>
A.Line 1 only
B.Line 2 only
C.Lines 1 and 2
D.Neither line will compile without error
سؤال
Consider the hierarchy of classes shown below. Consider the hierarchy of classes shown below.   What is the superclass of the class TelevisionShow? A.Object B.Comedy C.RealityShow D.This class has no superclass<div style=padding-top: 35px> What is the superclass of the class TelevisionShow?
A.Object
B.Comedy
C.RealityShow
D.This class has no superclass
سؤال
Insert the missing code in the following code fragment.This fragment is intended to call the Vehicle class's method. Insert the missing code in the following code fragment.This fragment is intended to call the Vehicle class's method.   A.Motorcyle.setVehicleClass(2.0); B.Vehicle.setVehicleClass(2.0); C.numberAxles = 2.0; D.setVehicleClass(2.0);<div style=padding-top: 35px>
A.Motorcyle.setVehicleClass(2.0);
B.Vehicle.setVehicleClass(2.0);
C.numberAxles = 2.0;
D.setVehicleClass(2.0);
سؤال
You are creating a Motorcycle class which is supposed to be a subclass of the Vehicle class.Which of the following class declaration statements will accomplish this?
A.public class Motorcycle extends Vehicle
B.public class Motorcycle implements Vehicle
C.public class Motorcycle interfaces Vehicle
D.public class Motorcycle inherits Vehicle
سؤال
What must a subclass do to modify a private superclass instance variable?
A.The subclass must simply use the name of the superclass instance variable.
B.The subclass must declare its own instance variable with the same name as the superclass instance variable.
C.The subclass must use a public method of the superclass (if it exists) to update the superclass's private instance variable.
D.The subclass must have its own public method to update the superclass's private instance variable.
سؤال
Consider the following code snippet: <strong>Consider the following code snippet:   Which of the following statements is true? </strong> A)This method will call itself. B)This method calls a public method in its subclass. C)This method calls a private method in its superclass D)This method calls a public method in its superclass. <div style=padding-top: 35px> Which of the following statements is true?

A)This method will call itself.
B)This method calls a public method in its subclass.
C)This method calls a private method in its superclass
D)This method calls a public method in its superclass.
سؤال
Consider the following class hierarchy: Consider the following class hierarchy:   Complete the code in the Auto class method named displayAutoType to return the type data. A.super(type); B.super.type; C.super.super.type; D.super.displayInfo()<div style=padding-top: 35px> Complete the code in the Auto class method named displayAutoType to return the type data.
A.super(type);
B.super.type;
C.super.super.type;
D.super.displayInfo()
سؤال
Consider the following class hierarchy: Consider the following class hierarchy:   When an object of type Vehicle is constructed, what will be printed by the constructors from this inheritance hierarchy? A.Vehicle Land Auto B.Auto Land Vehicle C.Vehicle D.Auto<div style=padding-top: 35px> When an object of type Vehicle is constructed, what will be printed by the constructors from this inheritance hierarchy?
A.Vehicle Land Auto
B.Auto Land Vehicle
C.Vehicle
D.Auto
سؤال
Which of the following is true regarding subclasses?

A)A subclass inherits methods from its superclass but not instance variables.
B)A subclass inherits instance variables from its superclass but not methods.
C)A subclass inherits methods and instance variables from its superclass.
D)A subclass does not inherit methods or instance variables from its superclass.
سؤال
Which reserved word must be used to call a method of a superclass?
A.this
B.my
C.parent
D.super
سؤال
Suppose the class Value is partially defined below Suppose the class Value is partially defined below   A subclass of Value, LargerValue, is defined with a getValue method that returns twice the value of the parent.Which line is the body of LargerValue's getValue method? A.return getValue() * 2; B.return super.getValue() * 2; C.return number * 2; D.return super.number * 2;<div style=padding-top: 35px> A subclass of Value, LargerValue, is defined with a getValue method that returns twice the value of the parent.Which line is the body of LargerValue's getValue method?
A.return getValue() * 2;
B.return super.getValue() * 2;
C.return number * 2;
D.return super.number * 2;
سؤال
Which of the following is true regarding subclasses?

A)A subclass has access to private instance variables of its superclass.
B)A subclass does not have access to public instance variables of its superclass.
C)A subclass must specify the implicit parameter to use methods inherited from its superclass.
D)A subclass has no access to private instance variables of its superclass.
سؤال
Which of the following statements about superclasses and subclasses is true?

A)A superclass is larger than its subclass.
B)A superclass inherits from a subclass.
C)A superclass extends a subclass.
D)A subclass extends a superclass.
سؤال
Which of the following indicates that a class named ClassA class is a superclass of the ClassB class?
A.public class ClassB extends ClassA
B.public class ClassB implements ClassA
C.public class ClassA extends ClassB
D.public class ClassA implements ClassB
سؤال
Consider the classes shown below: Consider the classes shown below:   A.24 24 B.-7 -7 C.-7 24 D.24 -7<div style=padding-top: 35px>
A.24 24
B.-7 -7
C.-7 24
D.24 -7
سؤال
Consider the following class hierarchy: Consider the following class hierarchy:   Complete the code in the Auto class constructor to store the type data. A.super(type); B.super(super(type)); C.super.super(type); D.This cannot be done unless Auto declares an instance variable named type.<div style=padding-top: 35px> Complete the code in the Auto class constructor to store the type data.
A.super(type);
B.super(super(type));
C.super.super(type);
D.This cannot be done unless Auto declares an instance variable named type.
سؤال
Which keyword is used to create a subclass?
A.inherits
B.implements
C.interface
D.extends
سؤال
Which of the following is true regarding subclasses?

A)A subclass that inherits methods from its superclass may not override the methods.
B)A subclass that inherits instance variables from its superclass may not declare additional instance variables.
C)A subclass may inherit methods or instance variables from its superclass but not both.
D)A subclass may inherit methods and instance variables from its superclass, and may also implement its own methods and declare its own instance variables.
سؤال
Consider the following code snippet: Consider the following code snippet:   If a Motorcycle class is created as a subclass of the Vehicle class, which of the following statements is correct? A.A Motorcycle object inherits and can directly use both the instance variable manufacturer and the method setVehicleClass. B.A Motorcycle object inherits and can directly use the instance variable manufacturer but not the method setVehicleClass. C.A Motorcycle object inherits but cannot directly use either the instance variable manufacturer or the method setVehicleClass. D.A Motorcycle object inherits and can directly use the method setVehicleClass but cannot directly use the instance variable manufacturer.<div style=padding-top: 35px> If a Motorcycle class is created as a subclass of the Vehicle class, which of the following statements is correct?
A.A Motorcycle object inherits and can directly use both the instance variable manufacturer and the method setVehicleClass.
B.A Motorcycle object inherits and can directly use the instance variable manufacturer but not the method setVehicleClass.
C.A Motorcycle object inherits but cannot directly use either the instance variable manufacturer or the method setVehicleClass.
D.A Motorcycle object inherits and can directly use the method setVehicleClass but cannot directly use the instance variable manufacturer.
سؤال
Consider the following code snippet: Consider the following code snippet:   Which of the following statements is correct? A.The subclass is shadowing a superclass method. B.The subclass is overloading a superclass method. C.The subclass is overriding a superclass method. D.This code will not compile.<div style=padding-top: 35px> Which of the following statements is correct?
A.The subclass is shadowing a superclass method.
B.The subclass is overloading a superclass method.
C.The subclass is overriding a superclass method.
D.This code will not compile.
سؤال
Consider the following class hierarchy: Consider the following class hierarchy:   Complete the code in this program snippet to correctly display the auto's type. A.myAuto.displayInfo() B.myAuto.super.displayInfo() C.myAuto.super.super.displayInfo() D.This cannot be done unless the Auto class overrides the displayInfo method.<div style=padding-top: 35px> Complete the code in this program snippet to correctly display the auto's type.
A.myAuto.displayInfo()
B.myAuto.super.displayInfo()
C.myAuto.super.super.displayInfo()
D.This cannot be done unless the Auto class overrides the displayInfo method.
سؤال
Suppose the class Message is partially defined as shown below: <strong>Suppose the class Message is partially defined as shown below:   A subclass of Message, Excitedimessage, is defined that will behave like Message, except that it will add two exclamation points to the end of the message. Sample code that uses Excitedilessage is shown below:   Which ExcitedMessage constructor will give this behavior?</strong> A)   B)   C)   D)   <div style=padding-top: 35px>
A subclass of Message, Excitedimessage, is defined that will behave like Message, except that it will add two exclamation points to the end of the message. Sample code that uses Excitedilessage is shown below:
<strong>Suppose the class Message is partially defined as shown below:   A subclass of Message, Excitedimessage, is defined that will behave like Message, except that it will add two exclamation points to the end of the message. Sample code that uses Excitedilessage is shown below:   Which ExcitedMessage constructor will give this behavior?</strong> A)   B)   C)   D)   <div style=padding-top: 35px>
Which ExcitedMessage constructor will give this behavior?

A) <strong>Suppose the class Message is partially defined as shown below:   A subclass of Message, Excitedimessage, is defined that will behave like Message, except that it will add two exclamation points to the end of the message. Sample code that uses Excitedilessage is shown below:   Which ExcitedMessage constructor will give this behavior?</strong> A)   B)   C)   D)   <div style=padding-top: 35px>
B) <strong>Suppose the class Message is partially defined as shown below:   A subclass of Message, Excitedimessage, is defined that will behave like Message, except that it will add two exclamation points to the end of the message. Sample code that uses Excitedilessage is shown below:   Which ExcitedMessage constructor will give this behavior?</strong> A)   B)   C)   D)   <div style=padding-top: 35px>
C) <strong>Suppose the class Message is partially defined as shown below:   A subclass of Message, Excitedimessage, is defined that will behave like Message, except that it will add two exclamation points to the end of the message. Sample code that uses Excitedilessage is shown below:   Which ExcitedMessage constructor will give this behavior?</strong> A)   B)   C)   D)   <div style=padding-top: 35px>
D) <strong>Suppose the class Message is partially defined as shown below:   A subclass of Message, Excitedimessage, is defined that will behave like Message, except that it will add two exclamation points to the end of the message. Sample code that uses Excitedilessage is shown below:   Which ExcitedMessage constructor will give this behavior?</strong> A)   B)   C)   D)   <div style=padding-top: 35px>
سؤال
Consider the following class hierarchy: Consider the following class hierarchy:   When an object of type Auto is constructed, what will be printed by the constructors from this inheritance hierarchy? A.Vehicle Land Auto B.Auto Land Vehicle C.Land Auto Vehicle D.Auto<div style=padding-top: 35px> When an object of type Auto is constructed, what will be printed by the constructors from this inheritance hierarchy?
A.Vehicle Land Auto
B.Auto Land Vehicle
C.Land Auto Vehicle
D.Auto
سؤال
When the reserved word super is followed by a parenthesis, what does it indicate?
A.A call to a superclass method.
B.A call to a superclass constructor.
C.A call to a subclass method.
D.A call to a subclass constructor.
سؤال
What is the term used for a subclass that defines a method with the same name as a method in its superclass, but with different parameter types?
A.implementing
B.inheriting
C.overriding
D.overloading
سؤال
Consider the following code snippet: Consider the following code snippet:   Which of the following statements is correct? A.The Motorcycle class's setVehicleClass method overrides the Vehicle class's setVehicleClass method. B.The Vehicle class's setVehicleClass method overrides the Motorcycle class's setVehicleClass method. C.The Motorcycle class's setVehicleClass method overloads the Vehicle class's setVehicleClass method. D.The Vehicle class's setVehicleClass method overloads the Motorcycle class's setVehicleClass method.<div style=padding-top: 35px> Which of the following statements is correct?
A.The Motorcycle class's setVehicleClass method overrides the Vehicle class's setVehicleClass method.
B.The Vehicle class's setVehicleClass method overrides the Motorcycle class's setVehicleClass method.
C.The Motorcycle class's setVehicleClass method overloads the Vehicle class's setVehicleClass method.
D.The Vehicle class's setVehicleClass method overloads the Motorcycle class's setVehicleClass method.
سؤال
Consider the following code snippet that appears in a subclass: <strong>Consider the following code snippet that appears in a subclass:   Which of the following statements is true? </strong> A)This method will call itself. B)This method calls a public method in its subclass. C)This method calls a private method in its superclass D)This method calls a public method in its superclass. <div style=padding-top: 35px> Which of the following statements is true?

A)This method will call itself.
B)This method calls a public method in its subclass.
C)This method calls a private method in its superclass
D)This method calls a public method in its superclass.
سؤال
When the reserved word super is followed by a period and a method name, what does it indicate?
A.A call to a superclass method.
B.A call to a superclass constructor.
C.A call to a subclass method.
D.A call to a subclass constructor.
سؤال
Consider the following code snippet: Consider the following code snippet:   What does this code do? A.It invokes the constructor of the Vehicle class from within the constructor of the Motorcycle class. B.It invokes the constructor of the Motorcycle class from within the constructor of the Vehicle class. C.It invokes a private method of the Vehicle class from within a method of the Motorcycle class. D.It attempts to access directly an instance variable of the Vehicle superclass rather than using a constructor or an accessor.<div style=padding-top: 35px> What does this code do?
A.It invokes the constructor of the Vehicle class from within the constructor of the Motorcycle class.
B.It invokes the constructor of the Motorcycle class from within the constructor of the Vehicle class.
C.It invokes a private method of the Vehicle class from within a method of the Motorcycle class.
D.It attempts to access directly an instance variable of the Vehicle superclass rather than using a constructor or an accessor.
سؤال
Which of the following statements is true about using the reserved word super to call a superclass constructor?

A)The call must use the keyword super followed by a period and a method name.
B)The call must use the keyword super with no arguments.
C)The call must be the last line of the subclass constructor.
D)The call must be the first line of the subclass constructor.
سؤال
In Java, if you forget to call a superclass constructor explicitly in the constructor of a subclass, what will happen?
A.The code will not compile.
B.The default constructor (the one with no arguments) of the superclass will be invoked automatically.
C.The subclass will be constructed without invoking a constructor for the superclass.
D.The subclass object will be given a value of null.
سؤال
Consider the classes shown below: Consider the classes shown below:   A.Methods 1 and 2 only B.Method 2 only C.Methods 2 and 3 only D.Methods 1, 2, and 3<div style=padding-top: 35px>
A.Methods 1 and 2 only
B.Method 2 only
C.Methods 2 and 3 only
D.Methods 1, 2, and 3
سؤال
In Java, if you define two methods that have the same but different parameter types, the compiler will not complain. Why not?
A.The compiler will use only the most recent method definition.
B.The compiler considers the two methods to be completely unrelated.
C.The compiler cannot detect the difference between the two methods.
D.The compiler will silently link the two methods through inheritance.
سؤال
Consider the following code snippet: Consider the following code snippet:   Which of the following statements is correct? A.The Auto class overrides the setVehicleClass method. B.The Vehicle class overrides the setVehicleClass method. C.The Auto class overloads the setVehicleClass method. D.The Vehicle class overloads the setVehicleClass method.<div style=padding-top: 35px> Which of the following statements is correct?
A.The Auto class overrides the setVehicleClass method.
B.The Vehicle class overrides the setVehicleClass method.
C.The Auto class overloads the setVehicleClass method.
D.The Vehicle class overloads the setVehicleClass method.
سؤال
Consider the following code snippet: Consider the following code snippet:   What does this code do? A.It invokes the constructor of the Vehicle class from within the constructor of the Auto class. B.It invokes the constructor of the Auto class from within the constructor of the Vehicle class. C.It invokes a private method of the Vehicle class from within a method of the Auto class. D.This code will not compile.<div style=padding-top: 35px> What does this code do?
A.It invokes the constructor of the Vehicle class from within the constructor of the Auto class.
B.It invokes the constructor of the Auto class from within the constructor of the Vehicle class.
C.It invokes a private method of the Vehicle class from within a method of the Auto class.
D.This code will not compile.
سؤال
Consider the following code snippet: Consider the following code snippet:   A.The Vehicle class constructor would invoke the constructor of the Motorcycle class with no parameters. B.The Motorcycle class constructor would invoke the constructor of the Vehicle class with a parameter value of 0. C.The Motorcycle class constructor would invoke the constructor of the Vehicle class with no parameters. D.This code would not compile.<div style=padding-top: 35px>
A.The Vehicle class constructor would invoke the constructor of the Motorcycle class with no parameters.
B.The Motorcycle class constructor would invoke the constructor of the Vehicle class with a parameter value of 0.
C.The Motorcycle class constructor would invoke the constructor of the Vehicle class with no parameters.
D.This code would not compile.
سؤال
If a subclass defines the same method name and the same parameter types for a method that appears in its superclass, which statement is true?

A)the subclass method overloads the superclass method.
B)the subclass method overrides the superclass method.
C)the subclass has implemented the method on behalf of the superclass.
D)a compiler error will occur.
سؤال
Consider the classes shown below: Consider the classes shown below:   A.Method 1 only B.Methods 2 and 3 only C.Methods 1 and 2 only D.Methods 1, 2, and 3<div style=padding-top: 35px>
A.Method 1 only
B.Methods 2 and 3 only
C.Methods 1 and 2 only
D.Methods 1, 2, and 3
سؤال
Consider the following code snippet: Consider the following code snippet:   Which of the following statements is NOT correct? A.An object of type Motorcycle can call the setVehicleClass method of the Vehicle class on itself. B.An object of type Vehicle can call the setModelName method on itself. C.The Motorcycle class's SetVehicleClass method overrides the Vehicle class's setVehicleClass method. D.An object of type Motorcycle can call the setVehicleClass method of the Motorcycle class on itself.<div style=padding-top: 35px> Which of the following statements is NOT correct?
A.An object of type Motorcycle can call the setVehicleClass method of the Vehicle class on itself.
B.An object of type Vehicle can call the setModelName method on itself.
C.The Motorcycle class's SetVehicleClass method overrides the Vehicle class's setVehicleClass method.
D.An object of type Motorcycle can call the setVehicleClass method of the Motorcycle class on itself.
سؤال
Which statement is true about a subclass that uses the same method name but different parameter types for a method that appears in its superclass?

A)the subclass method has overloaded its superclass's method.
B)the subclass method has overridden its superclass's method.
C)the subclass has implemented its superclass's method.
D)a compiler error will occur.
سؤال
Consider the following code snippet: Consider the following code snippet:   What does this code do? A.It invokes the constructor of the Vehicle class from within the constructor of the Motorcycle class. B.It invokes the constructor of the Motorcycle class from within the constructor of the Vehicle class. C.It invokes a private method of the Vehicle class from within a method of the Motorcycle class. D.This code will not compile.<div style=padding-top: 35px> What does this code do?
A.It invokes the constructor of the Vehicle class from within the constructor of the Motorcycle class.
B.It invokes the constructor of the Motorcycle class from within the constructor of the Vehicle class.
C.It invokes a private method of the Vehicle class from within a method of the Motorcycle class.
D.This code will not compile.
سؤال
Consider the following code snippet: Consider the following code snippet:   What does this code do? A.It invokes the constructor of the Vehicle class from within the constructor of the Motorcycle class. B.It invokes the constructor of the Motorcycle class from within the constructor of the Vehicle class. C.It invokes a private method of the Vehicle class from within a method of the Motorcycle class. D.This code will not compile.<div style=padding-top: 35px> What does this code do?
A.It invokes the constructor of the Vehicle class from within the constructor of the Motorcycle class.
B.It invokes the constructor of the Motorcycle class from within the constructor of the Vehicle class.
C.It invokes a private method of the Vehicle class from within a method of the Motorcycle class.
D.This code will not compile.
سؤال
Consider the following code snippet: Consider the following code snippet:   Which of the following statements is correct? A.An object of type Programmer can call the setDepartment method of the Employee class on itself. B.An object of type Employee can call the setProjectName method on itself. C.The Employee class's setDepartment method overrides the Programmer class's setDepartment method. D.An object of type Employee can call the setDepartment method of the Programmer class on itself.<div style=padding-top: 35px> Which of the following statements is correct?
A.An object of type Programmer can call the setDepartment method of the Employee class on itself.
B.An object of type Employee can call the setProjectName method on itself.
C.The Employee class's setDepartment method overrides the Programmer class's setDepartment method.
D.An object of type Employee can call the setDepartment method of the Programmer class on itself.
سؤال
To ensure that an instance variable can only be accessed by the class that declared it, how should the variable be declared?
A.public
B.private
C.protected
D.final
سؤال
With a few exceptions, what access should instance variables of classes always have?
A.final
B.private
C.public
D.protected
سؤال
Which of the following statements about abstract methods is true?

A)An abstract method has a name, parameters, and a return type, but no code in the body of the method.
B)An abstract method has parameters, a return type, and code in its body, but has no defined name.
C)An abstract method has a name, a return type, and code in its body, but has no parameters.
D)An abstract method has only a name and a return type, but no parameters or code in its body.
سؤال
What reserved word in a method definition ensures that subclasses cannot override the method?
A.abstract
B.anonymous
C.final
D.static
سؤال
Consider the following code snippet: Consider the following code snippet:   If the Programmer class inherits from the Employee class, and only the Employee class has an implementation of the increaseSalary method, which statement is correct? A.The increaseSalary method call will cause a run-time error. B.The increaseSalary method of the Employee class will be executed. C.The Programmer class is required to provide an implementation of the increaseSalary method. D.Programmer objects must be cast to Employee objects before the method call can me made.<div style=padding-top: 35px> If the Programmer class inherits from the Employee class, and only the Employee class has an implementation of the increaseSalary method, which statement is correct?
A.The increaseSalary method call will cause a run-time error.
B.The increaseSalary method of the Employee class will be executed.
C.The Programmer class is required to provide an implementation of the increaseSalary method.
D.Programmer objects must be cast to Employee objects before the method call can me made.
سؤال
If a class has an abstract method, which of the following statements is NOT true?

A)You can construct an object from this class.
B)You can have an object reference whose type is this class.
C)You can inherit from this class.
D)All non-abstract subclasses of this class must implement this method.
سؤال
Consider the following code snippet: <strong>Consider the following code snippet:   You wish to create a concrete subclass named PolisherHachine. Which of the following is the correct way to declare this subclass?</strong> A)   B)   C)   D)   <div style=padding-top: 35px>
You wish to create a concrete subclass named PolisherHachine. Which of the following is the correct way to declare this subclass?

A) <strong>Consider the following code snippet:   You wish to create a concrete subclass named PolisherHachine. Which of the following is the correct way to declare this subclass?</strong> A)   B)   C)   D)   <div style=padding-top: 35px>
B) <strong>Consider the following code snippet:   You wish to create a concrete subclass named PolisherHachine. Which of the following is the correct way to declare this subclass?</strong> A)   B)   C)   D)   <div style=padding-top: 35px>
C) <strong>Consider the following code snippet:   You wish to create a concrete subclass named PolisherHachine. Which of the following is the correct way to declare this subclass?</strong> A)   B)   C)   D)   <div style=padding-top: 35px>
D) <strong>Consider the following code snippet:   You wish to create a concrete subclass named PolisherHachine. Which of the following is the correct way to declare this subclass?</strong> A)   B)   C)   D)   <div style=padding-top: 35px>
سؤال
Consider the following code snippet: <strong>Consider the following code snippet:   Which statement is true about the accessibility of data in the numberAxles variable? </strong> A)It is only accessible by the Vehicle class's methods and by all of its subclasses B)It is only accessible by the Vehicle class's methods, by all of its subclasses, and by methods in classes within the same package. C)It is only accessible by the Vehicle class's methods. D)It is accessible by any class. <div style=padding-top: 35px> Which statement is true about the accessibility of data in the numberAxles variable?

A)It is only accessible by the Vehicle class's methods and by all of its subclasses
B)It is only accessible by the Vehicle class's methods, by all of its subclasses, and by methods in classes within the same package.
C)It is only accessible by the Vehicle class's methods.
D)It is accessible by any class.
سؤال
Consider the following class hierarchy: Consider the following class hierarchy:   Which of the following code fragments is NOT valid in Java? A.Vehicle myAuto = new Auto(sedan); B.LandVehicle myAuto = new Auto(sedan); C.Auto myAuto = new Auto(sedan); D.LandVehicle myAuto = new Vehicle(sedan);<div style=padding-top: 35px> Which of the following code fragments is NOT valid in Java?
A.Vehicle myAuto = new Auto("sedan");
B.LandVehicle myAuto = new Auto("sedan");
C.Auto myAuto = new Auto("sedan");
D.LandVehicle myAuto = new Vehicle("sedan");
سؤال
The term for a class from which you cannot create objects is
A.Abstract class.
B.Concrete class.
C.Non-inheritable class.
D.Superclass.
سؤال
Consider the following code snippet: Consider the following code snippet:   Assume that the Auto class inherits from the Vehicle class, and both classes have an implementation of the moveForward method with the same set of parameters and the same return type.The process for determining which class's moveForward method to execute is called ____. A.inheritance disambiguation. B.inheritance hierarchy. C.dynamic inheritance. D.dynamic method lookup.<div style=padding-top: 35px> Assume that the Auto class inherits from the Vehicle class, and both classes have an implementation of the moveForward method with the same set of parameters and the same return type.The process for determining which class's moveForward method to execute is called ____.
A.inheritance disambiguation.
B.inheritance hierarchy.
C.dynamic inheritance.
D.dynamic method lookup.
سؤال
In designing an inheritance hierarchy it is helpful first to list classes that are part of the hierarchy and then organize those classes via an inheritance diagram.Once this has been done, what is the next step in the design?
A.Determine common responsibilities among the classes.
B.Decide which methods should be overridden.
C.Declare the public interface of each class.
D.Define and implement constructors and methods.
سؤال
What reserved word in a class definition ensures that subclasses cannot be created from the class?
A.abstract
B.anonymous
C.final
D.static
سؤال
When declared as protected, which statement is true about the access to data in an object?

A)The data is accessible only by that class's methods and by all of its subclasses
B)The data is accessible only by that class's methods, by all of its subclasses, and by methods in classes within the same package.
C)The data is accessible only by that class's methods.
D)The data is accessible by any class.
سؤال
Consider the following code snippet: Consider the following code snippet:   If the Auto class inherits from the Vehicle class, and both classes have an implementation of the moveForward method with the same set of parameters and the same return type, which statement is correct? A.The moveForward method of the Auto class will be executed. B.The moveForward method of the Vehicle class will be executed. C.You must specify in the code which class's moveForward method is to be used. D.It is not possible to determine which class's method is called.<div style=padding-top: 35px> If the Auto class inherits from the Vehicle class, and both classes have an implementation of the moveForward method with the same set of parameters and the same return type, which statement is correct?
A.The moveForward method of the Auto class will be executed.
B.The moveForward method of the Vehicle class will be executed.
C.You must specify in the code which class's moveForward method is to be used.
D.It is not possible to determine which class's method is called.
سؤال
Which of the following is true regarding inheritance?

A)When creating a subclass, all methods of the superclass must be overridden.
B)When creating a subclass, no methods of a superclass can be overridden.
C)A superclass can force a programmer to override a method in any subclass created from it.
D)A superclass cannot prevent a programmer from overriding a method in any subclass created from it.
سؤال
Suppose the abstract class Message is defined below Suppose the abstract class Message is defined below   A concrete subclass of Message, called FrenchMessage, is defined.Which methods must FrenchMessage define? A.translate() only B.getMessage() only C.The FrenchMessage constructor and translate() only D.The FrenchMessage constructor, getMessage(), and translate()<div style=padding-top: 35px> A concrete subclass of Message, called FrenchMessage, is defined.Which methods must FrenchMessage define?
A.translate() only
B.getMessage() only
C.The FrenchMessage constructor and translate() only
D.The FrenchMessage constructor, getMessage(), and translate()
سؤال
Consider the following code snippet: Consider the following code snippet:   Assume that the Auto class inherits from the Vehicle class, and both classes have an implementation of the moveForward method with the same set of parameters and the same return type.What determines which class's moveForward method is to be executed? A.the actual object type. B.the variable's type. C.the hierarchy of the classes. D.it is not possible to determine which method is executed.<div style=padding-top: 35px> Assume that the Auto class inherits from the Vehicle class, and both classes have an implementation of the moveForward method with the same set of parameters and the same return type.What determines which class's moveForward method is to be executed?
A.the actual object type.
B.the variable's type.
C.the hierarchy of the classes.
D.it is not possible to determine which method is executed.
سؤال
Which of the following statements about classes is true?

A)You can create an object from a class declared with the keyword final.
B)You can override methods in a class declared with the keyword final.
C)You can extend a class declared with the keyword final.
D)You can create subclasses from a class declared with the keyword final.
سؤال
Which of the following statements about classes is true?

A)You can create an object from a concrete class, but not from an abstract class.
B)You can create an object from an abstract class, but not from a concrete class.
C)You cannot have an object reference whose type is an abstract class.
D)You cannot create subclasses from abstract classes.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/99
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 9: Inheritance
1
You are creating a class inheritance hierarchy about motor vehicles that will contain classes named Vehicle, Auto, and Motorcycle.Which of the following statements is correct?
A.Vehicle should be the default class, while Auto and Motorcycle should be the subclasses.
B.Vehicle should be the superclass, while Auto and Motorcycle should be the subclasses.
C.Vehicle should be the subclass, while Auto and Motorcycle should be the superclasses.
D.Vehicle should be the subclass, while Auto and Motorcycle should be the default classes.
B
2
Consider the classes shown below: Consider the classes shown below:   A.Line 1 only B.Line 2 only C.Lines 1 and 2 D.Neither line will compile without error
A.Line 1 only
B.Line 2 only
C.Lines 1 and 2
D.Neither line will compile without error
C
3
Consider the following inheritance hierarchy diagram: Consider the following inheritance hierarchy diagram:   Which of the following statements is correct? A.Auto class inherits from LandVehicle class, and LandVehicle class inherits from Vehicle class. B.Auto class inherits from LandVehicle class, and Vehicle class inherits from LandVehicle class. C.LandVehicle class inherits from Auto class, and LandVehicle class inherits from Vehicle class. D.LandVehicle class inherits from Auto class, and Vehicle class inherits from LandVehicle class. Which of the following statements is correct?
A.Auto class inherits from LandVehicle class, and LandVehicle class inherits from Vehicle class.
B.Auto class inherits from LandVehicle class, and Vehicle class inherits from LandVehicle class.
C.LandVehicle class inherits from Auto class, and LandVehicle class inherits from Vehicle class.
D.LandVehicle class inherits from Auto class, and Vehicle class inherits from LandVehicle class.
A
4
All hamsters are rodents and all rodents are mammals.What hierarchy best captures this information?
A.Hamster is a superclass of Rodent and Rodent is a superclass of Mammal
B.Mammal is a superclass of Rodent and Rodent is a superclass of Hamster
C.Mammal is a superclass of Rodent and Hamster
D.Hamster is a superclass of Rodent and Mammal
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
5
Which class represents a more specific entity in an inheritance hierarchy?
A.Default class
B.Superclass
C.Subclass.
D.Inheritance class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
6
Which of the following statements about inheritance is correct?
A.You can always use a superclass object in place of a subclass object.
B.You can always use a subclass object in place of a superclass object.
C.A superclass inherits data and behavior from a subclass.
D.A superclass inherits only behavior from a subclass.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
7
Consider the following code snippet: Consider the following code snippet:   Which of the following statements is correct? A.The subclass is shadowing a superclass method. B.The subclass is overloading a superclass method. C.The subclass is overriding a superclass method. D.The subclass is defining its own distinct method. Which of the following statements is correct?
A.The subclass is shadowing a superclass method.
B.The subclass is overloading a superclass method.
C.The subclass is overriding a superclass method.
D.The subclass is defining its own distinct method.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
8
Consider the following inheritance hierarchy diagram: Consider the following inheritance hierarchy diagram:   Which of the following statements is correct? A.Auto is a superclass of LandVehicle, and LandVehicle is a superclass of Vehicle. B.Auto is a superclass of LandVehicle, and LandVehicle is a subclass of Vehicle. C.Auto is a subclass of LandVehicle, and LandVehicle is a superclass of Vehicle. D.Auto is a subclass of LandVehicle, and LandVehicle is a subclass of Vehicle. Which of the following statements is correct?
A.Auto is a superclass of LandVehicle, and LandVehicle is a superclass of Vehicle.
B.Auto is a superclass of LandVehicle, and LandVehicle is a subclass of Vehicle.
C.Auto is a subclass of LandVehicle, and LandVehicle is a superclass of Vehicle.
D.Auto is a subclass of LandVehicle, and LandVehicle is a subclass of Vehicle.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
9
Consider the hierarchy of classes shown below. Consider the hierarchy of classes shown below.   What is the direct superclass of the class ScriptedShow? A.Comedy B.RealityShow C.Object D.TelevisionShow What is the direct superclass of the class ScriptedShow?
A.Comedy
B.RealityShow
C.Object
D.TelevisionShow
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
10
Insert the missing code in the following code fragment.This fragment is intended to call the Vessel class's method. Insert the missing code in the following code fragment.This fragment is intended to call the Vessel class's method.   A.SpeedBoat.vesselLength(26.0); B.Vessel.vesselLength(26.0); C.vesselLength = 26.0; D.setVesselClass(26.0);
A.SpeedBoat.vesselLength(26.0);
B.Vessel.vesselLength(26.0);
C.vesselLength = 26.0;
D.setVesselClass(26.0);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
11
Consider the classes shown below: Consider the classes shown below:   A.-7 24 B.24 24 C.-7 -7 D.24 -7
A.-7 24
B.24 24
C.-7 -7
D.24 -7
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
12
Consider the hierarchy of classes shown below. <strong>Consider the hierarchy of classes shown below.   Which represent valid class headers that would be found in this hierarchy? </strong> A)   B)   C)   D)   Which represent valid class headers that would be found in this hierarchy?

A) <strong>Consider the hierarchy of classes shown below.   Which represent valid class headers that would be found in this hierarchy? </strong> A)   B)   C)   D)
B) <strong>Consider the hierarchy of classes shown below.   Which represent valid class headers that would be found in this hierarchy? </strong> A)   B)   C)   D)
C) <strong>Consider the hierarchy of classes shown below.   Which represent valid class headers that would be found in this hierarchy? </strong> A)   B)   C)   D)
D) <strong>Consider the hierarchy of classes shown below.   Which represent valid class headers that would be found in this hierarchy? </strong> A)   B)   C)   D)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
13
What is a class called that represents the most general entity in an inheritance hierarchy?
A.Default class.
B.Superclass.
C.Subclass.
D.Inheritance class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
14
All rodents are mammals and all canines are mammals.No canines are rodents and no rodents are canines.What hierarchy best captures this information?
A.Mammal is a superclass of Rodent and Mammal
B.Rodent is a superclass of Mammal and Canine is a superclass of Mammal
C.Mammal is a superclass of Rodent and Rodent is a superclass of Canine
D.Mammal is a superclass of Canine and Canine is a superclass of Rodent
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
15
Consider the classes shown below: Consider the classes shown below:   A.100 100 B.-14 21 C.21 21 D.-14 100
A.100 100
B.-14 21
C.21 21
D.-14 100
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
16
Consider the classes shown below: Consider the classes shown below:   A.-14 21 B.21 21 C.21 100 D.100 100
A.-14 21
B.21 21
C.21 100
D.100 100
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
17
Consider the classes shown below: Consider the classes shown below:   A.100 100 B.-14 100 C.-14 -14 D.100 -14
A.100 100
B.-14 100
C.-14 -14
D.100 -14
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
18
Consider the classes shown below: Consider the classes shown below:   A.Line 1 only B.Line 2 only C.Lines 1 and 2 D.Neither line will compile without error
A.Line 1 only
B.Line 2 only
C.Lines 1 and 2
D.Neither line will compile without error
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
19
Consider the hierarchy of classes shown below. Consider the hierarchy of classes shown below.   What is the superclass of the class TelevisionShow? A.Object B.Comedy C.RealityShow D.This class has no superclass What is the superclass of the class TelevisionShow?
A.Object
B.Comedy
C.RealityShow
D.This class has no superclass
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
20
Insert the missing code in the following code fragment.This fragment is intended to call the Vehicle class's method. Insert the missing code in the following code fragment.This fragment is intended to call the Vehicle class's method.   A.Motorcyle.setVehicleClass(2.0); B.Vehicle.setVehicleClass(2.0); C.numberAxles = 2.0; D.setVehicleClass(2.0);
A.Motorcyle.setVehicleClass(2.0);
B.Vehicle.setVehicleClass(2.0);
C.numberAxles = 2.0;
D.setVehicleClass(2.0);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
21
You are creating a Motorcycle class which is supposed to be a subclass of the Vehicle class.Which of the following class declaration statements will accomplish this?
A.public class Motorcycle extends Vehicle
B.public class Motorcycle implements Vehicle
C.public class Motorcycle interfaces Vehicle
D.public class Motorcycle inherits Vehicle
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
22
What must a subclass do to modify a private superclass instance variable?
A.The subclass must simply use the name of the superclass instance variable.
B.The subclass must declare its own instance variable with the same name as the superclass instance variable.
C.The subclass must use a public method of the superclass (if it exists) to update the superclass's private instance variable.
D.The subclass must have its own public method to update the superclass's private instance variable.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
23
Consider the following code snippet: <strong>Consider the following code snippet:   Which of the following statements is true? </strong> A)This method will call itself. B)This method calls a public method in its subclass. C)This method calls a private method in its superclass D)This method calls a public method in its superclass. Which of the following statements is true?

A)This method will call itself.
B)This method calls a public method in its subclass.
C)This method calls a private method in its superclass
D)This method calls a public method in its superclass.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
24
Consider the following class hierarchy: Consider the following class hierarchy:   Complete the code in the Auto class method named displayAutoType to return the type data. A.super(type); B.super.type; C.super.super.type; D.super.displayInfo() Complete the code in the Auto class method named displayAutoType to return the type data.
A.super(type);
B.super.type;
C.super.super.type;
D.super.displayInfo()
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
25
Consider the following class hierarchy: Consider the following class hierarchy:   When an object of type Vehicle is constructed, what will be printed by the constructors from this inheritance hierarchy? A.Vehicle Land Auto B.Auto Land Vehicle C.Vehicle D.Auto When an object of type Vehicle is constructed, what will be printed by the constructors from this inheritance hierarchy?
A.Vehicle Land Auto
B.Auto Land Vehicle
C.Vehicle
D.Auto
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
26
Which of the following is true regarding subclasses?

A)A subclass inherits methods from its superclass but not instance variables.
B)A subclass inherits instance variables from its superclass but not methods.
C)A subclass inherits methods and instance variables from its superclass.
D)A subclass does not inherit methods or instance variables from its superclass.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
27
Which reserved word must be used to call a method of a superclass?
A.this
B.my
C.parent
D.super
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
28
Suppose the class Value is partially defined below Suppose the class Value is partially defined below   A subclass of Value, LargerValue, is defined with a getValue method that returns twice the value of the parent.Which line is the body of LargerValue's getValue method? A.return getValue() * 2; B.return super.getValue() * 2; C.return number * 2; D.return super.number * 2; A subclass of Value, LargerValue, is defined with a getValue method that returns twice the value of the parent.Which line is the body of LargerValue's getValue method?
A.return getValue() * 2;
B.return super.getValue() * 2;
C.return number * 2;
D.return super.number * 2;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
29
Which of the following is true regarding subclasses?

A)A subclass has access to private instance variables of its superclass.
B)A subclass does not have access to public instance variables of its superclass.
C)A subclass must specify the implicit parameter to use methods inherited from its superclass.
D)A subclass has no access to private instance variables of its superclass.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
30
Which of the following statements about superclasses and subclasses is true?

A)A superclass is larger than its subclass.
B)A superclass inherits from a subclass.
C)A superclass extends a subclass.
D)A subclass extends a superclass.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
31
Which of the following indicates that a class named ClassA class is a superclass of the ClassB class?
A.public class ClassB extends ClassA
B.public class ClassB implements ClassA
C.public class ClassA extends ClassB
D.public class ClassA implements ClassB
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
32
Consider the classes shown below: Consider the classes shown below:   A.24 24 B.-7 -7 C.-7 24 D.24 -7
A.24 24
B.-7 -7
C.-7 24
D.24 -7
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
33
Consider the following class hierarchy: Consider the following class hierarchy:   Complete the code in the Auto class constructor to store the type data. A.super(type); B.super(super(type)); C.super.super(type); D.This cannot be done unless Auto declares an instance variable named type. Complete the code in the Auto class constructor to store the type data.
A.super(type);
B.super(super(type));
C.super.super(type);
D.This cannot be done unless Auto declares an instance variable named type.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
34
Which keyword is used to create a subclass?
A.inherits
B.implements
C.interface
D.extends
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
35
Which of the following is true regarding subclasses?

A)A subclass that inherits methods from its superclass may not override the methods.
B)A subclass that inherits instance variables from its superclass may not declare additional instance variables.
C)A subclass may inherit methods or instance variables from its superclass but not both.
D)A subclass may inherit methods and instance variables from its superclass, and may also implement its own methods and declare its own instance variables.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
36
Consider the following code snippet: Consider the following code snippet:   If a Motorcycle class is created as a subclass of the Vehicle class, which of the following statements is correct? A.A Motorcycle object inherits and can directly use both the instance variable manufacturer and the method setVehicleClass. B.A Motorcycle object inherits and can directly use the instance variable manufacturer but not the method setVehicleClass. C.A Motorcycle object inherits but cannot directly use either the instance variable manufacturer or the method setVehicleClass. D.A Motorcycle object inherits and can directly use the method setVehicleClass but cannot directly use the instance variable manufacturer. If a Motorcycle class is created as a subclass of the Vehicle class, which of the following statements is correct?
A.A Motorcycle object inherits and can directly use both the instance variable manufacturer and the method setVehicleClass.
B.A Motorcycle object inherits and can directly use the instance variable manufacturer but not the method setVehicleClass.
C.A Motorcycle object inherits but cannot directly use either the instance variable manufacturer or the method setVehicleClass.
D.A Motorcycle object inherits and can directly use the method setVehicleClass but cannot directly use the instance variable manufacturer.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
37
Consider the following code snippet: Consider the following code snippet:   Which of the following statements is correct? A.The subclass is shadowing a superclass method. B.The subclass is overloading a superclass method. C.The subclass is overriding a superclass method. D.This code will not compile. Which of the following statements is correct?
A.The subclass is shadowing a superclass method.
B.The subclass is overloading a superclass method.
C.The subclass is overriding a superclass method.
D.This code will not compile.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
38
Consider the following class hierarchy: Consider the following class hierarchy:   Complete the code in this program snippet to correctly display the auto's type. A.myAuto.displayInfo() B.myAuto.super.displayInfo() C.myAuto.super.super.displayInfo() D.This cannot be done unless the Auto class overrides the displayInfo method. Complete the code in this program snippet to correctly display the auto's type.
A.myAuto.displayInfo()
B.myAuto.super.displayInfo()
C.myAuto.super.super.displayInfo()
D.This cannot be done unless the Auto class overrides the displayInfo method.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
39
Suppose the class Message is partially defined as shown below: <strong>Suppose the class Message is partially defined as shown below:   A subclass of Message, Excitedimessage, is defined that will behave like Message, except that it will add two exclamation points to the end of the message. Sample code that uses Excitedilessage is shown below:   Which ExcitedMessage constructor will give this behavior?</strong> A)   B)   C)   D)
A subclass of Message, Excitedimessage, is defined that will behave like Message, except that it will add two exclamation points to the end of the message. Sample code that uses Excitedilessage is shown below:
<strong>Suppose the class Message is partially defined as shown below:   A subclass of Message, Excitedimessage, is defined that will behave like Message, except that it will add two exclamation points to the end of the message. Sample code that uses Excitedilessage is shown below:   Which ExcitedMessage constructor will give this behavior?</strong> A)   B)   C)   D)
Which ExcitedMessage constructor will give this behavior?

A) <strong>Suppose the class Message is partially defined as shown below:   A subclass of Message, Excitedimessage, is defined that will behave like Message, except that it will add two exclamation points to the end of the message. Sample code that uses Excitedilessage is shown below:   Which ExcitedMessage constructor will give this behavior?</strong> A)   B)   C)   D)
B) <strong>Suppose the class Message is partially defined as shown below:   A subclass of Message, Excitedimessage, is defined that will behave like Message, except that it will add two exclamation points to the end of the message. Sample code that uses Excitedilessage is shown below:   Which ExcitedMessage constructor will give this behavior?</strong> A)   B)   C)   D)
C) <strong>Suppose the class Message is partially defined as shown below:   A subclass of Message, Excitedimessage, is defined that will behave like Message, except that it will add two exclamation points to the end of the message. Sample code that uses Excitedilessage is shown below:   Which ExcitedMessage constructor will give this behavior?</strong> A)   B)   C)   D)
D) <strong>Suppose the class Message is partially defined as shown below:   A subclass of Message, Excitedimessage, is defined that will behave like Message, except that it will add two exclamation points to the end of the message. Sample code that uses Excitedilessage is shown below:   Which ExcitedMessage constructor will give this behavior?</strong> A)   B)   C)   D)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
40
Consider the following class hierarchy: Consider the following class hierarchy:   When an object of type Auto is constructed, what will be printed by the constructors from this inheritance hierarchy? A.Vehicle Land Auto B.Auto Land Vehicle C.Land Auto Vehicle D.Auto When an object of type Auto is constructed, what will be printed by the constructors from this inheritance hierarchy?
A.Vehicle Land Auto
B.Auto Land Vehicle
C.Land Auto Vehicle
D.Auto
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
41
When the reserved word super is followed by a parenthesis, what does it indicate?
A.A call to a superclass method.
B.A call to a superclass constructor.
C.A call to a subclass method.
D.A call to a subclass constructor.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
42
What is the term used for a subclass that defines a method with the same name as a method in its superclass, but with different parameter types?
A.implementing
B.inheriting
C.overriding
D.overloading
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
43
Consider the following code snippet: Consider the following code snippet:   Which of the following statements is correct? A.The Motorcycle class's setVehicleClass method overrides the Vehicle class's setVehicleClass method. B.The Vehicle class's setVehicleClass method overrides the Motorcycle class's setVehicleClass method. C.The Motorcycle class's setVehicleClass method overloads the Vehicle class's setVehicleClass method. D.The Vehicle class's setVehicleClass method overloads the Motorcycle class's setVehicleClass method. Which of the following statements is correct?
A.The Motorcycle class's setVehicleClass method overrides the Vehicle class's setVehicleClass method.
B.The Vehicle class's setVehicleClass method overrides the Motorcycle class's setVehicleClass method.
C.The Motorcycle class's setVehicleClass method overloads the Vehicle class's setVehicleClass method.
D.The Vehicle class's setVehicleClass method overloads the Motorcycle class's setVehicleClass method.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
44
Consider the following code snippet that appears in a subclass: <strong>Consider the following code snippet that appears in a subclass:   Which of the following statements is true? </strong> A)This method will call itself. B)This method calls a public method in its subclass. C)This method calls a private method in its superclass D)This method calls a public method in its superclass. Which of the following statements is true?

A)This method will call itself.
B)This method calls a public method in its subclass.
C)This method calls a private method in its superclass
D)This method calls a public method in its superclass.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
45
When the reserved word super is followed by a period and a method name, what does it indicate?
A.A call to a superclass method.
B.A call to a superclass constructor.
C.A call to a subclass method.
D.A call to a subclass constructor.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
46
Consider the following code snippet: Consider the following code snippet:   What does this code do? A.It invokes the constructor of the Vehicle class from within the constructor of the Motorcycle class. B.It invokes the constructor of the Motorcycle class from within the constructor of the Vehicle class. C.It invokes a private method of the Vehicle class from within a method of the Motorcycle class. D.It attempts to access directly an instance variable of the Vehicle superclass rather than using a constructor or an accessor. What does this code do?
A.It invokes the constructor of the Vehicle class from within the constructor of the Motorcycle class.
B.It invokes the constructor of the Motorcycle class from within the constructor of the Vehicle class.
C.It invokes a private method of the Vehicle class from within a method of the Motorcycle class.
D.It attempts to access directly an instance variable of the Vehicle superclass rather than using a constructor or an accessor.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
47
Which of the following statements is true about using the reserved word super to call a superclass constructor?

A)The call must use the keyword super followed by a period and a method name.
B)The call must use the keyword super with no arguments.
C)The call must be the last line of the subclass constructor.
D)The call must be the first line of the subclass constructor.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
48
In Java, if you forget to call a superclass constructor explicitly in the constructor of a subclass, what will happen?
A.The code will not compile.
B.The default constructor (the one with no arguments) of the superclass will be invoked automatically.
C.The subclass will be constructed without invoking a constructor for the superclass.
D.The subclass object will be given a value of null.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
49
Consider the classes shown below: Consider the classes shown below:   A.Methods 1 and 2 only B.Method 2 only C.Methods 2 and 3 only D.Methods 1, 2, and 3
A.Methods 1 and 2 only
B.Method 2 only
C.Methods 2 and 3 only
D.Methods 1, 2, and 3
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
50
In Java, if you define two methods that have the same but different parameter types, the compiler will not complain. Why not?
A.The compiler will use only the most recent method definition.
B.The compiler considers the two methods to be completely unrelated.
C.The compiler cannot detect the difference between the two methods.
D.The compiler will silently link the two methods through inheritance.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
51
Consider the following code snippet: Consider the following code snippet:   Which of the following statements is correct? A.The Auto class overrides the setVehicleClass method. B.The Vehicle class overrides the setVehicleClass method. C.The Auto class overloads the setVehicleClass method. D.The Vehicle class overloads the setVehicleClass method. Which of the following statements is correct?
A.The Auto class overrides the setVehicleClass method.
B.The Vehicle class overrides the setVehicleClass method.
C.The Auto class overloads the setVehicleClass method.
D.The Vehicle class overloads the setVehicleClass method.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
52
Consider the following code snippet: Consider the following code snippet:   What does this code do? A.It invokes the constructor of the Vehicle class from within the constructor of the Auto class. B.It invokes the constructor of the Auto class from within the constructor of the Vehicle class. C.It invokes a private method of the Vehicle class from within a method of the Auto class. D.This code will not compile. What does this code do?
A.It invokes the constructor of the Vehicle class from within the constructor of the Auto class.
B.It invokes the constructor of the Auto class from within the constructor of the Vehicle class.
C.It invokes a private method of the Vehicle class from within a method of the Auto class.
D.This code will not compile.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
53
Consider the following code snippet: Consider the following code snippet:   A.The Vehicle class constructor would invoke the constructor of the Motorcycle class with no parameters. B.The Motorcycle class constructor would invoke the constructor of the Vehicle class with a parameter value of 0. C.The Motorcycle class constructor would invoke the constructor of the Vehicle class with no parameters. D.This code would not compile.
A.The Vehicle class constructor would invoke the constructor of the Motorcycle class with no parameters.
B.The Motorcycle class constructor would invoke the constructor of the Vehicle class with a parameter value of 0.
C.The Motorcycle class constructor would invoke the constructor of the Vehicle class with no parameters.
D.This code would not compile.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
54
If a subclass defines the same method name and the same parameter types for a method that appears in its superclass, which statement is true?

A)the subclass method overloads the superclass method.
B)the subclass method overrides the superclass method.
C)the subclass has implemented the method on behalf of the superclass.
D)a compiler error will occur.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
55
Consider the classes shown below: Consider the classes shown below:   A.Method 1 only B.Methods 2 and 3 only C.Methods 1 and 2 only D.Methods 1, 2, and 3
A.Method 1 only
B.Methods 2 and 3 only
C.Methods 1 and 2 only
D.Methods 1, 2, and 3
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
56
Consider the following code snippet: Consider the following code snippet:   Which of the following statements is NOT correct? A.An object of type Motorcycle can call the setVehicleClass method of the Vehicle class on itself. B.An object of type Vehicle can call the setModelName method on itself. C.The Motorcycle class's SetVehicleClass method overrides the Vehicle class's setVehicleClass method. D.An object of type Motorcycle can call the setVehicleClass method of the Motorcycle class on itself. Which of the following statements is NOT correct?
A.An object of type Motorcycle can call the setVehicleClass method of the Vehicle class on itself.
B.An object of type Vehicle can call the setModelName method on itself.
C.The Motorcycle class's SetVehicleClass method overrides the Vehicle class's setVehicleClass method.
D.An object of type Motorcycle can call the setVehicleClass method of the Motorcycle class on itself.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
57
Which statement is true about a subclass that uses the same method name but different parameter types for a method that appears in its superclass?

A)the subclass method has overloaded its superclass's method.
B)the subclass method has overridden its superclass's method.
C)the subclass has implemented its superclass's method.
D)a compiler error will occur.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
58
Consider the following code snippet: Consider the following code snippet:   What does this code do? A.It invokes the constructor of the Vehicle class from within the constructor of the Motorcycle class. B.It invokes the constructor of the Motorcycle class from within the constructor of the Vehicle class. C.It invokes a private method of the Vehicle class from within a method of the Motorcycle class. D.This code will not compile. What does this code do?
A.It invokes the constructor of the Vehicle class from within the constructor of the Motorcycle class.
B.It invokes the constructor of the Motorcycle class from within the constructor of the Vehicle class.
C.It invokes a private method of the Vehicle class from within a method of the Motorcycle class.
D.This code will not compile.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
59
Consider the following code snippet: Consider the following code snippet:   What does this code do? A.It invokes the constructor of the Vehicle class from within the constructor of the Motorcycle class. B.It invokes the constructor of the Motorcycle class from within the constructor of the Vehicle class. C.It invokes a private method of the Vehicle class from within a method of the Motorcycle class. D.This code will not compile. What does this code do?
A.It invokes the constructor of the Vehicle class from within the constructor of the Motorcycle class.
B.It invokes the constructor of the Motorcycle class from within the constructor of the Vehicle class.
C.It invokes a private method of the Vehicle class from within a method of the Motorcycle class.
D.This code will not compile.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
60
Consider the following code snippet: Consider the following code snippet:   Which of the following statements is correct? A.An object of type Programmer can call the setDepartment method of the Employee class on itself. B.An object of type Employee can call the setProjectName method on itself. C.The Employee class's setDepartment method overrides the Programmer class's setDepartment method. D.An object of type Employee can call the setDepartment method of the Programmer class on itself. Which of the following statements is correct?
A.An object of type Programmer can call the setDepartment method of the Employee class on itself.
B.An object of type Employee can call the setProjectName method on itself.
C.The Employee class's setDepartment method overrides the Programmer class's setDepartment method.
D.An object of type Employee can call the setDepartment method of the Programmer class on itself.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
61
To ensure that an instance variable can only be accessed by the class that declared it, how should the variable be declared?
A.public
B.private
C.protected
D.final
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
62
With a few exceptions, what access should instance variables of classes always have?
A.final
B.private
C.public
D.protected
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
63
Which of the following statements about abstract methods is true?

A)An abstract method has a name, parameters, and a return type, but no code in the body of the method.
B)An abstract method has parameters, a return type, and code in its body, but has no defined name.
C)An abstract method has a name, a return type, and code in its body, but has no parameters.
D)An abstract method has only a name and a return type, but no parameters or code in its body.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
64
What reserved word in a method definition ensures that subclasses cannot override the method?
A.abstract
B.anonymous
C.final
D.static
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
65
Consider the following code snippet: Consider the following code snippet:   If the Programmer class inherits from the Employee class, and only the Employee class has an implementation of the increaseSalary method, which statement is correct? A.The increaseSalary method call will cause a run-time error. B.The increaseSalary method of the Employee class will be executed. C.The Programmer class is required to provide an implementation of the increaseSalary method. D.Programmer objects must be cast to Employee objects before the method call can me made. If the Programmer class inherits from the Employee class, and only the Employee class has an implementation of the increaseSalary method, which statement is correct?
A.The increaseSalary method call will cause a run-time error.
B.The increaseSalary method of the Employee class will be executed.
C.The Programmer class is required to provide an implementation of the increaseSalary method.
D.Programmer objects must be cast to Employee objects before the method call can me made.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
66
If a class has an abstract method, which of the following statements is NOT true?

A)You can construct an object from this class.
B)You can have an object reference whose type is this class.
C)You can inherit from this class.
D)All non-abstract subclasses of this class must implement this method.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
67
Consider the following code snippet: <strong>Consider the following code snippet:   You wish to create a concrete subclass named PolisherHachine. Which of the following is the correct way to declare this subclass?</strong> A)   B)   C)   D)
You wish to create a concrete subclass named PolisherHachine. Which of the following is the correct way to declare this subclass?

A) <strong>Consider the following code snippet:   You wish to create a concrete subclass named PolisherHachine. Which of the following is the correct way to declare this subclass?</strong> A)   B)   C)   D)
B) <strong>Consider the following code snippet:   You wish to create a concrete subclass named PolisherHachine. Which of the following is the correct way to declare this subclass?</strong> A)   B)   C)   D)
C) <strong>Consider the following code snippet:   You wish to create a concrete subclass named PolisherHachine. Which of the following is the correct way to declare this subclass?</strong> A)   B)   C)   D)
D) <strong>Consider the following code snippet:   You wish to create a concrete subclass named PolisherHachine. Which of the following is the correct way to declare this subclass?</strong> A)   B)   C)   D)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
68
Consider the following code snippet: <strong>Consider the following code snippet:   Which statement is true about the accessibility of data in the numberAxles variable? </strong> A)It is only accessible by the Vehicle class's methods and by all of its subclasses B)It is only accessible by the Vehicle class's methods, by all of its subclasses, and by methods in classes within the same package. C)It is only accessible by the Vehicle class's methods. D)It is accessible by any class. Which statement is true about the accessibility of data in the numberAxles variable?

A)It is only accessible by the Vehicle class's methods and by all of its subclasses
B)It is only accessible by the Vehicle class's methods, by all of its subclasses, and by methods in classes within the same package.
C)It is only accessible by the Vehicle class's methods.
D)It is accessible by any class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
69
Consider the following class hierarchy: Consider the following class hierarchy:   Which of the following code fragments is NOT valid in Java? A.Vehicle myAuto = new Auto(sedan); B.LandVehicle myAuto = new Auto(sedan); C.Auto myAuto = new Auto(sedan); D.LandVehicle myAuto = new Vehicle(sedan); Which of the following code fragments is NOT valid in Java?
A.Vehicle myAuto = new Auto("sedan");
B.LandVehicle myAuto = new Auto("sedan");
C.Auto myAuto = new Auto("sedan");
D.LandVehicle myAuto = new Vehicle("sedan");
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
70
The term for a class from which you cannot create objects is
A.Abstract class.
B.Concrete class.
C.Non-inheritable class.
D.Superclass.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
71
Consider the following code snippet: Consider the following code snippet:   Assume that the Auto class inherits from the Vehicle class, and both classes have an implementation of the moveForward method with the same set of parameters and the same return type.The process for determining which class's moveForward method to execute is called ____. A.inheritance disambiguation. B.inheritance hierarchy. C.dynamic inheritance. D.dynamic method lookup. Assume that the Auto class inherits from the Vehicle class, and both classes have an implementation of the moveForward method with the same set of parameters and the same return type.The process for determining which class's moveForward method to execute is called ____.
A.inheritance disambiguation.
B.inheritance hierarchy.
C.dynamic inheritance.
D.dynamic method lookup.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
72
In designing an inheritance hierarchy it is helpful first to list classes that are part of the hierarchy and then organize those classes via an inheritance diagram.Once this has been done, what is the next step in the design?
A.Determine common responsibilities among the classes.
B.Decide which methods should be overridden.
C.Declare the public interface of each class.
D.Define and implement constructors and methods.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
73
What reserved word in a class definition ensures that subclasses cannot be created from the class?
A.abstract
B.anonymous
C.final
D.static
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
74
When declared as protected, which statement is true about the access to data in an object?

A)The data is accessible only by that class's methods and by all of its subclasses
B)The data is accessible only by that class's methods, by all of its subclasses, and by methods in classes within the same package.
C)The data is accessible only by that class's methods.
D)The data is accessible by any class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
75
Consider the following code snippet: Consider the following code snippet:   If the Auto class inherits from the Vehicle class, and both classes have an implementation of the moveForward method with the same set of parameters and the same return type, which statement is correct? A.The moveForward method of the Auto class will be executed. B.The moveForward method of the Vehicle class will be executed. C.You must specify in the code which class's moveForward method is to be used. D.It is not possible to determine which class's method is called. If the Auto class inherits from the Vehicle class, and both classes have an implementation of the moveForward method with the same set of parameters and the same return type, which statement is correct?
A.The moveForward method of the Auto class will be executed.
B.The moveForward method of the Vehicle class will be executed.
C.You must specify in the code which class's moveForward method is to be used.
D.It is not possible to determine which class's method is called.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
76
Which of the following is true regarding inheritance?

A)When creating a subclass, all methods of the superclass must be overridden.
B)When creating a subclass, no methods of a superclass can be overridden.
C)A superclass can force a programmer to override a method in any subclass created from it.
D)A superclass cannot prevent a programmer from overriding a method in any subclass created from it.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
77
Suppose the abstract class Message is defined below Suppose the abstract class Message is defined below   A concrete subclass of Message, called FrenchMessage, is defined.Which methods must FrenchMessage define? A.translate() only B.getMessage() only C.The FrenchMessage constructor and translate() only D.The FrenchMessage constructor, getMessage(), and translate() A concrete subclass of Message, called FrenchMessage, is defined.Which methods must FrenchMessage define?
A.translate() only
B.getMessage() only
C.The FrenchMessage constructor and translate() only
D.The FrenchMessage constructor, getMessage(), and translate()
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
78
Consider the following code snippet: Consider the following code snippet:   Assume that the Auto class inherits from the Vehicle class, and both classes have an implementation of the moveForward method with the same set of parameters and the same return type.What determines which class's moveForward method is to be executed? A.the actual object type. B.the variable's type. C.the hierarchy of the classes. D.it is not possible to determine which method is executed. Assume that the Auto class inherits from the Vehicle class, and both classes have an implementation of the moveForward method with the same set of parameters and the same return type.What determines which class's moveForward method is to be executed?
A.the actual object type.
B.the variable's type.
C.the hierarchy of the classes.
D.it is not possible to determine which method is executed.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
79
Which of the following statements about classes is true?

A)You can create an object from a class declared with the keyword final.
B)You can override methods in a class declared with the keyword final.
C)You can extend a class declared with the keyword final.
D)You can create subclasses from a class declared with the keyword final.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
80
Which of the following statements about classes is true?

A)You can create an object from a concrete class, but not from an abstract class.
B)You can create an object from an abstract class, but not from a concrete class.
C)You cannot have an object reference whose type is an abstract class.
D)You cannot create subclasses from abstract classes.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 99 في هذه المجموعة.