Home
MCQS
Java MCQ Quiz Hub
Java Multiple Choice Questions
Choose a topic to test your knowledge and improve your Java skills
1. Which of the following option leads to the portability and security of Java?
Bytecode is executed by JVM
The applet makes the Java code secure and portable
Use of exception handling
Dynamic binding between objects
2. Which of the following is not a Java features?
Dynamic
Architecture Neutral
Use of pointers
Object-oriented
3. The u0021 article referred to as a
Unicode escape sequence
Octal escape
Hexadecimal
Line feed
4. _____ is used to find and fix bugs in the Java programs.
JVM
JRE
JDK
JDB
5. What is the return type of the hashCode() method in the Object class?
Object
int
long
void
6. Which of the following is a valid long literal?
ABH8097
L990023
904423
0xnf029L
7. What does the expression float a = 35 / 0 return?
0
Not a Number
Infinity
Run time exception
8. Evaluate the following Java expression if x=3 y=5 and z=10: ++z + y - y + z + x++
24
23
20
25
9. Which of the following tool is used to generate API documentation in HTML format from doc comments in source code?
javap tool
javaw command
Javadoc tool
javah command
10. Which of the following creates a List of 3 visible items and multiple selections abled?
new List(false 3)
new List(3 true)
new List(true 3)
new List(3 false)
11. Which of the following for loop declaration is not valid?
for ( int i = 99; i >= 0; i / 9 )
for ( int i = 7; i <= 77; i += 7 )
for ( int i = 20; i >= 2; - -i )
for ( int i = 2; i <= 20; i = 2* i )
12. Which method of the Class.class is used to determine the name of a class represented by the class object as a String?
getClass()
intern()
getName()
toString()
13. In which process a local variable has the same name as one of the instance variables?
Serialization
Variable Shadowing
Abstraction
Multi-threading
14. Which package contains the Random class?
java.util package
java.lang package
java.awt package
java.io package
15. What do you mean by nameless objects?
An object created by using the new keyword.
An object of a superclass created in the subclass.
An object without having any name but having a reference.
An object that has no reference.
16. An interface with no fields or methods is known as a ______.
Runnable Interface
Marker Interface
Abstract Interface
CharSequence Interface
17. Which of the following is an immediate subclass of the Panel class?
Applet class
Window class
Frame class
Dialog class
18. Which option is false about the final keyword?.
A final method cannot be overridden in its subclasses.
A final class cannot be extended.
A final class cannot extend other classes
A final method can be inherited.
19. Which of these classes are the direct subclasses of the Throwable class?
RuntimeException and Error class
Exception and VirtualMachineError class
Error and Exception class
IOException and VirtualMachineError class
20. What do you mean by chained exceptions in Java?
Exceptions occurred by the VirtualMachineError
An exception caused by other exceptions
Exceptions occur in chains with discarding the debugging information
None of the above
21. In which memory a String is stored when we create a string using new operator?
Stack
String memory
Heap memory
Random storage space
22. What is the use of the intern() method?
It returns the existing string from memory
It creates a new string in the database
It modifies the existing string in the database
None of the above
23. Which of the following is a marker interface?
Runnable interface
Remote interface
Readable interface
Result interface
24. Which of the following is a reserved keyword in Java?
object
strictfp
main
system
25. Which keyword is used for accessing the features of a package?
package
import
extends
Export
26. In java jar stands for_____.
Java Archive Runner
Java Application Resource
Java Application Runner
None of the above
27. Which of the following is false?
The rt.jar stands for the runtime jar
It is an optional jar file
It contains all the compiled class files
All the classes available in rt.jar is known to the JVM
28. What is the use of w in regex?
Used for a whitespace character
Used for a non-whitespace character
Used for a word character
Used for a non-word character
29. Which of the given methods are of Object class?
notify() wait( long msecs ) and synchronized()
wait( long msecs ) interrupt() and notifyAll()
notify() notifyAll() and wait()
sleep( long msecs ) wait() and notify()
30. Given that Student is a class how many reference variables and objects are created by the following code? Student studentName studentId; studentName = new Student(); Student stud_class = new Student();
Three reference variables and two objects are created.
Two reference variables and two objects are created.
One reference variable and two objects are created.
Three reference variables and three objects are created.
Submit