Java Programming Exam Practice Questions | Generated by AI

Home 2025.11

Here are 30 multiple-choice exam questions for the course 08553 Introduction to Programming (Java) (National Higher Education Self-study Examination, Guangdong, Micro-course version by 胡运玲). All questions are in standard four-option format (A, B, C, D), suitable for the self-study exam level.

  1. Which of the following is the correct identifier name in Java?
    A. 2count
    B. my-name
    C. _total$
    D. class

  2. Which command is used to compile a Java source file?
    A. java Filename
    B. javac Filename.java
    C. java Filename.java
    D. compile Filename.java

  3. What is the correct extension of a compiled Java class file?
    A. .java
    B. .class
    C. .obj
    D. .exe

  4. Which of the following is NOT a primitive data type in Java?
    A. int
    B. float
    C. String
    D. boolean

  5. The default value of a boolean type variable is:
    A. true
    B. false
    C. 0
    D. null

  6. Which keyword is used to define a constant in Java?
    A. const
    B. final
    C. static
    D. constant

  7. What is the result of 10 / 3 in integer division in Java?
    A. 3.333
    B. 3
    C. 4
    D. Compilation error

  8. Which operator has the highest precedence in Java?
    A. +
    B. *
    C. ++
    D. ==

  9. Which of the following statements about the switch statement is correct?
    A. The expression must be of type String or int only
    B. The case value must be a constant expression
    C. break is mandatory after each case
    D. default must be placed first

  10. How many times will the loop body execute: for(int i=0; i<5; i++)
    A. 4 times
    B. 5 times
    C. 6 times
    D. Infinite times

  11. Which keyword can terminate the current loop iteration and continue with the next?
    A. break
    B. return
    C. continue
    D. exit

  12. In Java, arrays are:
    A. Primitive data types
    B. Objects
    C. Methods
    D. Keywords

  13. What is the index number of the first element in a Java array?
    A. 0
    B. 1
    C. -1
    D. Depends on declaration

  14. Which of the following correctly declares and initializes a one-dimensional array?
    A. int[] arr = new int[5] {1,2,3,4,5};
    B. int[] arr = {1,2,3,4,5};
    C. int arr[5] = new int[];
    D. int arr = new int[5];

  15. What is the output of System.out.println(“Hello” + 10 + 20);
    A. Hello1020
    B. Hello30
    C. 1020Hello
    D. Compilation error

  16. Which method is the entry point of a Java application?
    A. start()
    B. run()
    C. main()
    D. init()

  17. Which access modifier allows access only within the same class?
    A. public
    B. protected
    C. default
    D. private

  18. Which keyword is used to inherit a class in Java?
    A. implement
    B. extends
    C. inherits
    D. super

  19. A class that cannot be instantiated is called:
    A. final class
    B. static class
    C. abstract class
    D. private class

  20. Which of the following is true about constructors in Java?
    A. They must have a return type
    B. They cannot be overloaded
    C. They have the same name as the class
    D. They are called using new keyword only

  21. Which keyword prevents method overriding?
    A. static
    B. final
    C. abstract
    D. private

  22. What is the parent class of all Java classes?
    A. Object
    B. Class
    C. System
    D. Main

  23. Which exception is thrown when dividing an integer by zero?
    A. NullPointerException
    B. ArrayIndexOutOfBoundsException
    C. ArithmeticException
    D. IOException

  24. Which keyword is used to manually throw an exception?
    A. catch
    B. finally
    C. throw
    D. throws

  25. Which block is always executed whether an exception occurs or not?
    A. try
    B. catch
    C. finally
    D. throw

  26. Which of the following is a checked exception?
    A. NullPointerException
    B. ClassNotFoundException
    C. ArithmeticException
    D. IndexOutOfBoundsException

  27. In Java, strings are:
    A. Mutable
    B. Immutable
    C. Both mutable and immutable
    D. Primitive data type

  28. Which method is used to get the length of a string?
    A. size()
    B. length()
    C. count()
    D. len()

  29. Which class is used to read input from the console in Java?
    A. System.in
    B. Scanner
    C. InputStream
    D. BufferedReader

  30. What is the correct way to create an object of a class named Student?
    A. Student s = new Student();
    B. Student s = new Student;
    C. new Student s;
    D. Student s = Student();

These questions cover the full scope of the 08553 Java self-study exam syllabus (basic syntax, control structures, arrays, OOP principles, exception handling, and common classes), consistent with the micro-course version. Ready to use directly in exams.


Back

x-ai/grok-4.1-fast

Donate