Expanded Java Interview Questions: A Comprehensive Guide for 2023
Java continues to be a dominant force in the software development world. Whether you’re a beginner or an expert, understanding Java’s features and concepts is crucial for acing your next job interview. This expanded guide aims to cover a wide range of topics, including serialization, design patterns, and more.
1. Number of Primitive Data Types in Java
Java has 8 primitive data types: byte, short, int, long, float, double, char, and boolean.
2. Which Class in Java is Used to Take Input from the User?
Scanner class is commonly used to take input from the user.
3. When is the Object Created with the
An object in Java is created at runtime when the
new keyword is used.
4. What is Serialization and Deserialization in Java?
Serialization is the process of converting an object’s state into a byte stream, while deserialization is the reverse process. This is often used for data storage or transmission.
5. Explain the
transient Keyword in Java
transient keyword in Java is used to indicate that a variable should not be serialized. This is useful when you want to skip certain sensitive or temporary fields during serialization.
6. What is the
volatile Keyword in Java?
volatile keyword in Java is used to indicate that a variable’s value may be changed by multiple threads. It ensures that the value of the variable is read from the main memory, not the thread’s local cache.
7. What is the
final Keyword in Java?
final keyword can be used to mark a variable as unmodifiable, a method as non-overridable, or a class as non-inheritable.
8. Design Patterns in Java
Design patterns like Singleton, Factory, and Observer are commonly used in Java to solve specific problems in a flexible and clean way.
9. In Java, Arrays Are?
Arrays in Java are objects that store multiple variables of the same type. They are static, meaning their size can’t be changed once declared.
10. Arrays That Are Declared Dynamically Using the
new Keyword Are?
Arrays declared dynamically using the
new keyword are created at runtime and can be resized using utility classes like
11. Identify the Modifier Which Cannot Be Used for Constructor
static modifier cannot be used for constructors in Java.
12. What is the Implicit Return Type of Constructor?
The implicit return type of a constructor is the class type itself.
13. Which One is a Template for Creating Different Objects?
A class serves as a template for creating different objects in Java.
14. A Binary Tree Has L Leaves and K Internal Nodes
For a binary tree, �=�+1, where � is the number of leaves and � is the number of internal nodes.
15. Which of These Class is Superclass of Every Class in Java?
Object class is the superclass of every class in Java.
16. Which of the Below is Not a Java Profiler?
JProfiler, YourKit, and VisualVM are Java profilers. NetBeans, however, is an IDE, not a profiler.
17. Which of the Following is Not a Java Keyword?
sizeof is not a Java keyword.
18. Which One of the Following is Not a Java Feature?
Multiple inheritance is not a feature in Java.
19. What is the Extension of Java Code Files?
The extension for Java code files is
20. Which of the Following is Not an OOPs Concept in Java?
Method overloading is not considered an OOPs concept in Java.
21. Which Keyword is Used for Accessing the Features of a Package?
import keyword is used for this purpose.
22. What is the Extension of Java Code Files?
Java code files have the extension
Java is a multifaceted language with a wide array of features and functionalities. This comprehensive guide aims to cover questions that span from basic to advanced topics, providing you with the arsenal you need to excel in your next Java interview.