Declare a class called country that contains a function called language that prints "English" Define 3 classes and they all inherit from country A brand named Australia A class named Saudi Rewrite the language function and change the implementation of the function so that it prints "Arabic" A class called Spain Rewrite the language function and change the implementation of the function so that it prints "Spanish" Build a Test class to test the code with the Main function and then create objects of the three classes that Workshop of the father's class Then call the language function The result should be as in the picture English Arabic Spanish
IN JAV
1. Declare a class called country that contains a function called language that prints "English"
Define 3 classes and they all inherit from country
A brand named Australia
A class named Saudi Rewrite the language function and change the implementation of the function so that it prints "Arabic"
A class called Spain Rewrite the language function and change the implementation of the function so that it prints "Spanish"
Build a Test class to test the code with the Main function and then create objects of the three classes that
Workshop of the father's class
Then call the language function
The result should be as in the picture
English
Arabic
Spanish
import java.util.*;
public class country
{
public static void main(String[] args)
{
// Creating a new Locale
Locale language1 = new Locale("English", "Australia");
Locale language2 = new Locale("Arabic", "Saudi");
Locale language3 = new Locale("Spanish", "Spain");
// Use of getDefault() :
Locale language2 = Locale.getDefault();
System.out.println("Locale name : " + language1);
System.out.println("Locale name Default : " + language2);
// Use of getDisplayCountry() :
System.out.println("\nCountry Name : "
+ language1.getDisplayCountry());
// Use of getAvailableLocales()
Locale[] language4 = Locale.getAvailableLocales();
System.out.println("\nInstalled locales are : ");
for (int i = 1; i < language4.length/10; i++)
System.out.println(i + ":" + language4[i]);
// Use of getDisplayLanguage() :
System.out.println("\nlanguage2 Language : "
+ language2.getDisplayLanguage());
// Use of getDisplayLanguage(Locale in) :
System.out.println("Language of in Locale : "
+ language1.getDisplayLanguage(new Locale("France", "French")));
// Use of getDisplayName :
System.out.println("\nUse of getDisplayName : "
+ language1.getDisplayName());
// Use of getDisplayName(Locale in) :
System.out.println("Name of in Locale : "
+ language2.getDisplayName(new Locale("English", "english")));
}
}
Step by step
Solved in 2 steps with 1 images