JAVA MCQ
Soopro Pathshala provides JAVA MCQ(Multiple Choice Questions)
1. What is the extension of java code files?
a) .js
b) .txt
c) .class
d) .java
View Answer
2. Which of the following is not a Java features?
a) Dynamic
b) Architecture Neutral
c) Use of pointers
d) Object-oriented
View Answer
Answer: (c) Use of pointers
3. _____ is used to find and fix bugs in the Java programs.
a) JVM
b) JRE
c) JDK
d) JDB
View Answer
4. What is the extension of compiled java classes?
a) .txt
b) .js
c) .class
d) .java
View Answer
5. Which exception is thrown when java is out of memory?
a) MemoryError
b) OutOfMemoryError
c) MemoryOutOfBoundsException
d) MemoryFullException
View Answer
Answer: (b) OutOfMemoryError
6. Which of these are selection statements in Java?
a) break
b) continue
c) for()
d) if()
View Answer
7. Which of the following is a superclass of every class in Java?
a) ArrayList
b) Abstract class
c) Object class
d) String
View Answer
8. What is the numerical range of a char data type in Java?
a) 0 to 256
b) -128 to 127
c) 0 to 65535
d) 0 to 32767
View Answer
9. Which of the following is true about the anonymous inner class?
a) It has only methods
b) objects can't be created
c) it has a fixed class name
d) it has not class name
View Answer
Answer: (d) It has no class name
10. Arrays in java are___
a) object references
b) objects
c) primitive data type
d) none
View Answer
11. When is the object created with new keyword?
a) at compile time
b) at runtime
c) depends on the code
d) none
View Answer
12. In which of the following is toString() method defined?
a) java.lang.object
b) java.lang.string
c) java.lang.util
d) none
View Answer
Answer: (a) java.lang.object
13. What is false about constructor?
a) Constructors cannot be synchronized in Java
b) Java does not provide default copy constructor
c) Constructor can have a return type
d) “this” and “super” can be used in a constructor
View Answer
Answer: (c) Constructor can have a return type
14. Which keyword is used for accessing the features of a package?
a) package
b) import
c) extends
d) export
View Answer
15. In java, jar stands for___
a) Java Archive Runner
b) Java Application Resource
c) Java Application Runner
d) none of the above
View Answer
Answer: (d) none of the above
16. On which platforms java runs?
a) Windows
b) Mac OS
c) UNIX
d) all of these
View Answer
17. Which one of the following is an Unary operator in Java?
a) ()
b) *
c) +
d) ++
View Answer
18. Which of the following operator has more precedence?
a) ()
b) ++
c) *
d) >=
View Answer
19. Which of the following is not an operator in Java?
a) |
b) ^
c) ~
d) <->
View Answer
20. What was the original name for Java?
a) C++
b) Oak
c) Pine
d) Maple
View Answer
21. What does JVM stand for?
a) Java version machine
b) Java Virtual mechanism
c) Java Verfified Module
d) Java Virtual Machine
View Answer
Answer: (d) Java Virtual Machine
22. What does JDK include?
a) Only a compiler
b) only a runtime environment
c) both a compiler and a runtime environment
d) none of the above
View Answer
Answer: (c) both a compiler and a runtime environment
23. Which of the following is NOT a part of the JRE?
a) Bytecode verifier
b) class loader
c) Java Compiler
d) Java API classes
View Answer
Answer: (c) Java Compiler
24. What is the primary function of JRE?
a) Compilation
b) Debugging
c) Execution
d) Development
View Answer
25. Can you run a Java without JRE?
a) Yes
b) No
c) cant say
d) none of these
View Answer
26. Is JVM platform-independent?
a) Yes
b) No
c) cant say
d) none of these
View Answer
27. What operator is used to perform bitwise "AND" operation?
a) &&
b) &
c) |
d) ||
View Answer
28. What does the == operator compare in Java objects?
a) Values
b) References
c) Hash codes
d) Fields
View Answer
29. Which operator is used for logical "AND" operation?
a) &&
b) &
c) ||
d) |
View Answer
30. Which of the following is not a primitive data type in Java?
a) byte
b) String
c) double
d) short
View Answer
31. What is the default value of the int data type?
a) 0
b) 1
c) null
d) undefined
View Answer
32. Which of the following data types can store a floating-point number?
a) int
b) byte
c) double
d) char
View Answer
33. Which data type can store a single character?
a) String
b) byte
c) char
d) int
View Answer
34. How many bits does the long data type use?
a) 8
b) 16
c) 32
d) 64
View Answer
35. What is an infinite loop?
a) A loop that executes only once
b) A loop that never terminates naturally
c) A loop that contains an unreachable code block
d) A loop that uses the continue statement
View Answer
Answer: (b) A loop that never terminates naturally
36. Which statement is used to exit a loop prematurely?
a) return statement
b) continue statement
c) break statement
d) exit statement
View Answer
Answer: (c) break statement
37. How do you declare an array in Java?
a) int arrayName;
b) int [] arrayName
c) int arrayName[];
d) both b and c
View Answer
38. Which of the following has the highest memory requirement?
a) Heap
b) Stack
c) JVM
d) Class
View Answer
39. Which of these can be overloaded?
a) Methods
b) Constructors
c) all of the mentioned
d) none of the mentioned
View Answer
Answer: (c) all of the mentioned
40. Which of the following is a mutable class in java?
a) java.lang.string
b) java.lang.byte
c) java.lang.object
d) java.lang.stringbuilder
View Answer
Answer: (d) java.lang.strinbuilder