Fill in the blanks to implement the toString method. public class Dorm { private String roomNumber; private int numResidents; private double area; public 1 toString( 2 ) { 3 }} 1 : 2 : 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: int a = new Integer(5); // 1 occursInteger b = a; // 2 occurs 1 : 2 :
Avatar a1 = new Earth(); Avatar a2 = new Fire(); Earth e…
Avatar a1 = new Earth(); Avatar a2 = new Fire(); Earth e = new Earth(); Fire f = new Fire(); 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 Avatar avatar = (Avatar) f; 2 Fire f1 = (Fire) a1; 3 Fire f2 = (Fire) a2; 4 Fire f3 = (Fire) e; 1 : 2 : 3 : 4 :
Fill in the blanks to implement the toString method. public…
Fill in the blanks to implement the toString method. public class Dorm { private String roomNumber; private int numResidents; private double area; public 1 toString( 2 ) { 3 }} 1 : 2 : 3 :
Avatar a1 = new Earth(); Avatar a2 = new Fire(); Earth e…
Avatar a1 = new Earth(); Avatar a2 = new Fire(); Earth e = new Earth(); Fire f = new Fire(); 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 Avatar avatar = (Avatar) f; 2 Fire f1 = (Fire) a1; 3 Fire f2 = (Fire) a2; 4 Fire f3 = (Fire) e; 1 : 2 : 3 : 4 :
Given the following class hierarchy, identify whether the me…
Given the following class hierarchy, identify whether the method scare is overloaded, overridden, or neither by the subclass: public class Spooky { public void scare(int i, boolean b) { /* implemented */ }}public class Ghost extends Spooky { public void scare(int num, boolean fright) { /* implemented */ }}
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: Integer a = 15; // 1 occurs int b = a; // 2 occurs 1 : 2 :
public class Bread { public Bread() { System.out.println…
public class Bread { public Bread() { System.out.println(“BREAD”); }}public class Toast extends Bread { public Toast() { System.out.println(“TOAST”); }}public class AvocadoToast extends Toast { public AvocadoToast() { super(); System.out.println(“AVO”); }} 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). Toast t = new Toast();AvocadoToast a = new AvocadoToast();
Given the following class hierarchy, identify whether the me…
Given the following class hierarchy, identify whether the method foo is overloaded, overridden, or neither by the subclass: public class Parent { public void foo(int i, String s) { /* implemented */ }}public class Child extends Parent { public void foo(int i) { /* implemented */ }}
public class Bread { public Bread() { System.out.println…
public class Bread { public Bread() { System.out.println(“BREAD”); }}public class Toast extends Bread { public Toast() { System.out.println(“TOAST”); }}public class AvocadoToast extends Toast { public AvocadoToast() { super(); System.out.println(“AVO”); }} 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). Toast t = new Toast();AvocadoToast a = new AvocadoToast();