GradePack

    • Home
    • Blog
Skip to content
bg
bg
bg
bg

GradePack

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();

Read Details

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

Read Details

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

Fill in the blanks to implement the toString method. public class Restaurant {    private String name;    private String cuisine;    private double rating;    public 1 toString( 2 ) {       3    }}   1  :[1]   2  :[2]   3  :[3]

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

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();

Read Details

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

Fill in the blanks to implement the toString method. public class Restaurant {    private String name;    private String cuisine;    private double rating;    public 1 toString( 2 ) {       3    }}   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 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 */ }}

Read Details

public class Genre {   public Genre() { System.out.println…

public class Genre {   public Genre() { System.out.println(“GENRE”); }}public class MusicGenre extends Genre {   public MusicGenre() { System.out.println(“MUSIC”); }}public class Rock extends MusicGenre {   public Rock () { super(); System.out.println(“ROCK”); }} 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). MusicGenre g = new MusicGenre();Rock s = new Rock();

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: Boolean b = true; //  1   occursboolean a = b; //  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 Flag {    private double height;    private double width;    private String color;    public 1 toString( 2 ) {       3    }}   1  :[1]   2  :[2]   3  :[3]

Read Details

Posts pagination

Newer posts 1 … 80,476 80,477 80,478 80,479 80,480 … 82,647 Older posts

GradePack

  • Privacy Policy
  • Terms of Service
Top