Java MCQs on Local & Random classes of Java Programming Language.
1. Which of these class produce objects with respect to geographical locations? Answer: b 2. Which of these methods is not a Locale class? Answer: c 3. Which of these class can generate pseudorandom numbers? Answer: c 4. Which of these method of Locale class can be used to obtain country of operation? Answer: d 5. Which of these is a method can generate a boolean output? Answer: d 6. What will be the output of the following Java program? a) India 7. What will be the output of the following Java program? a) India 8. What will be the output of the following Java program? a) India 9. What will be the output of the following Java program? a) India
a) TimeZone
b) Locale
c) Date
d) SimpleTimeZone
Clarification: The Locale class isinstantiated to produce objects that each describe a geographical or cultural region.
a) UK
b) US
c) INDIA
d) KOREA
Clarification: INDIA is not a Locale class.
a) Locale
b) Rand
c) Random
d) None of the mentioned
Clarification: None.
a) getCountry()
b) whichCountry()
c) DisplayCountry()
d) getDisplayCountry()
Clarification: None.
a) retbool()
b) getBool()
c) nextBool()
d) nextBoolean()
Clarification: None.
import java.util.*;
class LOCALE_CLASS
{
public static void main(String args[])
{
Locale obj = new Locale("INDIA") ;
System.out.print(obj.getCountry());
}
}
b) INDIA
c) Compilation Error
d) Nothing is displayed
Clarification: None.
Output:
$ javac LOCALE_CLASS.java
$ java LOCALE_CLASS
import java.util.*;
class LOCALE_CLASS
{
public static void main(String args[])
{
Locale obj = new Locale("HINDI", "INDIA") ;
System.out.print(obj.getCountry());
}
}
b) INDIA
c) Compilation Error
d) Nothing is displayed
Clarification: None.
Output:
$ javac LOCALE_CLASS.java
$ java LOCALE_CLASS
INDIA
import java.util.*;
class LOCALE_CLASS
{
public static void main(String args[])
{
Locale obj = new Locale("HINDI") ;
System.out.print(obj.getDisplayLanguage());
}
}
b) INDIA
c) HINDI
d) Nothing is displayed
Clarification: None.
Output:
$ javac LOCALE_CLASS.java
$ java LOCALE_CLASS
HINDI
import java.util.*;
class LOCALE_CLASS
{
public static void main(String args[])
{
Locale obj = new Locale("HINDI", "INDIA") ;
System.out.print(obj.getDisplayLanguage());
}
}
b) INDIA
c) HINDI
d) Nothing is displayed
Clarification: None.
Output:
$ javac LOCALE_CLASS.java
$ java LOCALE_CLASS
HINDI