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

4/7

Page

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

What is the range of short data type in Java?

Select an option to see the answer and solution.

Is SimpleDateFormat thread safe?

Select an option to see the answer and solution.

Which of these can not be used for a variable name in Java?

Select an option to see the answer and solution.

Are enums are type-safe?

Select an option to see the answer and solution.

Which of the below data type doesn't support overloaded methods for +,-,* and /?

Select an option to see the answer and solution.

How to convert a String to a Date object?

Options are not available for this question.

Select an option to see the answer and solution.

What is BigDecimal.ONE?

Select an option to see the answer and solution.

What will be the error in the following Java code?
byte b = 50;
b = b * 50;

Select an option to see the answer and solution.

Which of these values can a boolean variable contain?

Select an option to see the answer and solution.

What will be the output of the following Java code?
class increment {
    public static void main(String args[]) 
    {        
         int g = 3;
         System.out.print(++g * 8);
    } 
}

Select an option to see the answer and solution.

If an expression contains double, int, float, long, then the whole expression will be promoted into which of these data types?

Select an option to see the answer and solution.

What will be the output of the following Java program?
class dynamic_initialization 
{
    public static void main(String args[]) 
    {
        double a, b;
        a = 3.0;
        b = 4.0;
  double c = Math.sqrt(a * a + b * b);
  System.out.println(c);
    } 
}

Select an option to see the answer and solution.

Which of these can be returned by the operator &?

Select an option to see the answer and solution.

Which data type value is returned by all transcendental math functions?

Select an option to see the answer and solution.

What is the prototype of the default constructor of this Java class?
public class prototype { }

Select an option to see the answer and solution.

What will be the output of the following Java program, if we run as "java main_arguments 1 2 3"?
class main_arguments 
{
    public static void main(String [] args) 
    {
        String [][] argument = new String[2][2];
        int x;
        argument[0] = args;
        x = argument[0].length;
        for (int y = 0; y < x; y++) 
            System.out.print(" " + argument[0][y]);              
    }
}

Select an option to see the answer and solution.

Which of these literals can be contained in float data type variable?

Select an option to see the answer and solution.

What will be the output of the following Java code?
class A 
{
    final public int calculate(int a, int b) { return 1; } 
} 
class B extends A 
{ 
    public int calculate(int a, int b) { return 2; } 
} 
 public class output 
 {
    public static void main(String args[]) 
    { 
        B object = new B(); 
        System.out.print("b is " + b.calculate(0, 1));  
    } 
}

Select an option to see the answer and solution.

What will be the output of the following Java code snippet?
 enum Levels 
{
    private TOP,
 
    public MEDIUM,
 
    protected BOTTOM;
}

Select an option to see the answer and solution.

How to format date from one form to another?

Select an option to see the answer and solution.