public abstract class Landmark { public abstract int countVisitors();} Consider the class shown above. Which of the following class definitions will NOT compile?
Blog
Given the following class hierarchy, identify whether the me…
Given the following class hierarchy, identify whether the method operate is overloaded, overridden, or neither by the subclass: public class Doctor { public void operate(int t, String d) { /* implemented */ } } public class Surgeon extends Doctor { public void operate(int time, String date) { /* implemented */ } }
You have files VendingMachine.java, Cola.java, and a driver…
You have files VendingMachine.java, Cola.java, and a driver class named Driver.java. Fill in the correct visibility modifiers so that the comments in the class Cola and Driver’s main method are upheld. public class VendingMachine { 1 void pay() { /*compiles*/ } 2 void shake() { /*compiles*/ } 3 void choose() { /*compiles*/ } } —– in a separate file in a different package/directory —– public class Cola extends VendingMachine { public void cocaCola() { pay(); // doesn’t compile choose(); // compiles }} —– in a separate file in a different package/directory —– public class Driver { public static void main(String[] args) { Cola c = new Cola(); c.pay(); // doesn’t compile c.shake(); // compiles c.choose(); // doesn’t compile }} 1 : [1] 2 : [2] 3 : [3]
public abstract class Athlete { public abstract void compete…
public abstract class Athlete { public abstract void compete();} Consider the class shown above. Which of the following class definitions will NOT compile?
Given the following class hierarchy, identify whether the me…
Given the following class hierarchy, identify whether the method operate is overloaded, overridden, or neither by the subclass: public class Doctor { public void operate(int t, String d) { /* implemented */ } } public class Surgeon extends Doctor { public void operate(int time, String date) { /* implemented */ } }
You have files VendingMachine.java, Cola.java, and a driver…
You have files VendingMachine.java, Cola.java, and a driver class named Driver.java. Fill in the correct visibility modifiers so that the comments in the class Cola and Driver’s main method are upheld. public class VendingMachine { 1 void pay() { /*compiles*/ } 2 void shake() { /*compiles*/ } 3 void choose() { /*compiles*/ } } —– in a separate file in a different package/directory —– public class Cola extends VendingMachine { public void cocaCola() { pay(); // doesn’t compile choose(); // compiles }} —– in a separate file in a different package/directory —– public class Driver { public static void main(String[] args) { Cola c = new Cola(); c.pay(); // doesn’t compile c.shake(); // compiles c.choose(); // doesn’t compile }} 1 : [1] 2 : [2] 3 : [3]
Fill in the blanks to implement the toString method. public…
Fill in the blanks to implement the toString method. public class Dog { private String name; private String owner; private int age; public 1 toString( 2 ) { 3 }} 1 :[1] 2 :[2] 3 :[3]
Fill in the blanks to implement the toString method. public…
Fill in the blanks to implement the toString method. public class Coffee { private String brand; private String[] addOns; private double price; public 1 toString( 2 ) { 3 }} 1 :[1] 2 :[2] 3 :[3]
Analyze the following code and indicate, for each line, whet…
Analyze the following code and indicate, for each line, whether autoboxing, unboxing, or neither occurs when the assignment operator is evaluated: Character c = ‘b’; // 1 occurschar a = c; // 2 occurs 1 : [1] 2 : [2]
Fill in the blanks to implement the toString method. public…
Fill in the blanks to implement the toString method. public class Coffee { private String brand; private String[] addOns; private double price; public 1 toString( 2 ) { 3 }} 1 :[1] 2 :[2] 3 :[3]