This section of our 1000+ Java MCQs focuses on Local & Random classes of Java Programming Language.
1. Which of these class produce objects with respect to geographical locations?
a) TimeZone
b) Locale
c) Date
d) SimpleTimeZone
View Answer
Explanation: The Locale class isinstantiated to produce objects that each describe a geographical or cultural region.
2. Which of these methods is not a Locale class?
a) UK
b) US
c) INDIA
d) KOREA
View Answer
Explanation: INDIA is not a Locale class.
3. Which of these class can generate pseudorandom numbers?
a) Locale
b) Rand
c) Random
d) None of the mentioned
View Answer
Explanation: None.
4. Which of these method of Locale class can be used to obtain country of operation?
a) getCountry()
b) whichCountry()
c) DisplayCountry()
d) getDisplayCountry()
View Answer
Explanation: None.
5. Which of these is a method can generate a boolean output?
a) retbool()
b) getBool()
c) nextBool()
d) nextBoolean()
View Answer
Explanation: None.
6. What will be the output of the following Java program?
import java.util.*;
class LOCALE_CLASS
{
public static void main(String args[])
{
Locale obj = new Locale("INDIA") ;
System.out.print(obj.getCountry());
}
}
a) India
b) INDIA
c) Compilation Error
d) Nothing is displayed
View Answer
Explanation: None.
Output:
$ javac LOCALE_CLASS.java
$ java LOCALE_CLASS
7. What will be the output of the following Java program?
import java.util.*;
class LOCALE_CLASS
{
public static void main(String args[])
{
Locale obj = new Locale("HINDI", "INDIA") ;
System.out.print(obj.getCountry());
}
}
a) India
b) INDIA
c) Compilation Error
d) Nothing is displayed
View Answer
Explanation: None.
Output:
$ javac LOCALE_CLASS.java
$ java LOCALE_CLASS
INDIA
8. What will be the output of the following Java program?
import java.util.*;
class LOCALE_CLASS
{
public static void main(String args[])
{
Locale obj = new Locale("HINDI") ;
System.out.print(obj.getDisplayLanguage());
}
}
a) India
b) INDIA
c) HINDI
d) Nothing is displayed
View Answer
Explanation: None.
Output:
$ javac LOCALE_CLASS.java
$ java LOCALE_CLASS
HINDI
9. What will be the output of the following Java program?
import java.util.*;
class LOCALE_CLASS
{
public static void main(String args[])
{
Locale obj = new Locale("HINDI", "INDIA") ;
System.out.print(obj.getDisplayLanguage());
}
}
a) India
b) INDIA
c) HINDI
d) Nothing is displayed
View Answer
Explanation: None.
Output:
$ javac LOCALE_CLASS.java
$ java LOCALE_CLASS
HINDI
Sanfoundry Global Education & Learning Series Java Programming Language.
If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]
- Check Programming Books
- Check Java Books
- Apply for Computer Science Internship
- Practice BCA MCQs
- Practice Programming MCQs