Question: trace the following program and correct the error and then write it correctly and write its output String[] fruits = new String[3]; fruits[0] = Mango;

trace the following program and correct the error and then write ittrace the following program and correct the error and then write it correctly and write its output

correctly and write its output String[] fruits = new String[3]; fruits[0] =

String[] fruits = new String[3]; fruits[0] = "Mango"; fruits[1] = "Apple"; fruits[2] = "Strawberry"; fruits[3] = "Watermelon"; System.out.println(fruits[1]); ArrayList fruitList = new ArrayList[]; fruitList.add("Mango"); fruitList.add("Apple"); fruitList.add("Strawberry"); fruitList.add("Watermelon"); fruitList.remove("Strawberry"); System.out.println(fruitList.contains("Raspberry")); System.out.println(fruitList); } } public static void main(String[] args) { Animal animal; Animal animali = new Dog[]; animal1.eat[]; animali.run(); }} abstract class Animal { public void run() { System.out.println("Animal is running"); } abstract public void eat(); } class Dog extends Animal { public void eat() { System.out.println("Dog is eating"); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!