Consider the following code snippet: public class Motorcycle extends Vehicle {pu
ID: 3811164 • Letter: C
Question
Consider the following code snippet: public class Motorcycle extends Vehicle {public Motorcycle (int number Axles) super (numberAxles);//line #1}} If the line marked "//line #1" was missing, which of these statements would be correct? a. The Motorcycle class constructor would invoke the constructor of the Vehicle class with no parameters. b. The Vehicle class constructor would invoke the constructor of the Motorcycle class with no parameters. c. The Motorcycle class constructor would invoke the constructor of the Vehicle class with a parameter value of 0. d. This code would not compile. Consider the following code snippet: Employee anEmployee = new Programmer(); anEmployee.increaseSalary (2500); Assume that the Programmer class inherits from the Employee class, and both classes have an implementation of the increaseSalary method with the same set of parameters and the same re type. Which class's increaseSalary method is to be executed is determined by ___. a. the hierarchy of the classes b. the variable's type. c. the actual object type. d. it is not possible to determine which method is executed. Which of the following statements about comparing objects is correct? a. The equals method and the == operator are perform the same actions. b. The == operator is used to compare whether two objects have the same contents. c. The equals method is used to compare whether two references are to the same object. d. The equals method is used to compare whether two objects have the same contents.Explanation / Answer
19)Ans)a
Reason:
When we create the sub class object (Motorcycle) based on the parameters the corresponding the Sub class (Motorcycle) Constructor will be called.Immediately before executing the line of the Sub class constructor ,the default constructor of the Super class(Vehicle) will be called.After executing the super class constructor,the contents inside the sub class constructor will be called.
20)Ans)a
Reason:
If we created an object to the sub class(Programmer).If we call the method (increaseSalary()) on the sub class.First the controller will check whether the method (increaseSalary()) is available in the sub class.If the method is available it will be executed.if the method is not found.Then the controller will check whether the method (increaseSalary()) is available in the super class.if available it will be executed.
21)Ans)d
Reason:
The two objects are said to be equal if an only if all the contents of both the the objects are same.If any one is not same ,then those two objects are not equal.
______________Thank You
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.