LogIn
I don't have account.
Q1.
What is the maximum value that can be stored in a byte variable in Java?
1
1
127
2
255
3
64
4
32767
Q2.
Which data type is used to store a single character in Java?
1
1
char
2
int
3
string
4
ch
Q3.
What is the default value of an int variable in Java if it's not explicitly initialized?
1
1
0
2
1
3
null
4
garbage value
Q4.
What is the size of a long variable in Java?
1
1
2 bytes
2
4 bytes
3
8 bytes
4
12 bytes
Q5.
What is the range of values that can be stored in a short variable in Java?
1
1
-128 to 127
2
0 to 255
3
0 to 65,535
4
-32,768 to 32,767
Q6.
Which of the following is a primitive data type in Java?
1
1
char
2
String
3
Boolean
4
Integer
Q7.
What is the default value of a boolean variable in Java if it is not explicitly initialized?
1
1
false
2
true
3
0
4
null
Q8.
Which of the following is the correct way to declare a hexadecimal value in Java?
2
1
0x1A
2
#1A
3
0b1A
4
#1A
Q9.
What is the minimum value that can be stored in a char variable in Java?
2
1
-128
2
'a'
3
0
4
-32768
Q10.
Which of the following is not a primitive data type in Java?
1
1
String
2
int
3
byte
4
char
Q11.
What is the default value of a double variable in Java if it's not explicitly initialized?
1
1
0.0
2
1.0
3
null
4
garbage value
Q12.
What is the keyword used to declare a constant value in Java?
1
1
const
2
constant
3
final
4
static
Q13.
Which of the following is not a valid way to declare an integer variable in Java?
1
1
int x =42;
2
int x = 42.5;
3
int x = 0x42;
4
int x = -42;
Q14.
What is the default value of a char variable in Java if it's not explicitly initialized?
1
1
'\u0000'
2
''
3
'0'
4
null
Q15.
Which of the following is the correct way to declare a boolean variable named isJava and initialize it to true in Java?
1
1
boolean isJava = true;
2
bool isJava = true;
3
bool = true;
4
boolean = true;
Q16.
What is the size of a float variable in Java?
1
1
2 bytes
2
4 bytes
3
8 bytes
4
12 bytes
Q17.
What is the size of a double variable in Java?
1
1
2 bytes
2
4 bytes
3
8 bytes
4
12 bytes
Q18.
What is the range of values that can be stored in a char variable in Java?
1
1
0 to 65535
2
-128 to 127
3
-32768 to 32767
4
0 to 255
Q19.
What is the default value of a boolean array element in Java if it's not explicitly initialized?
1
1
false
2
true
3
0
4
null
Q20.
Which of the following is not a valid way to declare a char variable in Java?
1
1
char x = 'a'
2
char x = 'M'
3
char x = 64
4
char w = 0x0041
Q21.
How many primitive data types are there in Java?
1
1
6
2
7
3
8
4
9
Q22.
The smallest integer type is ......... and its size is ......... bits.
1
1
byte , 8
2
short , 8
3
byte , 16
4
short , 16
Q23.
Automatic type conversion in Java takes place when
1
1
Two type are compatible and size of destination type is equal of source type.
2
Two type are compatible and size of destination type is larger than source type.
3
Two type are compatible and size of destination type is shorter than source type.
4
All of the above
Q24.
What will be the output of following Java Code?
public class Main {
     public static void main(String args[]){
        byte b;
        int i = 264;
        b = (byte) i;
        System.out.print(b); 
    }
}
2
1
8
2
127
3
264
4
None of the above
Q25.
What will be the output of following Java Code?
public class Main {
     public static void main(String args[]){
        byte b;
        int i = 264;
        double d = 215.59;
        b = (byte) i;
        System.out.print(b); 
        i = (int) d; 
        System.out.print(i); 
        b = (byte) d; 
        System.out.print(b); 
    }
}
2
1
8215-41
2
4215-41
3
264215264
4
None of the above
Q26.
Which data type is used to store a single character in Java?
2
1
char
2
String
3
character
4
Character
Q27.
In Java, what is the default value of a char variable?
1
1
null
2
' '
3
'\u0000'
4
0
Q28.
What is the output of the following Java program?
System.out.println('A' + 1);
2
1
B
2
A1
3
66
4
Compilation Error
Q29.
What is the default numeric data type for decimal values in Java?
1
1
int
2
float
3
long
4
double