What is the default value of a char variable in Java if it's not explicitly initialized?
A. ' '
B. '0'
C. '\u0000'
D. Null
Select an option to see the answer and solution.
Which data type is used to represent integer values in Java?
A. int
B. float
C. boolean
D. char
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?
A. boolean isJavaFun = true
B. bool isJavaFun = true
C. boolean = true
D. bool = true
Select an option to see the answer and solution.
What is the size of a float variable in Java?
A. 4 bytes
B. 8 bytes
C. 2 bytes
D. 16 bytes
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?
A. long x = 123L
B. long y = 123
C. long z = 123.0
D. long w = 0x1L
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?
A. byte myByte = 5
B. byte myByte = "5"
C. byte myByte = '5'
D. byte myByte = 5.0
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?
A. 0 to 127
B. -128 to 127
C. 0 to 65535
D. -32768 to 32767
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?
A. float
B. byte
C. short
D. long
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?
A. char x = 'A'
B. char y = 'n'
C. char z = 65
D. char w = 0x0041
Select an option to see the answer and solution.
Java is a ........... language.
A. weakly typed
B. strongly typed
C. moderate typed
D. None of these
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
A. signed
B. unsigned
C. Both of the above
D. None of these
Select an option to see the answer and solution.
Size of int in Java is
A. 16 bit
B. 32 bit
C. 64 bit
D. Depends on execution environment
Select an option to see the answer and solution.
The smallest integer type is ......... and its size is ......... bits.
A. short, 8
B. byte, 8
C. short, 16
D. byte, 16
Select an option to see the answer and solution.
Size of float and double in Java is
A. 32 and 64
B. 64 and 64
C. 32 and 32
D. 64 and 32
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);
}
}A. 10 20 10 100
B. 10 20 10 20
C. 10 20 10 10
D. Error
Select an option to see the answer and solution.
Automatic type conversion in Java takes place when
A. Two type are compatible and size of destination type is shorter than source type.
B. Two type are compatible and size of destination type is equal of source type.
C. Two type are compatible and size of destination type is larger than source type.
D. All of the above
Select an option to see the answer and solution.
Which of the following automatic type conversion will be possible?
A. short to int
B. byte to int
C. int to long
D. All of these
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);
}
}A. 258 325 325
B. 258 326 326
C. 2 325 69
D. Error
Select an option to see the answer and solution.