You have files Dessert.java, BlueberryMuffin.java, and a dri…

You have files Dessert.java, BlueberryMuffin.java, and a driver class named Driver.java. Fill in the correct visibility modifiers so that the comments in the class BlueberryMuffin and Driver’s main method are upheld. public class Dessert {   1 void eat() { /*compiles*/ }   2 void split() { /*compiles*/ }   3 void purchase() { /*compiles*/ } } —– in a separate file in a different package/directory —– public class BlueberryMuffin extends Dessert {   public void nom() { split(); // doesn’t compile purchase(); // compiles }} —– in a separate file in a different package/directory —– public class Driver { public static void main(String[] args) {        BlueberryMuffin b = new BlueberryMuffin();        b.eat(); // compiles        b.split(); // doesn’t compile        b.purchase(); // doesn’t compile }}   1   : [1]  2   : [2]  3   : [3]

public class Game {   public Game() { System.out.println(“…

public class Game {   public Game() { System.out.println(“GAME”); }}public class BoardGame extends Game {   public BoardGame () { System.out.println(“BOARDGAME”); }}public class Chess extends BoardGame {   public Chess () { super(); System.out.println(“CHESS”); }} Given the class definitions above, what is printed to the console when the following lines of code are executed? Assume the code compiles and runs (i.e. ignore typos). BoardGame p = new BoardGame();Chess c = new Chess();

   Noodle n1 = new Pasta(); Noodle n2 = new Ramen(); Pasta p…

   Noodle n1 = new Pasta(); Noodle n2 = new Ramen(); Pasta p = new Pasta(); Ramen r = new Ramen();  For the class hierarchy and declarations above, correctly indicate whether each of the following statements will compile and what will happen at runtime (runs correctly or runtime exception). It may be helpful to use scratch paper to keep track of each variable’s static and dynamic type. 1  Noodle noodle = (Noodle) r; 2   Ramen r1 = (Ramen) n1;  3  Ramen r2 = (Ramen) p; 4  Ramen r3 = (Ramen) n2;   1   : [1]  2   : [2]  3   : [3]  4   : [4]

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]