Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Find the error in each of the following code segments: // Superclass public clas

ID: 3534107 • Letter: F

Question


Find the error in each of the following code segments:

// Superclass
public class Vehicle
{
        ( Member declarations . . .)
}

// Subclass
public class Car expands Vehicle
{
         ( Member declarations . . .)
}

Describe errors with a couple of sentences of words.



Find the error in each of the following code segments:

// Superclass
public class Vehicle
{
      private double cost;
      ( Other methods . . .)
}

// Subclass
public class Car extends Vehicle
{
      public Car( double c)
      {
           cost = c;
      }
}

Describe errors with a couple of sentences of words.



Find the error in each of the following code segments:

// Superclass
public class Vehicle
{
     private double cost;
     public Vehicle( double c)
     {
          cost = c;
     }
     ( Other methods . . .)
}

// Subclass
public class Car extends Vehicle
{
     private int passengers;
     public Car( int p)
     {
          passengers = c;
     }
     ( Other methods . . .)
}

Describe errors with a couple of sentences of words.

Explanation / Answer

1.

public class Car expands Vehicle it should be extends
{
         ( Member declarations . . .)
}

2.

public class Car extends Vehicle
{
      public Car( double c)
      {
           cost = c; // cost is private variable of super class which can not be used in subclass
      }
}

3.

public class Car extends Vehicle
{
     private int passengers;
     public Car( int p)
     {
          passengers = c; // c is an undeclraed variable in class Car
     }
     ( Other methods . . .)
}


Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote