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 sortCitiesList String cityList
Collections.sortcityList;
public bool equalsother
return this.name.compareToothername && this.capital.compareToothercapital && this.population other.population && this.gdp other.gdp ;
Assume that there are getter methods for instance variables.
a GivenalistofcitiesListcityListSacramentoChicago,Detroit, Portland, Atlanta give the output for each of the following code snippets.
Country.sortcityList; forString x : cityList
System.out.printfx;
a AtlantaChicagoDetroitPortlandSacramento
Country.sortUSAgetCityList; forString x : USA.getCityList
System.out.printfx;
a AtlantaChicagoDetroitPortlandSacramento
USA.sortUSAgetCityList; forString x : USA.getCityList
System.out.printfx;
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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
