In this post, you can test your knowledge of Java fundamental concepts.

What is Java?

a) Database
b) Operating System
c) Programming Language
d) File format

Answer:

c) Programming Language

Explanation:

Java is a widely-used object-oriented programming language.

2. Which company developed Java?

a) Microsoft
b) Oracle
c) Apple
d) Sun Microsystems

Answer:

d) Sun Microsystems

Explanation:

Java was originally developed by Sun Microsystems, which was later acquired by Oracle Corporation.

3. What does JVM stand for?

a) Java Virtual Mechanism
b) Java Varying Machine
c) Java Verified Method
d) Java Virtual Machine

Answer:

d) Java Virtual Machine

Explanation:

JVM stands for Java Virtual Machine, which provides the runtime environment for executing Java bytecode.

4. Which keyword is used to create an object in Java?

a) object
b) create
c) new
d) make

Answer:

c) new

Explanation:

The new keyword is used to create a new instance of a class in Java.

5. What is the default value of a boolean data type in Java?

a) true
b) false
c) 0
d) null

Answer:

b) false

Explanation:

The default value of the boolean data type in Java is false.

6. What is the superclass of all Java classes?

a) Object
b) Java
c) SuperClass
d) Class

Answer:

a) Object

Explanation:

In Java, the Object class is the ultimate parent class of all classes.

7. Which of these keywords is used to inherit a class?

a) inherits
b) extends
c) implements
d) uses

Answer:

b) extends

Explanation:

The extends keyword is used to inherit properties and behavior from a superclass.

8. Which method is called when an object is instantiated from a class?

a) constructor
b) initialize
c) new
d) Object

Answer:

a) constructor

Explanation:

A constructor method is called when an object is instantiated from a class. It has the same name as the class.

9. Which of the following is used to handle exceptions?

a) throw
b) throws
c) try-catch
d) error

Answer:

c) try-catch

Explanation:

try-catch blocks are used to handle exceptions in Java. throw and throws are related to exceptions but are used for different purposes.

10. What is the size of a long data type in Java?

a) 8 bits
b) 16 bits
c) 32 bits
d) 64 bits

Answer:

d) 64 bits

Explanation:

In Java, the long data type is 64 bits in size.