Question: Using Java eclipse 3 Assume the existence of a class called Voter which defines two instance variables: private String name: private char party: I1 'D'

Using Java eclipse Using Java eclipse 3 Assume the existence of a class called Voter

3 Assume the existence of a class called Voter which defines two instance variables: private String name: private char party: I1 'D' for Democrat or 'R' for Republican Assume that this class implements these two methods: public char getParty () public String tostring) // name and party affiliation Add 10 user to the ArrayList. Now assume you're in the main method in another class called VoterDriver. a) Write a Java statement that instantiates an ArrayList of voter objects called voterS. b) Given the constructor interface, public Voter (String name, char party), write a Java statement that appends (to voters) one Voter, whose name and party are "Leibowitz" and 'D', respectively. Use an anonymous object. Using a standard for loop, write a code fragment that searches the array for Democrats only and prints each Democrat's information on a separate line. c)

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!