Vidyalelo
Java Programming · all questions

Data Types and Variables
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

127

Questions

6/7

Page

Pick an option on a question to see the right answer and solution.

What will be the output of the following Java program?
class variable_scope 
{
    public static void main(String args[]) 
    {
        int x;
        x = 5;
        {
      int y = 6;
      System.out.print(x + " " + y);
        }
        System.out.println(x + " " + y);
    } 
}

Select an option to see the answer and solution.

What does LocalTime represent?

Select an option to see the answer and solution.

What will be the output of the following Java program?
class mainclass {
    public static void main(String args[]) 
    {
        char a = 'A';
        a++;
  System.out.print((int)a);
    } 
}

Select an option to see the answer and solution.

What will be the output of the following Java code snippet?
public class AddDemo 
{
	public static void main(String args[]) 
        {
		BigDecimal b = new BigDecimal("23.43");
		BigDecimal br = new BigDecimal("24");
		BigDecimal bres = b.add(new BigDecimal("450.23"));
		System.out.println("Add: "+bres);
 
		MathContext mc = new MathContext(2, RoundingMode.DOWN);
		BigDecimal bdecMath = b.add(new BigDecimal("450.23"), mc);
		System.out.println("Add using MathContext: "+bdecMath);
	}
}

Select an option to see the answer and solution.

What will be the output of the following Java code?
enum Season 
{
    WINTER, SPRING, SUMMER, FALL
};
System.out.println(Season.WINTER.ordinal());

Select an option to see the answer and solution.

Which of these coding types is used for data type characters in Java?

Select an option to see the answer and solution.

What is Truncation in Java?

Select an option to see the answer and solution.

Which of these occupy first 0 to 127 in Unicode character set used for characters in Java?

Select an option to see the answer and solution.

How to convert Date object to String?

Options are not available for this question.

Select an option to see the answer and solution.

What will be the output of the following Java program?
    class c 
    {    
        public void main( String[] args ) 
        {  
            System.out.println( "Hello" + args[0] ); 
        } 
    }

Select an option to see the answer and solution.

How to identify if a timezone is eligible for DayLight Saving?

Select an option to see the answer and solution.

Can we create an instance of Enum outside of Enum itself?

Select an option to see the answer and solution.

Which of the following is not provided by BigDecimal?

Select an option to see the answer and solution.

Which of these is necessary condition for automatic type conversion in Java?

Select an option to see the answer and solution.

What will be the output of the following Java program?
class array_output 
{
    public static void main(String args[]) 
    {
        int array_variable [] = new int[10];
  for (int i = 0; i < 10; ++i) {
            array_variable[i] = i/2;
            array_variable[i]++;
            System.out.print(array_variable[i] + " ");
            i++;
        }

    } 
}

Select an option to see the answer and solution.

What will be the output of the following Java code?
class asciicodes {
    public static void main(String args[]) 
    {
        char var1 = 'A';
  char var2 = 'a';
  System.out.println((int)var1 + " " + (int)var2);
    } 
}

Select an option to see the answer and solution.

What will be the output of the following Java code?
class average {
    public static void main(String args[])
    {
        double num[] = {5.5, 10.1, 11, 12.8, 56.9, 2.5};
        double result;
        result = 0;
        for (int i = 0; i < 6; ++i) 
            result = result + num[i];
  System.out.print(result/6);

    } 
}

Select an option to see the answer and solution.

What will be the output of the following Java program?
class array_output {
    public static void main(String args[]) 
    {    
        char array_variable [] = new char[10];
  for (int i = 0; i < 10; ++i) {
            array_variable[i] = 'i';
            System.out.print(array_variable[i] + "" );
            i++;
        }
    } 
}

Select an option to see the answer and solution.

Literals in java must be appended by which of these?

Select an option to see the answer and solution.

Which of these is long data type literal?

Select an option to see the answer and solution.