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:

Interior Designer

A professional who plans, researches, coordinates, and manages the enhancement of interior spaces to achieve aesthetically pleasing environments.

Market Maven

An individual recognized for their knowledge about the marketplace, including where to get products at the best prices, and who influences others with their recommendations.

Opinion Leader

An individual who has the ability to influence public opinions, attitudes, and behaviors due to their expertise, social standing, or other characteristics.

Innovator

A person or organization that introduces new ideas, products, or methods, often driving change and progress within a market or industry.

Related Questions