Question: public class Country { private String name; private String capital; private int population; private int gdp; private List countryCities; public Country ( String name, String

public class Country { private String name;
private String capital;
private int population;
private int gdp;
private List countryCities;
public Country (String name, String capital, int population, int gdp, List countryCities){
.
.
}
public static void sortCities(List< String > cityList){
Collections.sort(cityList); }
public bool equals(other){
return this.name.compareTo(other.name) && this.capital.compareTo(other.capital) && this.population == other.population && this.gdp == other.gdp ;
}
// Assume that there are getter methods for instance variables. }
a. GivenalistofcitiesListcityList={Sacramento,Chicago,Detroit, Portland, Atlanta}, give the output for each of the following code snippets.
1. Country.sort(cityList); for(String x : cityList)
System.out.printf(x);
a. AtlantaChicagoDetroitPortlandSacramento
2. Country.sort(USA.getCityList()); for(String x : USA.getCityList())
System.out.printf(x);
a. AtlantaChicagoDetroitPortlandSacramento
3. USA.sort(USA.getCityList()); for(String x : USA.getCityList())
System.out.printf(x);
a. AtlantaChicagoDetroitPortlandSacramento
b. Wont compile
b. Wont compile
b. Wont compile
c. Runtime error
c. Runtime error
c. Runtime error

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 Programming Questions!