250+ TOP MCQs on Locale & Random Classes and Answers

Java MCQs 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

Answer: b
Clarification: 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

Answer: c
Clarification: 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

Answer: c
Clarification: 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()

Answer: d
Clarification: None.

5. Which of these is a method can generate a boolean output?
a) retbool()
b) getBool()
c) nextBool()
d) nextBoolean()

Answer: d
Clarification: None.

6. What will be the output of the following Java program?

  1.     import java.util.*;
  2.     class LOCALE_CLASS
  3.     {
  4.         public static void main(String args[])
  5.         {
  6.             Locale obj = new Locale("INDIA") ;
  7.             System.out.print(obj.getCountry());
  8.         }
  9.     }

a) India
b) INDIA
c) Compilation Error
d) Nothing is displayed

Answer: d
Clarification: None.
Output:

$ javac LOCALE_CLASS.java
$ java LOCALE_CLASS

7. What will be the output of the following Java program?

  1.     import java.util.*;
  2.     class LOCALE_CLASS
  3.     {
  4.         public static void main(String args[])
  5.         {
  6.             Locale obj = new Locale("HINDI", "INDIA") ;
  7.             System.out.print(obj.getCountry());
  8.         }
  9.     }

a) India
b) INDIA
c) Compilation Error
d) Nothing is displayed

Answer: b
Clarification: None.
Output:

$ javac LOCALE_CLASS.java
$ java LOCALE_CLASS
INDIA

8. What will be the output of the following Java program?

  1.     import java.util.*;
  2.     class LOCALE_CLASS
  3.     {
  4.         public static void main(String args[])
  5.         {
  6.             Locale obj = new Locale("HINDI") ;
  7.             System.out.print(obj.getDisplayLanguage());
  8.         }
  9.     }

a) India
b) INDIA
c) HINDI
d) Nothing is displayed

Answer: c
Clarification: None.
Output:

$ javac LOCALE_CLASS.java
$ java LOCALE_CLASS
HINDI

9. What will be the output of the following Java program?

  1.     import java.util.*;
  2.     class LOCALE_CLASS
  3.     {
  4.         public static void main(String args[])
  5.         {
  6.             Locale obj = new Locale("HINDI", "INDIA") ;
  7.             System.out.print(obj.getDisplayLanguage());
  8.         }
  9.     }

a) India
b) INDIA
c) HINDI
d) Nothing is displayed

Answer: c
Clarification: None.
Output:

$ javac LOCALE_CLASS.java
$ java LOCALE_CLASS
HINDI

Leave a Reply

Your email address will not be published. Required fields are marked *