Skip to content
Get started free

Test

java test 1

By Tamilarasi.R · java · Professional development · Published Nov 3, 2026 · New

java test 1

26 questions · 68 points

  1. Question 1 · One correct answer · 1 point

    1Which component is responsible for executing Java bytecode?
    1. A. a) JDK
    2. B. b) JVM
    3. C. c) JRE
    4. D. d) JAR
  2. Question 2 · One correct answer · 1 point

    1. Which data type is used to store a single character?
    1. A. a) String
    2. B. b) int
    3. C. c) char
    4. D. d) boolean
  3. Question 3 · One correct answer · 1 point

    3.Which operator is used to check whether two conditions are true?
    1. A. a) ||
    2. B. b) &&
    3. C. c) !
    4. D. d) =
  4. Question 4 · One correct answer · 1 point

    4.Which statement is used to make decisions in Java?
    1. A. a) for
    2. B. b) while
    3. C. c) if
    4. D. d) break
  5. Question 5 · One correct answer · 1 point

    5.Which loop executes at least once?
    1. A. a) for
    2. B. b) while
    3. C. c) do-while
    4. D. d) enhanced for
  6. Question 6 · One correct answer · 1 point

    1. What is the index of the first element in a Java array?
    1. A. a) 1
    2. B. b) 0
    3. C. c) -1
    4. D. d) 2
  7. Question 7 · One correct answer · 1 point

    1. Which keyword is used to terminate a loop?
    1. A. a) continue
    2. B. b) return
    3. C. c) break
    4. D. d) exit
  8. Question 8 · One correct answer · 1 point

    1. Which statement is used to skip the current iteration?
    1. A. a) break
    2. B. b) continue
    3. C. c) return
    4. D. d) switch
  9. Question 9 · One correct answer · 1 point

    1. How many indexes are required to access an element in a 2D array?
    1. A. a) One
    2. B. b) Two
    3. C. c) Three
    4. D. d) Four
  10. Question 10 · One correct answer · 1 point

    1. Which property is used to find the length of an array?
    1. A. a) size()
    2. B. b) length()
    3. C. c) length
    4. D. d) count()
  11. Question 11 · Short answer · 2 points

    1. What is the difference between JDK, JRE and JVM?

    Your answer:

  12. Question 12 · Short answer · 2 points

    1. Differentiate between while and do-while loops.

    Your answer:

  13. Question 13 · Short answer · 2 points

    1. What is the difference between break and continue?

    Your answer:

  14. Question 14 · Short answer · 2 points

    1. What is a two-dimensional array? Give an example.

    Your answer:

  15. Question 15 · Short answer · 2 points

    1. Predict the Output

    int a = 10;

    int b = 5;

    System.out.println(a + b);

    System.out.println(a * b);

    Your answer:

  16. Question 16 · Short answer · 2 points

    1. Predict the Output

    int age = 16;

    if (age >= 18) {

    System.out.println("Eligible");

    } else {

    System.out.println("Not Eligible");

    }

    Your answer:

  17. Question 17 · Short answer · 2 points

    1. Predict the Output

    for (int i = 1; i <= 5; i++) {

    System.out.println(i);

    }

    Your answer:

  18. Question 18 · Short answer · 2 points

    1. Predict the Output

    int i = 1;

    while (i <= 3) {

    System.out.println(i);

    i++;

    }

    Your answer:

  19. Question 19 · Short answer · 2 points

    1. Predict the Output

    int[] numbers = {10, 20, 30, 40};

    System.out.println(numbers[2]);

    System.out.println(numbers.length);

    Your answer:

  20. Question 20 · Short answer · 4 points

    1. Find the Error

    for (int i = 1; i >= 5; i++) {

    System.out.println(i);

    }

    Your answer:

  21. Question 21 · Short answer · 4 points

    1. Find the Error

    int[] numbers = {10, 20, 30};

    System.out.println(numbers[3]);

    Your answer:

  22. Question 22 · One correct answer · 3 points

    1. Programming Questions

    public class Main {

    public static void main(String[] args) {

    int number = 10;

    if (number % 2 == 0) {

    System.out.println("Even Number");

    } else {

    System.out.println("Odd Number");

    }

    }

    }

    1. A. Even Number
    2. B. Odd Number
  23. Question 23 · Short answer · 3 points

    1. Print numbers from 10 to 1.
    2. public class Main { public static void main(String[] args) { for (int i = 10; i >= 1; i--) { System.out.println(i); } }}

    Your answer:

  24. Question 24 · Short answer · 3 points

    1. Print five student names using enhanced for loop.

    public class Main {

    public static void main(String[] args) {

    String[] students = {

    "Anu", "Priya", "Kavi", "Ravi", "Tamil"

    };

    for (String name : students) {

    System.out.println(name);

    }

    }

    }

    Your answer:

  25. Question 25 · Short answer · 3 points

    1. Create and print a 2D array.

    public class Main {

    public static void main(String[] args) {

    int[][] numbers = {

    {10, 20, 30},

    {40, 50, 60}

    };

    for (int i = 0; i < 2; i++) {

    for (int j = 0; j < 3; j++) {

    System.out.print(numbers[i][j] + " ");

    }

    System.out.println();

    }

    }

    }

    Your answer:

  26. Question 26 · Short answer · 20 points

    Write a Java program to:

    • Create an integer array containing five marks.
    • Print all five marks.
    • Calculate and print the total.
    • Calculate and print the average.

    Your answer:

How it works with your class

  1. 1. Copy it to your accountOne click. Change anything you want.
  2. 2. Share a link or codeStudents open it on any device, no accounts needed.
  3. 3. See the resultsScores and every answer, checked for you.
Sign up free

More like this