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

2/7

Page

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

What is the default value of a char variable in Java if it's not explicitly initialized?

Select an option to see the answer and solution.

Which data type is used to represent integer values in Java?

Select an option to see the answer and solution.

Which of the following is the correct way to declare a boolean variable named isJavaFun and initialize it to true in Java?

Select an option to see the answer and solution.

What is the size of a float variable in Java?

Select an option to see the answer and solution.

Which of the following is not a valid way to declare a long variable in Java?

Select an option to see the answer and solution.

Which of the following is the correct way to declare a byte variable named myByte and initialize it to 5 in Java?

Select an option to see the answer and solution.

What is the range of values that can be stored in a char variable in Java?

Select an option to see the answer and solution.

Which data type is used to store numbers with decimal points and less precision than double?

Select an option to see the answer and solution.

What is the default value of a boolean array element in Java if it's not explicitly initialized?

Select an option to see the answer and solution.

Which of the following is not a valid way to declare a char variable in Java?

Select an option to see the answer and solution.

Java is a ........... language.

Select an option to see the answer and solution.

How many primitive data types are there in Java?

Select an option to see the answer and solution.

In Java byte, short, int and long all of these are

Select an option to see the answer and solution.

Size of int in Java is

Select an option to see the answer and solution.

The smallest integer type is ......... and its size is ......... bits.

Select an option to see the answer and solution.

Size of float and double in Java is

Select an option to see the answer and solution.

Determine output:
class A{
        public static void main(String args[]){
	        int x;
 	        x = 10;
	        if(x == 10){
		        int y = 20;
		        System.out.print("x and y: "+ x + " " + y);
		        y = x*2;
	        }
	        y = 100;
	        System.out.print("x and y: " + x + " " + y);
        }
}

Select an option to see the answer and solution.

Automatic type conversion in Java takes place when

Select an option to see the answer and solution.

Which of the following automatic type conversion will be possible?

Select an option to see the answer and solution.

What is the output of the following program?
class A{
        public static void main(String args[]){
	        byte b;
   	        int i = 258;
	        double d = 325.59;

	        b = (byte) i;
	        System.out.print(b);

	        i = (int) d;
	        System.out.print(i);

                b = (byte) d;
                System.out.print(b);
        }
}

Select an option to see the answer and solution.