Fix errors to get the desired output. You have to use both "class student" and "class q2". You should NOT modify or remove statement in "class student", but you can ADD statement(s) if necessary....

Fix errors to get the desired output. You have to use both "class student" and "class q2".
You should NOT modify or remove statement in "class student", but you can ADD statement(s) if necessary.


class student {


private int id;


private String name;


private String gender;






student(int id, String name, String gender){


this.id=id;


this.name=name;


this.gender=gender;


}


}


public class q2 {


public static void main(String args[]) {


ArrayList myArray = new ArrayList<>();


String[] name= {"kim", "Emily", "Bill", "Ed"};


String[] gender= {"f", "f", "m", "m"};






for(int i=0; i



student s = new student();


myArray.add(s);


}






for (int i = 0; i



System.out.println(myArray.id + " " + myArray.name + " " + myArray.gender);


}


}


}




// desired output


0 kim f


1 Emily f


2 Bill m


3 Ed m
-----------------------------
Write a java program to produce fruit information. There are three fruits (Apple, Orange, Mango). Seed and color of each fruit can be printed by the program. The following code shows sample codes in your main and its output.


Requirement: one super abstract class with two abstract methods, three sub classes, and one main program. Do not ask user to choose a fruit.




sample code in your main


apple.seed();


orange.color();


mango.seed();




sample output


Apple has seed.


Color of Orange is orange.


Mango has seed.


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


Nov 02, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here