LogIn
I don't have account.
Question 1
What is the maximum value that can be stored in a byte variable in Java?
1
64
2
32767
3
255
4
127
Question 2
Which data type is used to store a single character in Java?
1
int
2
char
3
string
4
ch
Question 3
What is the default value of an int variable in Java if it's not explicitly initialized?
1
1
2
0
3
null
4
garbage value
Question 4
What will be the output of following Java Code?
public class Main {
    public static void main(String[] args) {
        int[] arr = new int[3];
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]);
        }
    }
}
1
garbage value
2
000
3
error
4
0 0 0
5
111
Question 5
Which of the following is not a valid identifier for a Java variable?
1
$var
2
3rdvar
3
my_var
4
_myvar
Question 6
What is the size of a long variable in Java?
1
2 bytes
2
4 bytes
3
8 bytes
4
12 bytes
Question 7
What is the range of values that can be stored in a short variable in Java?
1
-128 to 127
2
-32,768 to 32,767
3
0 to 65,535
4
0 to 255
Question 8
Which of the following is a primitive data type in Java?
1
String
2
Integer
3
char
4
Boolean
Question 9
Which keyword is used to declare a variable that can hold a reference to an object of any class in Java?
1
var
2
object
3
genric
4
class
Question 10
What is the default value of a boolean variable in Java if it is not explicitly initialized?
1
true
2
0
3
false
4
null
Question 11
Which of the following is the correct way to declare a hexadecimal value in Java?
1
#1A
2
0b1A
3
0x1A
4
#1A
Question 12
What is the minimum value that can be stored in a char variable in Java?
1
'a'
2
-32768
3
0
4
-128
Question 13
Which of the following is not a primitive data type in Java?
1
byte
2
String
3
int
4
char
Question 14
What is the default value of a double variable in Java if it's not explicitly initialized?
1
1.0
2
null
3
garbage value
4
0.0
Question 15
What will be the output of following Java Code?
public class Main {
    public static void main(String[] args) {
        int myVar;
        System.out.print(myVar);
    }
}
1
runtime error
2
garbage value
3
0
4
compile time error
Question 16
What will be the output of following Java Code?
public class Main {
    static int myVar;
    public static void main(String[] args) {
        System.out.print(myVar);
    }
}
1
runtime error
2
garbage value
3
0
4
compile time error
Question 17
What will be the output of following Java Code?
public class Main {
    public static void main(String[] args) {
        static int myVar;
        System.out.print(myVar);
    }
}
1
garbage value
2
runtime error
3
0
4
compile time error
Question 18
What will be the output of following Java Code?
public class Main {
    int myVar;
    public static void main(String[] args) {
        Main obj = new Main();
        System.out.print(obj.myVar);
    }
}
1
0
2
compile time error
3
runtime error
4
garbage value
Question 19
What is the keyword used to declare a constant value in Java?
1
final
2
static
3
constant
4
const
Question 20
Which of the following is not a valid way to declare an integer variable in Java?
1
int x = 0x42;
2
int x = -42;
3
int x = 42.5;
4
int x =42;
Question 21
What is the default value of a char variable in Java if it's not explicitly initialized?
1
null
2
''
3
'\u0000'
4
'0'
Question 22
What will be the output of following Java Code?
public class Main {
    public static void main(String[] args) {
        char myVar;
        System.out.print(myVar);
    }
}
1
0
2
compile time error
3
garbage value
4
runtime error
Question 23
What will be the output of following Java Code?
public class Main {
    static char myVar;
    public static void main(String[] args) {
        System.out.print(myVar);
    }
}
1
null
2
0
3
An empty space (because the default value of myVar is '\u0000')
4
compile time error
Question 24
What will be the output of following Java Code?
public class Main {
    public static void main(String[] args) {
        static char myVar;
        System.out.print(myVar);
    }
}
1
compile time error
2
garbage value
3
runtime error
4
0
Question 25
What will be the output of following Java Code?
public class Main {
    char myVar;
    public static void main(String[] args) {
        Main obj = new Main();
        System.out.print(obj.myVar);
    }
}
1
''
2
0
3
An empty space (because the default value of myVar is '\u0000')
4
compile time error
5
null
Question 26
Which of the following is the correct way to declare a boolean variable named isJava and initialize it to true in Java?
1
bool isJava = true;
2
bool = true;
3
boolean isJava = true;
4
boolean = true;
Question 27
What is the size of a float variable in Java?
1
12 bytes
2
2 bytes
3
8 bytes
4
4 bytes
Question 28
What is the size of a double variable in Java?
1
8 bytes
2
4 bytes
3
2 bytes
4
12 bytes
Question 29
What is the range of values that can be stored in a char variable in Java?
1
-128 to 127
2
0 to 255
3
0 to 65535
4
-32768 to 32767
Question 30
What is the default value of a boolean array element in Java if it's not explicitly initialized?
1
null
2
0
3
true
4
false