Java Aptitude Test

This post presents the Java programming aptitude test designed for beginners with 25 multiple-choice questions.

This set of MCQ questions provides a fundamental overview of Java programming, ideal for beginners looking to test their understanding of basic concepts and syntax.

1. What is the range of the byte data type in Java?

a) -128 to 127
b) 0 to 255
c) -255 to 254
d) -32768 to 32767

2. How do you declare an array in Java?

a) int array[10];
b) int array = new int[10];
c) int[] array = new int[10];
d) array int[10];

3. Which of the following is a valid class name in Java?

a) 1stClass
b) _MyClass
c) class
d) MyClass

4. What keyword is used to inherit a class in Java?

a) super
b) this
c) class
d) extends

5. Which keyword is used for creating a constant in Java?

a) const
b) final
c) static
d) constant

6. How is a single-line comment written in Java?

a) /* comment */
b) // comment
c) <!– comment –>
d) # comment

7. What is the default value of a boolean variable in Java?

a) true
b) false
c) null
d) 0

8. What is method overloading?

a) Methods with different names but the same parameters
b) Methods with the same name but different parameters
c) Changing the way a method works
d) None of the above

9. Which collection class allows you to grow or shrink its size and provides indexed access to its elements?

a) HashSet
b) HashMap
c) ArrayList
d) TreeMap

10. What is the return type of the main method in Java?

a) int
b) void
c) double
d) String[]

11. What does the new keyword do in Java?

a) Declares a new variable
b) Creates a new object
c) Starts a new method
d) Declares a new type

12. What is encapsulation in Java?

a) Protecting data by declaring it as static
b) The concept of hiding the internal details of an object and exposing only the necessary parts
c) Inheritance from one class to another
d) Overriding methods in a subclass

13. Which of the following is an infinite loop?

a) for(int i=0; i<10; i++) { … }
b) while(true) { … }
c) while(false) { … }
d) None of the above

14. Which method would you use to find the length of a string s in Java?

a) s.length()
b) s.size()
c) s.length
d) Length(s)

15. How do you read input from the keyboard in Java?

a) Scanner input = new Scanner(;
b) Console input =;
c) BufferReader input = new BufferReader(new InputStreamReader(;
d) Scanner input = System.getInput();

16. What is the purpose of the continue keyword in Java?

a) Terminates the loop immediately
b) Skips the current iteration of the loop and proceeds to the next iteration
c) Continues to execute the same iteration
d) Exits the program

17. What are wrapper classes in Java?

a) Classes that contain primitive types within objects
b) Classes that wrap user-defined objects
c) Classes that are used to wrap return values
d) None of the above

18. What does the expression int[] arr = {1, 2, 3, 4}; do?

a) Declares an array
b) Instantiates an array
c) Initializes an array
d) All of the above

19. Which access specifier in Java makes a member accessible only within its own class?

a) private
b) protected
c) public
d) none of the above

20. What is polymorphism in Java?

a) A method that performs differently based on the input parameters
b) The ability of different objects to respond to the same method call in different ways
c) Multiple methods with the same name
d) None of the above

21. What does the static keyword denote in Java?

a) The variable or method belongs to the instance of a class
b) The variable or method belongs to the class, rather than any instance
c) The method cannot be overridden
d) The variable cannot be changed

22. What is an exception in Java?

a) An error that occurs during the execution of a program
b) A compile-time error
c) A type of class
d) A method that handles errors

23. What is the default value of a String object in Java?

a) “”
b) ‘ ‘
c) null
d) undefined

24. What does the final keyword mean when applied to a method?

a) The method cannot be deleted
b) The method cannot have its value changed
c) The method cannot be overridden by subclasses
d) The method will execute faster

25. What is the output of System.out.println(10 + 20 + “Hello” + 10 + 20);?

a) 30Hello1020
b) 30Hello30
c) 1020Hello1020
d) 1020Hello30

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top