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 ------------------------------------------------ ------------------------------------------------ } }
(
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
------------------------------------------------
------------------------------------------------
}
}
Step by step
Solved in 2 steps