Java Multiple Choice Questions (MCQs) and Answers

Java MCQs

1. Which of the following is not an OOP concept in Java?

a) Abstraction
b) Inheritance
c) Polymorphism
d) Multithreading

Answer: d) Multithreading

2. Which keyword is used to prevent inheritance in Java?

a) final
b) void
c) abstract
d) strictfp

Answer: a) final

3. Which of these methods can be overridden in Java?

a) private methods
b) final methods
c) static methods
d) protected methods

Answer: d) protected methods

4. Which of these is not a valid long literal in Java?

a) 0x99fffL
b) 99999
c) 0994466L
d) 9_9_9_9

Answer: b) 99999

5. Which interface is used to iterate over objects in Java?

a) Collection
b) Iterator
c) ListIterator
d) Iterable

Answer: b) Iterator

6. Which of these keywords is used to define a variable in Java?

a) var
b) let
c) int
d) define

Answer: c) int

7. Which of these methods converts a String to an Integer in java?

a) toInteger()
b) parseInt()
c) toInt()
d) stringToInteger()

Answer: b) parseInt()

8. Which of these access specifiers can be used for an interface in Java?

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

Answer: a) public

9. Which exception is thrown when an array is accessed with an illegal index?

a) ArrayIndexOutOfBoundsException
b) ArrayOutOfBoundsException
c) IndexOutOfBoundsException
d) IllegalArrayAccessException

Answer: a) ArrayIndexOutOfBoundsException

10. Which of these keywords is used to import a package in Java?

a) import
b) include
c) open
d) using

Answer: a) import

Leave a Reply

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