Consider the following declarations: public interface Displ…

Consider the following declarations: public interface Displayable { void display(); } public class Picture implements Displayable { private int size; public void increaseSize() { size++; } public void decreaseSize() { size–; } public void display() { System.out.println(size); } public void display(int value) { System.out.println(value * size); } } What method invocation can be used to complete the code segment below? Displayable picture = new Picture(); picture._________________;

Select an appropriate expression to complete the method belo…

Select an appropriate expression to complete the method below.  The method should return the number of times that the string stored in name appears in theList. public static int count(LinkedList theList, String name) { int number = 0; Iterator iter = theList.iterator(); while (______________________) { if (iter.next().equals(name)) { number++; } } return number; }

Consider the following declarations: public interface Encry…

Consider the following declarations: public interface Encryptable { void encrypt(String key); } public class SecretText implements Encryptable { private String text; _____________________________ { // code to encrypt the text using encryption key goes here } } Which of the following method headers should be used to complete the SecretText class?

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?

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; System.out.print(“Vehicle “); } public String displayInfo() { return type; } } public class LandVehicle extends Vehicle { public LandVehicle(String type) { super(type); System.out.print(“Land “); } } public class Auto extends LandVehicle { public Auto(String type) { super(type); System.out.print(“Auto “); } } When an object of type Auto is constructed, what will be printed by the constructors from this inheritance hierarchy?

Select an appropriate expression to complete the following c…

Select an appropriate expression to complete the following code segment, which is designed to print a message if the string stored in name is part of the players collection. Collection players = new ArrayList(); // code to add elements to the collection here if ______________________________________ { System.out.print(name + ” is one of the players in the collection.”); }

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) { . . . } } public class Auto extends LandVehicle { public Auto(String type) { . . . } public String displayAutoType() { return _____; } } Complete the code in the Auto class method named displayAutoType to return the type data.