For the given classes, Machine, Camera and Oven. Camera and Oven are subclasses of Machine. A) Override the toString in Machine so it returns the Machine partNumber. B) Create an array list of Machine and  C)add the following objects to the array list. public class Machine {      protected String serialNumber; // A) Override the toString method      ------------------------------------------------------      ------------------------------------------------------      ------------------------------------------------------      } } public class Camera extends Machine{ } public class Oven extends Machine{ } public class Test {     public static void main (String[] args){         Camera c1 = new Camera();         Oven o1 = new Oven();         // B) Create the array list of Machine         ------------------------------------------------         // C) Add the objects c1 and o1 to the array list         ------------------------------------------------         ------------------------------------------------     } }

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter12: Points, Classes, Virtual Functions And Abstract Classes
Section: Chapter Questions
Problem 33SA
icon
Related questions
Question

(programming)

 

For the given classes, Machine, Camera and Oven. Camera and Oven are subclasses of Machine. A) Override the toString in Machine so it returns the Machine partNumber. B) Create an array list of Machine and  C)add the following objects to the array list.

public class Machine {

     protected String serialNumber;

// A) Override the toString method

     ------------------------------------------------------

     ------------------------------------------------------

     ------------------------------------------------------

     }

}

public class Camera extends Machine{

}

public class Oven extends Machine{

}

public class Test {

    public static void main (String[] args){

        Camera c1 = new Camera();

        Oven o1 = new Oven();

        // B) Create the array list of Machine

        ------------------------------------------------

        // C) Add the objects c1 and o1 to the array list

        ------------------------------------------------

        ------------------------------------------------

    }

}

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning