Java Interview Questions and Answers | Intermediate Level – PLM Developer

Here are a few intermediate-level Java Interview Questions and Answers. This post's interview questions and answers are mostly useful for freshers and 2-4 experienced candidates.

Q.What is the difference between this and super in Java?

this and super are keywords in Java; both keywords are used to access variables and methods. this keyword is used to refer to the current class instance, and super is used to represent superclass reference from subclass


Q.What is serializable in Java?

- Serialization is the process of converting the state of an object into a byte stream. If you want a class object to be serializable, then you need to implement the interface. Serializable marker interface in Java and has no fields or methods to implement.

- Deserialization is the process of converting byte stream to the actual Java object in memory. 

Q.What is transient in Java?

- The transient keyword is used to avoid Serialization. If we define any data member as transient, It will not be serialized.

If JVM finds any data member defined as a transient, it ignores the variable's original value and saves the default value.

Q.What is the volatile keyword?

- If any variable is defined as volatile, then the value of the variable is not cached. The value of that variable always gets from the main memory instead of cached memory.

- volatile keyword is applicable for variables, methods, and classes. If a variable is volatile, then the variable is thread-safe multiple threads can operate on that variable simultaneously. 

Q.What is the final keyword in Java?

- final is a keyword in Java. It applies to variables, methods, and classes.

- If a variable is final then the values of the variable becomes constant we cannot change the value of the variable

- If a method is final then we cannot override the method in subclasses

- If a class is final, then we cannot extend the class.

Q.What are wrapper classes in Java?

- Wrapper classes are used to convert primitive data types to objects and vice-versa.

- Data Structures like ArrayList and Vector store only objects not primitives (because values pass primitives).

Q.What are autoboxing and auto unboxing?

- The Automatic conversion of primitives to their corresponding wrapper classes is called autoboxing.

  Example: int to Integer, long to Long, double to Double

- The Automatic conversion of wrapper classes to their corresponding primitives is called auto unboxing.

  Example: Integer to int, Long to long, Double to double


See Also:

👉Java Interview Questions & Answers 1

👉Java Interview Questions & Answers 2

👉Java Interview Questions & Answers 3


Post a Comment