Question: Question 1 Consider the following code snippet: anEmployee = new Programmer()anEmployee.increaseSalary(2500)If the Programmer class inherits from the Employee class, and both classes have an implementation
Question 1
Consider the following code snippet:
anEmployee = new Programmer()anEmployee.increaseSalary(2500)If the Programmer class inherits from the Employee class, and both classes have an implementation of the increaseSalary method with the same set of parameters, which statement is correct?
Question options:
An additional line of code must be added to the snippet shown previously to specify which method will execute.
It is not possible to determine which class's method will be executed without seeing the complete class definitions.
The increaseSalary method of the Employee class will be executed.
The increaseSalary method of the Programmer class will be executed.
Question 2
Which of the following statements is true? Question options:
A method that is overridden in a subclass can perform a task that is totally different from the task performed by the same method in the superclass.
A method that is overridden in a subclass cannot invoke the method in the superclass with the same name.
A method that is overridden in a subclass must extend the functionality of the superclass by invoking the superclass method.
Every method in a subclass must override a superclass method.
Question 3
If a class has an abstract method, which of the following statements is NOT true?
Question options:
You cannot inherit from this class.
You cannot construct an object from this class.
You can construct an object from this class.
All non-abstract subclasses of this class must implement this method.
Question 4
Which of the following statements about abstract methods is true?
Question options:
An abstract method has a name and parameters, but its implementation is not specified.
An abstract method has parameters and is fully implemented, but it has no defined name.
An abstract method has a name and is fully implemented, but it has no parameters.
An abstract method has only a name, but it implementation is not specified and it has no parameters.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
