Java Interview Questions Series Part 1

1. What is java bytecode?

Java bytecode is the instruction set of the Java Virtual Machine (JVM), which allows Java
programs to run on different platforms.
Java bytecode is generated by the Java compiler from the source code, and can be
executed by the JVM or other tools

2. Give full form of JIT.

JIT stands for Just-In-Time, which is a technique of compiling Java bytecode into native
machine code at runtime, to improve the performance of Java programs

3. Explain static variable.

A static variable is a variable that belongs to the class rather than the instance of the
class. A static variable is shared by all objects of the class, and can be accessed without
creating an object. A static variable is initialized only once, at the start of the execution

4. What is garbage collector?

A garbage collector is a piece of software that performs automatic memory management
in Java. It frees the memory occupied by the objects that are no longer referenced by the
program, and prevents memory leaks and fragmentation

5. How do you declare a generic class?

To declare a generic class in Java, you need to use the angle brackets (<>) after the class
name, and specify one or more type parameters that can represent any reference type.
For example:
class Test {
T obj;
// constructor, methods, etc.

6. State one advantage of using generic types.

One advantage of using generic types in Java is that they provide type safety, which
means that the compiler can check the compatibility of the types at compile time, and
prevent errors and bugs at runtime. Generics also eliminate the need for type casting,
which can improve the readability and performance of the code

7. Which class is a superclass of every class in Java?

The class named Object, in the java language package, is the superclass of every class in
Java. Every class inherits the methods and fields of the Object class, either directly or

8. Which keyword is used to inherit a class?

To inherit a class in Java, you need to use the extends keyword, which indicates that the
subclass inherits the features of the superclass. For example:
class Subclass extends Superclass {
// fields, methods, etc.

9. Explain this keyword.

This keyword in Java is a reference variable that refers to the current object of a method
or a constructor. The main purpose of using this keyword in Java is to remove the
confusion between class attributes and parameters that have the same name.

Post a Comment

* Please Don't Spam Here. All the Comments are Reviewed by Admin.