Common Jobs

Common Jobs Logo

Java Quiz

1 / 40

1) Which of the following is a marker interface in Java?

2 / 40

2) What is the output of the following code snippet?

System.out.println(10 / 0);

3 / 40

3) Which of the following is true about Java interfaces?

4 / 40

4) What is the output of the following code snippet?

System.out.println(10 > 9 && 5 < 3);

5 / 40

5) Which keyword is used to prevent a method from being overridden in Java?

6 / 40

6) Which keyword is used to create an object without a reference in Java?

7 / 40

7) Which of the following is not a valid Java identifier?

8 / 40

8) Which of the following is true about constructors in Java?

9 / 40

9) Which keyword is used to define a method that cannot be overridden in Java?

10 / 40

10) Which of the following statements is true about method overriding in Java?

11 / 40

11) Which keyword is used to define a constant in Java?

12 / 40

12) What is the output of the following code snippet?

public class Main {

    public static void main(String[] args) {

        int arr[] = new int[5];

        System.out.println(arr.length);

    }

}

13 / 40

13) Which of the following is a correct way to declare a constant in Java?

14 / 40

14) Which of the following statements about static methods in Java is true?

15 / 40

15) What is the output of the following code snippet?

public class Main {

    public static void main(String[] args) {

        int x = 5;

        int y = 2;

        System.out.println(x % y);

    }

}

16 / 40

16) What is the output of the following code snippet?

public class Main {

    public static void main(String[] args) {

        System.out.println(5 + 2 * 3 / 2);

    }

}

17 / 40

17) Which of the following is true about method overriding in Java?

18 / 40

18) What is the output of the following code snippet?

public class Main {

    public static void main(String[] args) {

        System.out.println(Math.ceil(2.1));

    }

}

19 / 40

19) What is the output of the following code snippet?

int[] arr = {1, 2, 3, 4, 5};

System.out.println(arr[arr.length]);

20 / 40

20) What is the output of the following code snippet?

public class Main {

    public static void main(String[] args) {

        String str = "hello";

        str.toUpperCase();

        System.out.println(str);

    }

}

21 / 40

21) What is the output of the following code snippet?

public class Main {

    public static void main(String[] args) {

        int arr[] = {1, 2, 3, 4, 5};

        System.out.println(arr[5]);

    }

}

22 / 40

22) Which of the following statements about Java packages is true?

23 / 40

23) Which collection class allows null elements?

24 / 40

24) Which of the following is a correct way to declare and initialize an ArrayList in Java?

25 / 40

25) What is the output of the following code snippet?

public class Main {

    public static void main(String[] args) {

        String str = "Hello";

        str.concat(" World");

        System.out.println(str);

    }

}

26 / 40

26) What is the output of the following code snippet?

public class Main {

    public static void main(String[] args) {

        int x = 10;

        if (x > 5) {

            System.out.println("x is greater than 5");

        } else {

            System.out.println("x is less than or equal to 5");

        }

    }

}

27 / 40

27) What is the output of the following code snippet?

public class Main {

    public static void main(String[] args) {

        int x = 5;

        int y = 2;

        System.out.println(x / y);

    }

}

28 / 40

28) Which of the following is not a valid access modifier in Java?

29 / 40

29) What is the output of the following code snippet?

int[] arr = new int[5];

System.out.println(arr[0]);

30 / 40

30) Which of the following statements is true about Java packages?

31 / 40

31) What is the output of the following code snippet?

public class Main {

    public static void main(String[] args) {

        int x = 5;

        x += x++ + ++x;

        System.out.println(x);

    }

}

32 / 40

32) Which of the following is true about the "super" keyword in Java?

33 / 40

33) What is the output of the following code snippet?

public class Main {

    public static void main(String[] args) {

        String str = "Java";

        str.concat(" Programming");

        System.out.println(str);

    }

}

34 / 40

34) What is the output of the following Java code?

public class Main {

    public static void main(String[] args) {

        int x = 5;

        System.out.println(x++ + ++x);

    }

}

35 / 40

35) What is the correct way to create an instance of an abstract class in Java?

36 / 40

36) Which of the following statements is true about method overloading in Java?

37 / 40

37) What is the output of the following code snippet?

String str = "hello";

System.out.println(str.toUpperCase());

38 / 40

38) Which of the following is a valid declaration of a two-dimensional array in Java?

39 / 40

39) Which of the following is not a Java keyword?

40 / 40

40) What is the default value of a local variable in Java?

Your score is

The average score is 38%

0%