Computer Programming-2 (CS2301) Constructor Method Overloading Lab Session-#02
Q3. Write a program
Define class Continent that has two instance variables name and numberOfCountries. Define three overloaded constructor methods: no-argument constructor (receives no name and no numberOfCountries), one-argument constructor (receives only name) and two-argument constructor (receives name and numberOfCountries). Additionally, define all sets and gets methods. In the main method, define three objects of class Continent and test the three constructors and print all information of the continent that has largest number of countries. The number of countries in each continent is shown in the following table.
Continent Number of countries
1 Asia 50
2 Africa 54
3 North America 23
4 South America 12
5 Antarctica 0
6 Europe 51
7 Autralia 14