An Example Of OOP Concept | Java Programs

Output:

*** Class And Object Example ***

Country Information: 
Name:          Pakistan
Provinces:     4
Population(m): 193.2

Click Here For Java Online Compiler

Solution:

/**
 *
 * @author Alee Ahmed Kolachi
 */
class Country {

    String name;
    int provinces;
    float population;

    public static void main(String[] args) {
        Country country1 = new Country();
        country1.name = "Pakistan";
        country1.provinces = 4;
        country1.population = 193.2f; //in millions
        System.out.println("*** Class And Object Example ***" + "\n");
        System.out.println("Country Information: ");
        System.out.println("Name:          " + country1.name);
        System.out.println("Provinces:     " + country1.provinces);
        System.out.println("Population(m): " + country1.population);
    }
}
Share This :

Related Post



sentiment_satisfied Emoticon