Question: The code below shows some of the text for a class called City. Now write a complete public constructor, which takes a String parameter called

The code below shows some of the text for a class called City. Now write a complete public constructor, which takes a String parameter called cityName. Your code should initialize the name attribute of the City class to the value of cityName. It should initialize the population attribute to a value of -1. (Presumably the class has a setPopulation method that will be used to set the city's population after the object has been constructed).

public class City { private String name; private int population;

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!