GradePack

    • Home
    • Blog
Skip to content
bg
bg
bg
bg

GradePack

public class SportsEquipment {      public SportsEquipment (…

public class SportsEquipment {      public SportsEquipment () {          System.out.println(“SPORTS”);      } } public class Ball extends SportsEquipment {     public Ball() {     super();         System.out.println(“BALL”);      } } public class BasketBall extends Ball {     public BasketBall () {         System.out.println(“BASKETBALL”);      } }  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). Ball b = new Ball(); BasketBall bb = new BasketBall(); 

Read Details

public abstract class Airline {     public abstract long sel…

public abstract class Airline {     public abstract long sellPlane(); }  Consider the class shown above. Which of the following class definitions will NOT compile? 

Read Details

Given the following class hierarchy, identify whether the me…

Given the following class hierarchy, identify whether the method eat is overloaded, overridden, or neither by the subclass:  public class Animal {   public void eat(String food) { /* implemented */ } } public class Dog extends Animal{   public void eat(String food, int quantity) { /* implemented */ } } 

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(); // compiles method3(); // doesn’t compile }} —– 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(); // compiles c.method3(); // 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 Novel {     private String genre;     private String title;     private int pages;    public 1 toString( 2 ) {       3    }}   1  :[1]   2  :[2]   3  :[3]

Read Details

   Anatomy a1 = new Histology(); Anatomy a2 = new Cytology()…

   Anatomy a1 = new Histology(); Anatomy a2 = new Cytology(); Histology histo = new Histology(); Cytology cyto = new Cytology();  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  Anatomy anatomy = (Anatomy) cyto;  2   Cytology c1 = (Cytology) histo;  3  Cytology c2 = (Cytology) a1; 4  Cytology c3 = (Cytology) a2;   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(); // compiles method3(); // doesn’t compile }} —– 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(); // compiles c.method3(); // doesn’t compile }}   1   : [1]  2   : [2]  3   : [3]

Read Details

                . ‘  .           ‘ .( ‘.) ‘     _   (‘-.)’…

                . ‘  .           ‘ .( ‘.) ‘     _   (‘-.)’ (`’.) ‘     | (- -(. HIERARCHIES -) ‘  .–`+’-.  .  (‘ -,).(‘) .  |`—-‘|   (‘ .) – (‘. )  | /..\ |    . (‘ `.  )   |\./\.\|      ` .  `   |./G \/|  |.\ T/.|  `-._/.-‘

Read Details

Given 3 classes (Book, Library, and BookStore), Book can in…

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

Read Details

Given 3 classes (YellowJacket, FlyingWasp, and StingingWasp)…

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

Read Details

Posts pagination

Newer posts 1 … 65,551 65,552 65,553 65,554 65,555 … 67,718 Older posts

GradePack

  • Privacy Policy
  • Terms of Service
Top