Question: 9) Consider the following code snippet: public class Vehicle private String type; public String Vehicle (String type) What is wrong with this code? a) The

 9) Consider the following code snippet: public class Vehicle private String
type; public String Vehicle (String type) What is wrong with this code?
a) The class instance variable type must be initialized when it is

9) Consider the following code snippet: public class Vehicle private String type; public String Vehicle (String type) What is wrong with this code? a) The class instance variable type must be initialized when it is declared. b) The constructor must not have any arguments. c) The constructor must not have a return type declared. d) The constructor's return type must be void. 10) 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. 11) Insert the missing code in the following code fragment. This fragment is intended to call the vehicle class's method. public class Vehicle public void setVehicleClass (double numberAxles) public class Motorcycle extends Vehicle public Motorcycle() a) Motorcyle.setVehicleClass (2.0); b) Vehicle.setVehicleClass (2.0); c) this.setVehicleclass (2.0); d) setVehicleClass (2.0); 12) 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 13) 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. 14) Consider the following code snippet: public class Vehicle public void setVehicleClass (double numberAxles) public class Motorcycle extends Vehicle public void setVehicleclass (double numberAxles) Which of the following statements is correct? a) The Motorcycle class overrides the setVehicleClass method. b) The Vehicle class overrides the set VehicleClass method. c) The Motorcycle class overloads the setVehicleClass method. d) The Vehicle class overloads the set Vehicleclass method. 15) Consider the following code snippet: public class Auto extends Vehicle public Auto (int numberAxles) super (numberixles): 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. 16) Consider the following code snippet: public abstract class Employee public abstract void setsalary(): You wish to create a subclass named Programmer. Which of the following is the correct way to declare this subclass? public clase Programmer implements Employee public void set Salary() {...} // - means actual implementation b) public class Programmer extends Employee void setsalary() ...) public class Programmer implements Employee void setsalary() {...} public class Programmer extends Employee public void setsalary() {...}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!