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:

Medical Advances

Innovations and improvements in medical science that lead to better diagnosis, treatment, and prevention of diseases.

Critical Point

In physical sciences, the condition under which a substance's properties change from one state to another, e.g., liquid to gas; in discussions, a pivotal moment that determines direction or outcome.

Delirium

An acute, usually reversible, mental disturbance characterized by confusion, disordered speech and hallucinations.

Terminally Ill

Describes a condition in which a disease is deemed incurable or untreatable and is expected to result in the death of the patient.

Related Questions