Examlex

Solved

Public Abstract Class Car

question 28

Essay

public abstract class Car
{
    private String model;
    public abstract void color();
    public String getModel()
    {
         return model;
     }
    public void setModel(String modelName)
    {
         model = modelName;
     }
}

public class Honda extends Car
{
    public void color()
    {
System.out.println("red");
    }
}

public class Ford extends Car
{
    public void color()
    {
      System.out.println("blue");
    }
}

public class MyCars
{
    public static void main(String[] args)
    {
       Honda myHonda = new Honda();
       Ford myFord = new Ford();
  myHonda.setModel("My Honda is ");
       myFord.setModel("My Ford is ");
  System.out.print(myHonda.getModel());
  myHonda.color();
  System.out.print(myFord.getModel());
  myFord.color();
    }
}
In the above code, the myHonda.getModel() and myHonda.color() method calls produce different output from when the same methods are used with myFord . Explain why this is the case.


Definitions:

Direct Reply Letter

A written communication that responds specifically and directly to a letter or inquiry received.

Previous Correspondence

Written or digital communications, like emails or letters, that occurred between the same parties in the past.

Frontloading

The practice of placing the most important information at the beginning of a communication to ensure it is seen or heard first.

Main Idea

The central or most important theme, point, or argument that a piece of writing, speech, or discussion seeks to convey.

Related Questions