Limited access

Upgrade to access all content for this subject

A programmer is involved in a project to create a series of robots which are all based on a base robot template. The base robot itself will never be produced. All of the produced robots will have the exact same way of turning on, but each must have its own unique way of walking and talking. The first of these series of robots is called a Monster Robot.

Which of the following would be the BEST programming design for these robots.

A
public class BaseRobot 
{
    // Instance variables and constructor methods not shown

    public void turnOn()
    {  /* implementation not shown */  }

    public void walk()
    {  /* implementation not shown */  }

    public void talk()
    {  /* implementation not shown */  }
}

public class MonsterRobot extends BaseRobot
{
    // Instance variables and constructor methods not shown

    public void turnOn()
    {  /* implementation not shown */  }
}
B
public abstract class BaseRobot 
{
    // Instance variables and constructor methods not shown

    public abstract void turnOn();

    public abstract void walk();

    public abstract void talk();
}

public class MonsterRobot extends BaseRobot
{
    // Instance variables and constructor methods not shown

    public void turnOn()
    {  /* implementation not shown */  }

    public void walk()
    {  /* implementation not shown */  }

    public void talk()
    {  /* implementation not shown */  }
}
C
public abstract class BaseRobot 
{
    // Instance variables and constructor methods not shown

    public void turnOn()
    {  /* implementation not shown */  }

    public abstract void walk();

    public abstract void talk();
}

public class MonsterRobot extends BaseRobot
{
    // Instance variables and constructor methods not shown

    public void walk()
    {  /* implementation not shown */  }

    public void talk()
    {  /* implementation not shown */  }
}
D
public interface BaseRobot 
{
    // Instance variables and constructor methods not shown

    public abstract void turnOn();

    public abstract void walk();

    public abstract void talk();
}

public class MonsterRobot implements BaseRobot 
{
    // Instance variables and constructor methods not shown

    public void turnOn()
    {  /* implementation not shown */  }

    public void walk()
    {  /* implementation not shown */  }

    public void talk()
    {  /* implementation not shown */  }
}
E
public interface BaseRobot 
{
    // Instance variables and constructor methods not shown

    public void turnOn()
    {  /* implementation not shown */  }

    public abstract void walk();

    public abstract void talk();
}

public class MonsterRobot implements BaseRobot 
{
    // Instance variables and constructor methods not shown

    public void walk()
    {  /* implementation not shown */  }

    public void talk()
    {  /* implementation not shown */  }
}
Select an assignment template