GradePack

    • Home
    • Blog
Skip to content
bg
bg
bg
bg

GradePack

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: char c = new Character(‘b’); //  1   occursCharacter a = c; //  2   occurs   1   : [1]   2   : [2]

Read Details

Car c1 = new Ford();Car c2 = new Honda();Ford f = new Ford()…

Car c1 = new Ford();Car c2 = new Honda();Ford f = new Ford();Honda h = new Honda(); 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  Car carA = (Car) f; 2   Ford fordA = (Ford) c1; 3  Ford fordB = (Ford) c2; 4  Ford fordC = (Ford) h;   1   : [1]  2   : [2]  3   : [3]  4   : [4]

Read Details

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: char c = new Character(‘b’); //  1   occursCharacter a = c; //  2   occurs   1   : [1]   2   : [2]

Read Details

You have files Parent.java, Child.java, and a driver class n…

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

Read Details

Car c1 = new Ford();Car c2 = new Honda();Ford f = new Ford()…

Car c1 = new Ford();Car c2 = new Honda();Ford f = new Ford();Honda h = new Honda(); 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  Car carA = (Car) f; 2   Ford fordA = (Ford) c1; 3  Ford fordB = (Ford) c2; 4  Ford fordC = (Ford) h;   1   : [1]  2   : [2]  3   : [3]  4   : [4]

Read Details

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   : [1]   2   : [2]

Read Details

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  :[1]   2  :[2]   3  :[3]

Read Details

   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   : [1]  2   : [2]  3   : [3]  4   : [4]

Read Details

You have files Parent.java, Child.java, and a driver class n…

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

Read Details

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 */ }}

Read Details

Posts pagination

Newer posts 1 … 80,471 80,472 80,473 80,474 80,475 … 82,643 Older posts

GradePack

  • Privacy Policy
  • Terms of Service
Top