Java Programming Exam Practice Questions | Generated by AI
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.
-
Which of the following is the correct identifier name in Java?
A. 2count
B. my-name
C. _total$
D. class -
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 -
What is the correct extension of a compiled Java class file?
A. .java
B. .class
C. .obj
D. .exe -
Which of the following is NOT a primitive data type in Java?
A. int
B. float
C. String
D. boolean -
The default value of a boolean type variable is:
A. true
B. false
C. 0
D. null -
Which keyword is used to define a constant in Java?
A. const
B. final
C. static
D. constant -
What is the result of 10 / 3 in integer division in Java?
A. 3.333
B. 3
C. 4
D. Compilation error -
Which operator has the highest precedence in Java?
A. +
B. *
C. ++
D. == -
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 -
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 -
Which keyword can terminate the current loop iteration and continue with the next?
A. break
B. return
C. continue
D. exit -
In Java, arrays are:
A. Primitive data types
B. Objects
C. Methods
D. Keywords -
What is the index number of the first element in a Java array?
A. 0
B. 1
C. -1
D. Depends on declaration -
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]; -
What is the output of System.out.println(“Hello” + 10 + 20);
A. Hello1020
B. Hello30
C. 1020Hello
D. Compilation error -
Which method is the entry point of a Java application?
A. start()
B. run()
C. main()
D. init() -
Which access modifier allows access only within the same class?
A. public
B. protected
C. default
D. private -
Which keyword is used to inherit a class in Java?
A. implement
B. extends
C. inherits
D. super -
A class that cannot be instantiated is called:
A. final class
B. static class
C. abstract class
D. private class -
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 -
Which keyword prevents method overriding?
A. static
B. final
C. abstract
D. private -
What is the parent class of all Java classes?
A. Object
B. Class
C. System
D. Main -
Which exception is thrown when dividing an integer by zero?
A. NullPointerException
B. ArrayIndexOutOfBoundsException
C. ArithmeticException
D. IOException -
Which keyword is used to manually throw an exception?
A. catch
B. finally
C. throw
D. throws -
Which block is always executed whether an exception occurs or not?
A. try
B. catch
C. finally
D. throw -
Which of the following is a checked exception?
A. NullPointerException
B. ClassNotFoundException
C. ArithmeticException
D. IndexOutOfBoundsException -
In Java, strings are:
A. Mutable
B. Immutable
C. Both mutable and immutable
D. Primitive data type -
Which method is used to get the length of a string?
A. size()
B. length()
C. count()
D. len() -
Which class is used to read input from the console in Java?
A. System.in
B. Scanner
C. InputStream
D. BufferedReader -
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.