Question
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),
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 |
Note: Inside the main method, write a line to greet the user by printing a message that has your name on it. Example: Hello! My name is ali turki . If you do not do this you will get ZERO.
Post a copy of your complete code inside the box below:
Post a screen-shot of the codes output inside the box below:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started