0% found this document useful (0 votes)
17 views7 pages

Java Interview Questions For Freshers PDF

This document outlines basic, intermediate, and advanced Java interview questions commonly asked for entry-level positions. It covers key concepts such as Java features, JVM, data types, OOP principles, exception handling, and the Java Collection Framework. Additionally, it includes distinctions between various Java components like ArrayList vs. LinkedList, String vs. StringBuilder, and more.

Uploaded by

GOURAV GHOSH
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views7 pages

Java Interview Questions For Freshers PDF

This document outlines basic, intermediate, and advanced Java interview questions commonly asked for entry-level positions. It covers key concepts such as Java features, JVM, data types, OOP principles, exception handling, and the Java Collection Framework. Additionally, it includes distinctions between various Java components like ArrayList vs. LinkedList, String vs. StringBuilder, and more.

Uploaded by

GOURAV GHOSH
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Basic Java Interview Questions for Freshers

These questions cover foundational concepts and are commonly asked in entry-level job
interviews.

What are the key features of Java?


Java is platform-independent, object-oriented, secure, and robust and supports multithreading
and automatic garbage collection.

What is the JVM?


The JVM (Java Virtual Machine) runs Java bytecode and allows Java programs to be
platform-independent.

What is the difference between JDK, JRE, and JVM?


●​ JDK: Java Development Kit (includes compiler + JRE)
●​ JRE: Java Runtime Environment (for running Java apps)
●​ JVM: Java Virtual Machine (executes bytecode)

What is a Class in Java?


A class is a blueprint for creating objects. It defines properties and methods.

What is an Object in Java?


An object is an instance of a class containing state and behavior.

What are the data types in Java?


Java has two types:
●​ Primitive (int, char, boolean, etc.)
●​ Non-Primitive (arrays, classes, interfaces)

What is a Constructor?
A constructor is a special method used to initialize objects. It has the same name as the class.

What is the difference between == and equals()?


●​ == checks reference equality.
●​ equals() checks value/content equality.
What is Inheritance in Java?
Inheritance allows one class to acquire the properties of another class using the extends
keyword.

What is Polymorphism?
Polymorphism allows objects to take many forms. It can be:
●​ Compile-time (method overloading)
●​ Runtime (method overriding)

What is Abstraction?
Abstraction hides internal details and shows only functionality. Achieved using abstract classes
and interfaces.

What is Encapsulation?
Encapsulation wraps data and methods in a single unit (class) and restricts access using
access modifiers.

What is the 'static' keyword?


Used to declare class-level methods and variables.

What is final in Java?


Final makes variables constant, methods un-overridable, and classes non-inheritable.

What is a Package in Java?


A package groups related classes and interfaces to prevent naming conflicts.

What are Access Modifiers?


They control visibility:
●​ public
●​ private
●​ protected
●​ default

What is the default value of an int variable?


Zero (0).

What is method overloading?


Two or more methods with the same name but different parameters.
What is method overriding?
A subclass provides its version of a method declared in the parent class.

What is the difference between Stack and Heap memory?


●​ Stack stores local variables.
●​ Heap stores objects.

Java Interview Questions for Freshers – Intermediate Level


Once you clear basic interview questions, interviewers often test your problem-solving and
coding logic.

What is the difference between ArrayList and LinkedList?


●​ ArrayList is faster for retrieval.
●​ LinkedList is better for insert/delete operations.

What is Exception Handling?


It manages runtime errors using try-catch blocks to prevent program crashes.

What is the difference between checked and unchecked exceptions?


●​ Checked: Caught at compile-time (IOException)
●​ Unchecked: Caught at runtime (NullPointerException)

What is the difference between String, StringBuilder, and StringBuffer?


●​ String: Immutable
●​ StringBuilder: Mutable, not thread-safe
●​ StringBuffer: Mutable, thread-safe

What are Wrapper Classes in Java?


Wrapper classes convert primitives to objects (e.g., int to Integer).

What is an interface?
An interface defines a contract with abstract methods. Implemented using the implements
keyword.

What is the use of the super keyword?


It refers to the parent class constructor or method.
What is the difference between an abstract class and an interface?
●​ Abstract Class: Can have methods with implementation.
●​ Interface: Only abstract methods (till Java 7), multiple inheritance.

What is Multithreading?
Allows concurrent execution of two or more threads to maximize CPU usage.

What is Synchronization?
Used to control thread access to shared resources to prevent data inconsistency.

Advanced Java Interview Questions for Freshers with Answers


These advanced-level questions may appear in product-based companies or roles requiring
deeper Java knowledge.

What is the Collection Framework in Java?


It provides data structures like List, Set, and Map for handling and manipulating data.

Difference between HashMap and Hashtable?


HashMap is non-synchronized and faster.
Hashtable is synchronized and thread-safe.

What is Garbage Collection in Java?


The Garbage Collector automatically deallocates memory by destroying unused objects.

What is Serialization?
Serialization converts an object into a byte stream for storage or transmission.

What is Deserialization?
It converts a byte stream back to the object.

Explain the 'transient' keyword.


Prevents variables from being serialized.

What is the Java Reflection API?


Allows inspection of classes, methods, and fields at runtime.
What is the significance of equals() and hashCode()?
Used for object comparison and storing objects in collections like HashMap.

Difference between Comparable and Comparator?


●​ Comparable: Used for natural ordering.
●​ Comparator: Custom ordering logic.

What are Lambda Expressions?


Introduced in Java 8, they enable functional programming with concise code.

What is Stream API?


Also introduced in Java 8, used to process collections in a functional style.

What is the Optional class?


It’s a container that may or may not contain a non-null value to avoid NullPointerExceptions.

What are Functional Interfaces?


Interfaces with a single abstract method, used in lambda expressions.

What is the difference between a List and a Set?


●​ List: Ordered, allows duplicates.
●​ Set: Unordered, no duplicates.

What is a ConcurrentHashMap?
A thread-safe version of HashMap for concurrent access.

What are annotations in Java?


Provide metadata for code. E.g., @Override, @Deprecated, @FunctionalInterface

What is a classloader in Java?


Loads classes into the JVM during runtime.

What are the types of class loaders?


●​ Bootstrap
●​ Extension
●​ System/Application
What is the volatile keyword?
Ensures changes to variables are visible across threads.

What is the Java Memory Model?


Defines how threads interact through memory, ensuring consistent visibility and ordering.

Core Java Interview Questions for Freshers


These are the most expected core Java interview questions for freshers that recruiters
commonly ask.

What are the OOP principles in Java?


●​ Inheritance
●​ Encapsulation
●​ Polymorphism
●​ Abstraction

What is the difference between an interface and a class?


A class can have implemented methods; an interface only contains method signatures (Java 7
and below).

Explain access modifiers in Java.


They define visibility:
●​ public: Everywhere
●​ private: Inside class only
●​ protected: Same package or subclass
●​ default: Package-level access

What is constructor overloading?


Multiple constructors in the same class with different parameters.

What is a static block?


Used for static initializations. It runs once when the class is loaded.

What is the purpose of the ‘this’ keyword?


Refers to the current class instance.
What is a nested class?
A class within another class. Can be static or non-static.

What are enums in Java?


Enums define a fixed set of constants. Introduced in Java 5.

What is the default constructor?


A no-argument constructor is provided by the compiler if no other constructors are defined.

What are the different loops in Java?


●​ for
●​ while
●​ do-while
●​ For-each

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy