LogIn
I don't have account.

Practice java Quizzes

Enhance your java skills with carefully curated quizzes designed to improve concept clarity and real-world application. Each question reinforces key principles through active practice. Ideal for students and professionals, these quizzes help you learn faster, stay sharp and strengthen your overall technical expertise.

Explore All java Quizzes

Learn java step by step with interactive quizzes designed for beginners and learners revising key concepts. Build a strong foundation with clear, structured practice in java.
Question 1
What is the maximum value that can be stored in a byte variable in Java?
1
64
2
255
3
127
4
32767
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
garbage value
2
1
3
0
4
null
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
000
2
111
3
error
4
garbage value
5
0 0 0
Question 5
Which of the following is not a valid identifier for a Java variable?
1
3rdvar
2
_myvar
3
my_var
4
$var
Question 6
What is the size of a long variable in Java?
1
12 bytes
2
4 bytes
3
2 bytes
4
8 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 255
4
0 to 65,535
Question 8
Which of the following is a primitive data type in Java?
1
Boolean
2
String
3
char
4
Integer
Question 9
Which keyword is used to declare a variable that can hold a reference to an object of any class in Java?
1
object
2
class
3
var
4
genric
Question 10
What is the default value of a boolean variable in Java if it is not explicitly initialized?
1
null
2
false
3
true
4
0
Question 11
Which of the following is the correct way to declare a hexadecimal value in Java?
1
0x1A
2
#1A
3
#1A
4
0b1A
Question 12
What is the minimum value that can be stored in a char variable in Java?
1
-128
2
'a'
3
0
4
-32768
Question 13
Which of the following is not a primitive data type in Java?
1
char
2
byte
3
int
4
String
Question 14
What is the default value of a double variable in Java if it's not explicitly initialized?
1
null
2
1.0
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
0
2
compile time error
3
runtime error
4
garbage value
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
compile time error
2
0
3
runtime error
4
garbage value
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
0
2
garbage value
3
runtime error
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
garbage value
2
compile time error
3
0
4
runtime error
Question 19
What is the keyword used to declare a constant value in Java?
1
const
2
constant
3
final
4
static
Question 20
Which of the following is not a valid way to declare an integer variable in Java?
1
int x = 42.5;
2
int x = -42;
3
int x =42;
4
int x = 0x42;
Question 21
What is the default value of a char variable in Java if it's not explicitly initialized?
1
'\u0000'
2
''
3
null
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
garbage value
2
runtime error
3
compile time error
4
0
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
compile time error
2
An empty space (because the default value of myVar is '\u0000')
3
0
4
null
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
garbage value
2
0
3
runtime error
4
compile time error
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
An empty space (because the default value of myVar is '\u0000')
2
compile time error
3
0
4
null
5
''
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 = true;
4
boolean isJava = true;
Question 27
What is the size of a float variable in Java?
1
4 bytes
2
2 bytes
3
8 bytes
4
12 bytes
Question 28
What is the size of a double variable in Java?
1
12 bytes
2
2 bytes
3
4 bytes
4
8 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 65535
3
-32768 to 32767
4
0 to 255
Question 30
What is the default value of a boolean array element in Java if it's not explicitly initialized?
1
false
2
null
3
0
4
true