JAVA MCQ QUESTIONS For Quizzes
JAVA MCQ QUESTIONS For Quizzes
FOR QUIZZES
BEGINNER FRIENDLY QUESTIONS
1. Who is known as the father of Java programming language?
a) Dennis Ritchie
b) Bjarne Stroustrup
c) James Gosling
d) Ken Thompson
Answer: c) James Gosling
2. Which of the following is a valid data type in Java?
a) double
b) integer
c) real
d) float64
Answer: a) double
3. What is the default value of a local variable in Java?
a) 0
b) null
c) Depends on the data type
d) No default value
Answer: d) No default value
4. Which keyword is used to declare a class in Java?
a) class
b) object
c) define
d) create
Answer: a) class
5. Which of the following is not a Java feature?
a) Object-Oriented
b) Platform-Independent
c) Use of Pointers
d) Multi-threaded
Answer: c) Use of Pointers
6. Which method is the entry point for a Java application?
a) init()
b) main()
c) start()
d) public()
Answer: b) main()
7. What is the extension of Java compiled files?
a) .java
b) .class
c) .exe
d) .javac
Answer: b) .class
8. Which of these is used to create an object in Java?
a) constructor
b) import
c) new
d) instance
Answer: c) new
9. What does JVM stand for?
a) Java Variable Machine
b) Java Virtual Machine
c) Java Visible Mode
d) Java Visual Machine
Answer: b) Java Virtual Machine
10. Which of the following is not a primitive data type in Java?
a) int
b) float
c) boolean
d) String
Answer: d) String
11. Which operator is used to compare two values in Java?
a) =
b) ==
c) !=
d) ===
Answer: b) ==
12. How do you declare an array in Java?
a) int arr[5];
b) int arr = new int[5];
c) int arr() = 5;
d) array int arr[5];
Answer: b) int arr = new int[5];
13. Which of these loops is guaranteed to execute at least once?
a) for
b) while
c) do-while
d) None
Answer: c) do-while
14. What is the size of int in Java?
a) 16 bits
b) 32 bits
c) 64 bits
d) Depends on the system
Answer: b) 32 bits
15. What does "static" keyword mean in Java?
a) A variable that belongs to the object
b) A method or variable shared among all instances of a class
c) A method only accessible within a package
d) None of the above
Answer: b) A method or variable shared among all instances of a class
16. Which of these is not a valid Java keyword?
a) static
b) try
c) NULL
d) final
Answer: c) NULL
17. Which of these is used to handle exceptions in Java?
a) error
b) try-catch
c) exception
d) throw-new
Answer: b) try-catch
18. Which of the following packages is automatically imported in Java?
a) java.awt
b) java.io
c) java.lang
d) java.net
Answer: c) java.lang
19. Which method is used to terminate a thread in Java?
a) terminate()
b) stop()
c) exit()
d) end()
Answer: b) stop()