Home Videos Exercises MCQ Q&A Quiz Services Sign in

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

Answer: (d) .java



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

Answer: (d) JDB



4. What is the extension of compiled java classes?

a) .txt

b) .js

c) .class

d) .java

View Answer

Answer: (c) .class



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

Answer: (d) if()



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

Answer: (c) Object class



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

Answer: (c) 0 to 65535



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

Answer: (b) objects



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

Answer: (b) at runtime



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

Answer: (b) import



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

Answer: (d) all of these



17. Which one of the following is an Unary operator in Java?

a) ()

b) *

c) +

d) ++

View Answer

Answer: (d) ++



18. Which of the following operator has more precedence?

a) ()

b) ++

c) *

d) >=

View Answer

Answer: (a) ()



19. Which of the following is not an operator in Java?

a) |

b) ^

c) ~

d) <->

View Answer

Answer: (d) <->



20. What was the original name for Java?

a) C++

b) Oak

c) Pine

d) Maple

View Answer

Answer: (b) Oak



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

Answer: (c) Excecution



25. Can you run a Java without JRE?

a) Yes

b) No

c) cant say

d) none of these

View Answer

Answer: (b) No



26. Is JVM platform-independent?

a) Yes

b) No

c) cant say

d) none of these

View Answer

Answer: (b) No



27. What operator is used to perform bitwise "AND" operation?

a) &&

b) &

c) |

d) ||

View Answer

Answer: (b) &



28. What does the == operator compare in Java objects?

a) Values

b) References

c) Hash codes

d) Fields

View Answer

Answer: (b) References



29. Which operator is used for logical "AND" operation?

a) &&

b) &

c) ||

d) |

View Answer

Answer: (a) &&



30. Which of the following is not a primitive data type in Java?

a) byte

b) String

c) double

d) short

View Answer

Answer: (b) String



31. What is the default value of the int data type?

a) 0

b) 1

c) null

d) undefined

View Answer

Answer: (a) 0



32. Which of the following data types can store a floating-point number?

a) int

b) byte

c) double

d) char

View Answer

Answer: (c) double



33. Which data type can store a single character?

a) String

b) byte

c) char

d) int

View Answer

Answer: (c) char



34. How many bits does the long data type use?

a) 8

b) 16

c) 32

d) 64

View Answer

Answer: (d) 64



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

Answer: (d) both b and c



38. Which of the following has the highest memory requirement?

a) Heap

b) Stack

c) JVM

d) Class

View Answer

Answer: (c) JVM



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