Consider the following class hierarchy: public class Vehicle…

Consider the following class hierarchy: public class Vehicle { private String type; public Vehicle(String type) { this.type = type; } public String displayInfo() { return type; } } public class LandVehicle extends Vehicle { public LandVehicle(String type) { super(type); } } public class Auto extends LandVehicle { public Auto(String type) { super(type); } } You have written a program to use these classes, as shown in the following code snippet: public class VehicleTester { public static void main(String[] args) { Auto myAuto = new Auto(“sedan”); System.out.println(“MyAuto type = ” + ______); } } Complete the code in this program snippet to correctly display the auto’s type.

Select an appropriate expression to complete the following m…

Select an appropriate expression to complete the following method, which is designed to return the number of elements in the parameter array numbers.  If a value appears more than once, it should be counted exactly once. public static int countElementsOnce(int[] numbers) { Set values = new HashSet(); for (int num: numbers) { values.add(num); } ______________________ }

Consider the following class hierarchy: public class Vehicle…

Consider the following class hierarchy: public class Vehicle { private String type; public Vehicle(String type) { this.type = type; } public String displayInfo() { return type; } } public class LandVehicle extends Vehicle { public LandVehicle(String type) { super(type); } } public class Auto extends LandVehicle { public Auto(String type) { super(type); } } You have written a program to use these classes, as shown in the following code snippet: public class VehicleTester { public static void main(String[] args) { Auto myAuto = new Auto(“sedan”); System.out.println(“MyAuto type = ” + ______); } } Complete the code in this program snippet to correctly display the auto’s type.

Suppose the class Value is partially defined below public cl…

Suppose the class Value is partially defined below public class Value { private int number; public int getValue() { return number; } } 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?

Select an appropriate expression to complete the following m…

Select an appropriate expression to complete the following method, which is designed to return the number of elements in the parameter array numbers.  If a value appears more than once, it should be counted exactly once. public static int countElementsOnce(int[] numbers) { Set values = new HashSet(); for (int num: numbers) { values.add(num); } ______________________ }

Assume inputFile is a Scanner object used to read data from…

Assume inputFile is a Scanner object used to read data from a text file that contains a number of lines.  Some lines contain an alphabetic string, while others contain a single integer value.  Select an expression to complete the following code segment, which counts the number of integer values in the input file. int count = 0; while (inputFile.hasNextLine()) { if (________________________________) { count++; } inputFile.nextLine(); } System.out.println(count);