Java Basic MCQs (Long Quiz)

This is the quiz about basics of Java. Students and new learner's can test their knowledge.

Jun 13, 2021 - 22:26
Jun 14, 2021 - 13:42
 0  59

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. Which of the following is a valid declaration of a char?

char ch = '\utea';
char ca = 'tea';
char cr = \u0223;
char cc = '\itea';

6. What is the return type of the hashCode() method in the

Object class? Object
int
long
void

7. Which of the following is a valid long literal?

ABH8097
L990023
904423
0xnf029L

8. What does the expression float a = 35 / 0 return?

0
Not a Number
Infinity
Run time exception

9. Evaluate the following Java expression, if x=3, y=5, and z=10: ++z + y - y + z + x++

24
23
20
25

10. 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

11. 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)

12. 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 )

13. 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()

14. In which process, a local variable has the same name as one of the instance variables?

Serialization
Variable Shadowing
Abstraction
Multi-threading

15. Which of the following is true about the anonymous inner class?

It has only methods
Objects can't be created
It has a fixed class name
It has no class name

16. Which package contains the Random class?

java.util package
java.lang package
java.awt package
java.io package

17. 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.

18. An interface with no fields or methods is known as a ______.

Runnable Interface
Marker Interface
Abstract Interface
CharSequence Interface

19. Which of the following is an immediate subclass of the Panel class?

Applet class
Window class
Frame class
Dialog class

20. 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.

21. 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

22. 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
None of the above

23. In which memory a String is stored, when we create a string using new operator?

Stack
String memory
Heap memory
Random storage space

24. 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

25. Which of the following is a marker interface?

Runnable interface
Remote interface
Readable interface
Result interface

26. Which of the following is a reserved keyword in Java?

object
strictfp
main
system

27. Which keyword is used for accessing the features of a package?

package
import
extends
export

28. In java, jar stands for_____.

Java Archive Runner
Java Application Resource
Java Application Runner
None of the above

29. 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

30. 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

What's Your Reaction?

like

dislike

love

funny

angry

sad

wow