Explore topic-wise MCQs in Java Programming.

This section includes 7 Mcqs, each offering curated multiple-choice questions to sharpen your Java Programming knowledge and support exam preparation. Choose a topic below to get started.

1.

What is the output of this program?
import java.util.*;
public class LOCALE_CLASS_Example
{
public static void main(String args[])
{
Locale object = new Locale("HINDI", "INDIA") ;
System.out.print(object.getDisplayLanguage());
}
}

A. India
B. Hindi
C. English
D. HINDI
E. None of these
Answer» C. English
2.

What is the output of this program?
import java.util.*;
public class LOCALE_CLASS_Example
{
public static void main(String args[])
{
Locale object = new Locale("ENGLISH") ;
System.out.print(object.getDisplayLanguage());
}
}

A. ENGLISH
B. Compilation Error
C. Runtime Error
D. english
E. None of these
Answer» E. None of these
3.

What is the output of this program?
import java.util.*;
public class LOCALE_CLASS_Example
{
public static void main(String args[])
{
Locale object = new Locale("English", "USA") ;
System.out.print(object.getCountry());
}
}

A. India
B. USA
C. Compilation Error
D. Runtime Error
E. None of these
Answer» C. Compilation Error
4.

What would be the output of following code snippet?
int ran = random.nextInt(10) + 2;

A. Random number between 4 to 10, excluding 4 and 10
B. Random number between 2 to 11, including 2 and 11
C. Random number between 2 to 11, excluding 2 and 11
D. Random number between 2 to 10, including 2 and 10
E. None of these
Answer» C. Random number between 2 to 11, excluding 2 and 11
5.

What would be the output of following code snippet?
int ran = random.nextInt(10) + 1;

A. Random number between 1 to 10, excluding 10
B. Random number between 1 to 10, excluding 1 and 10
C. Random number between 1 to 10, including 1 and 10
D. Random number between 1 to 10, excluding 1
E. None of these
Answer» D. Random number between 1 to 10, excluding 1
6.

What is the output of this program?
 import java.util.*;
public class LOCALE_CLASS_Example
{
public static void main(String args[])
{
Locale object = new Locale("ENGLAND") ;
System.out.print(object.getCountry());
}
}

A. INDIA
B. ENGLAND
C. Runtime Error
D. Compilation Error
E. Nothing is displayed
Answer» E. Nothing is displayed
7.

What would be the output of following code snippet?

A. Random number between 1 to 10, excluding 10
B. Random number between 1 to 10, excluding 1 and 10
C. Random number between 1 to 10, including 1 and 10
D. Random number between 1 to 10, excluding 1
E. None of these
Answer» D. Random number between 1 to 10, excluding 1