GradePack

    • Home
    • Blog
Skip to content
bg
bg
bg
bg

GradePack

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]

Read Details

Fill in the blanks to implement the toString method. public…

Fill in the blanks to implement the toString method. public class Flag {    private double height;    private double width;    private String color;    public 1 toString( 2 ) {       3    }}   1  :[1]   2  :[2]   3  :[3]

Read Details

public abstract class Dessert { public abstract void eat();…

public abstract class Dessert { public abstract void eat(); }  Consider the class shown above. Which of the following class definitions will NOT compile? 

Read Details

public abstract class Dessert { public abstract void eat();…

public abstract class Dessert { public abstract void eat(); }  Consider the class shown above. Which of the following class definitions will NOT compile? 

Read Details

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]

Read Details

public abstract class Landmark { public abstract int countVi…

public abstract class Landmark { public abstract int countVisitors();} Consider the class shown above. Which of the following class definitions will NOT compile?

Read Details

Given 3 classes (Tulip, Flower, and Plant), Tulip can inher…

Given 3 classes (Tulip, Flower, and Plant), Tulip can inherit from both Flower and Plant with the following syntax: public class Tulip extends Flower, Plant { /* valid class definition */}

Read Details

   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]

Read Details

public abstract class Landmark { public abstract int countVi…

public abstract class Landmark { public abstract int countVisitors();} Consider the class shown above. Which of the following class definitions will NOT compile?

Read Details

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]

Read Details

Posts pagination

Newer posts 1 … 65,549 65,550 65,551 65,552 65,553 … 67,719 Older posts

GradePack

  • Privacy Policy
  • Terms of Service
Top