Junior Java Developer

100+ Junior Java Developer Interview Questions and Answers

Updated 12 Jul 2025
search-icon

Q. For a circular cake shared by 8 members, what is the minimum number of cuts required to divide the cake equally?

Ans.

To cut a circular cake for 8 members equally, only 2 straight cuts are needed.

  • Make the first cut through the center, dividing the cake into 2 equal halves.

  • Make the second cut perpendicular to the first, creating 4 equal quarters.

  • Each quarter can then be further divided into 2 equal pieces, resulting in 8 equal slices.

  • This method minimizes the number of cuts while ensuring equal distribution.

6d ago

Q. What are the dependencies present in Spring, and can you explain them?

Ans.

Spring has various dependencies like Spring Core, Spring MVC, Spring ORM, etc.

  • Spring Core provides the basic functionality of the Spring framework

  • Spring MVC is used for building web applications

  • Spring ORM provides integration with Object Relational Mapping frameworks

  • Spring Data provides a consistent approach to data access

  • Spring Security provides authentication and authorization

  • Spring Boot provides an opinionated way of building Spring applications

  • Examples of dependencies inc...read more

Junior Java Developer Interview Questions and Answers for Freshers

illustration image
6d ago

Q. Why we need Oops concepts? What is Constructor? Need of Constructor? StringBuilder? etc.

Ans.

OOPs concepts are important for code reusability, maintainability, and scalability. Constructors are special methods used to initialize objects.

  • OOPs concepts help in creating modular, reusable, and maintainable code.

  • Inheritance, polymorphism, encapsulation, and abstraction are the four pillars of OOPs.

  • Constructors are special methods used to initialize objects with default or user-defined values.

  • StringBuilder is a class used to manipulate strings efficiently.

  • It is important t...read more

6d ago

Q. Can you override a static method?

Ans.

Yes, static methods cannot be overridden in Java.

  • Static methods belong to the class itself, not to any specific instance of the class.

  • They can be accessed using the class name directly.

  • When a subclass defines a static method with the same signature as a static method in the superclass, it is called method hiding, not overriding.

  • The subclass can have its own static method with the same name as the superclass, but it does not override the superclass method.

Are these interview questions helpful?

Q. What are the aggregate functions in SQL?

Ans.

Aggregate functions in SQL are used to perform calculations on a set of values and return a single value.

  • Common aggregate functions include COUNT, SUM, AVG, MIN, and MAX.

  • COUNT returns the number of rows that match a specified condition.

  • SUM calculates the sum of a column's values.

  • AVG calculates the average of a column's values.

  • MIN returns the minimum value in a column.

  • MAX returns the maximum value in a column.

  • Aggregate functions can be used with the GROUP BY clause to perform ...read more

3d ago

Q. What is the String pool in Java, and when would you use a String versus a character array for sensitive data?

Ans.

The String pool in Java is a special memory area for storing String literals, optimizing memory usage and performance.

  • String Pool: Java maintains a pool of String literals in the heap memory, allowing for memory efficiency by reusing immutable String objects.

  • String vs Character Array: Strings are immutable, while character arrays can be modified, making arrays preferable for sensitive data to avoid unintentional exposure.

  • Example of String Pool: When you create a String like '...read more

Junior Java Developer Jobs

Capgemini Technology Services India Limited logo
Junior Java Developer 1-4 years
Capgemini Technology Services India Limited
3.7
Bangalore / Bengaluru
Numinolabs logo
Jr. Java Developer 2-4 years
Numinolabs
4.4
South Goa
Redrock IT Solutions logo
Junior Java Developer - Full Stack Technologies (0-1 yrs) 0-1 years
Redrock IT Solutions
4.6
1d ago

Q. What is the difference between an interface and an abstract class? Please provide examples of business logic for each.

Ans.

Interfaces define contracts for classes, while abstract classes provide a base with shared code and can have state.

  • An interface can only declare methods (no implementation), while an abstract class can have both abstract and concrete methods.

  • A class can implement multiple interfaces but can inherit from only one abstract class.

  • Example of an interface: 'PaymentProcessor' with methods like 'processPayment()'.

  • Example of an abstract class: 'Employee' with common properties like '...read more

5d ago

Q. What is OOPs concept in Java? Explain what Inheritance is, polymorphism, encapsulation and abstraction? What is default key word? Explain collection details? You can get more from interview question online.

Ans.

OOPs concept in Java includes Inheritance, polymorphism, encapsulation, and abstraction. Default keyword is used in Java for default values. Collections in Java are used to store and manipulate groups of objects.

  • Inheritance allows a class to inherit properties and behavior from another class. Example: class B extends class A.

  • Polymorphism allows objects to be treated as instances of their parent class. Example: Animal class can have subclasses like Dog and Cat.

  • Encapsulation is...read more

Share interview questions and help millions of jobseekers 🌟

man-with-laptop
1d ago

Q. How does the Java Virtual Machine (JVM) handle method overloading and method overriding during runtime?

Ans.

JVM distinguishes method overloading at compile-time and method overriding at runtime using dynamic dispatch.

  • Method Overloading: Same method name, different parameters. Resolved at compile-time.

  • Example: 'void display(int a)' and 'void display(String b)' are overloaded methods.

  • Method Overriding: Same method name and parameters in subclass. Resolved at runtime.

  • Example: 'class Animal { void sound() { } }' and 'class Dog extends Animal { void sound() { } }'.

  • Dynamic Dispatch: JVM ...read more

Q. What types of applications can be developed using the Java programming language?

Ans.

Java can be used to develop a wide range of applications, from web to mobile and enterprise solutions.

  • Web Applications: Java is widely used for building dynamic web applications using frameworks like Spring and JavaServer Faces.

  • Mobile Applications: Android development primarily uses Java, allowing developers to create apps for Android devices.

  • Enterprise Applications: Java EE (Enterprise Edition) is designed for large-scale applications, such as banking systems and CRM softwar...read more

2d ago

Q. String is an object,it provide sequence of characters 1.mutable string 2.immutable string Java support immutable string

Ans.

Java supports immutable strings which cannot be changed once created.

  • Immutable strings are created using the String class in Java.

  • Any operation that modifies a string actually creates a new string object.

  • Immutable strings are thread-safe and can be safely shared among multiple threads.

  • Examples of immutable strings in Java include string literals and strings created using the String constructor.

2d ago

Q. What are the interfaces and classes in the Java Collection Framework?

Ans.

Java collection framework provides interfaces and classes to store, manipulate, and retrieve collections of objects.

  • Interfaces: List, Set, Map, Queue, Deque

  • Classes: ArrayList, LinkedList, HashSet, HashMap, PriorityQueue

  • Example: List interface is implemented by classes like ArrayList and LinkedList

2d ago

Q. What is Hibernate and what are its uses?

Ans.

Hibernate is an ORM tool that simplifies database access in Java applications.

  • Hibernate maps Java classes to database tables and provides a framework for querying and manipulating data.

  • It eliminates the need for writing SQL queries and handles database transactions automatically.

  • Hibernate supports caching, lazy loading, and optimistic locking to improve performance.

  • It can be integrated with various databases and application servers.

  • Example: Hibernate can be used to create a w...read more

4d ago

Q. What is responsible for executing Java programs?

Ans.

Java Virtual Machine (JVM) is responsible for executing Java programs.

  • JVM is a virtual machine that interprets compiled Java code.

  • It provides a runtime environment for Java programs to run.

  • JVM is platform-independent and provides memory management, security, and other features.

  • Java programs are compiled into bytecode, which is then executed by the JVM.

  • JVM is responsible for loading classes, verifying bytecode, and executing the program.

1d ago

Q. How can you implement stateless authentication in a Spring Boot application?

Ans.

Stateless authentication in Spring Boot uses tokens to manage user sessions without server-side storage.

  • Use JWT (JSON Web Tokens) for stateless authentication.

  • Implement a filter to validate the JWT on each request.

  • Generate a JWT upon successful login and send it to the client.

  • Store user roles and permissions in the JWT claims.

  • Use Spring Security to secure endpoints and manage authentication.

6d ago

Q. In what scenarios would you choose to use a LinkedList over an ArrayList?

Ans.

Use LinkedList for frequent insertions/deletions, while ArrayList is better for random access and iteration.

  • 1. Frequent Insertions/Deletions: LinkedList allows O(1) time complexity for adding/removing elements at both ends.

  • 2. Memory Overhead: LinkedList uses more memory due to node pointers, but is efficient for large datasets with frequent changes.

  • 3. Iteration: ArrayList provides faster iteration due to contiguous memory allocation, but LinkedList is better for dynamic data....read more

3d ago

Q. what are 4 pillars of OOPs diffrence between String,String Buffer,String Builder Some questions on Collection framework

Ans.

4 pillars of OOPs, difference between String, StringBuffer, StringBuilder, and Collection framework

  • 4 pillars of OOPs: Abstraction, Encapsulation, Inheritance, Polymorphism

  • String is immutable, StringBuffer and StringBuilder are mutable

  • StringBuffer is synchronized, StringBuilder is not

  • Collection framework includes interfaces like List, Set, Map and their implementations

  • Commonly used classes in Collection framework: ArrayList, LinkedList, HashSet, HashMap

2d ago

Q. Write an SQL query to find the maximum mark in maths from a student table.

Ans.

SQL query to find the maximum mark of maths subject in a student table.

  • Use the MAX() function to find the maximum mark in the maths subject column.

  • Specify the maths subject column in the query.

  • Include the student table name in the query.

3d ago

Q. In Hibernate, what is the difference between lazy loading and eager loading?

Ans.

Lazy loading fetches data on demand, while eager loading retrieves all related data upfront.

  • Lazy loading delays the loading of related entities until they are accessed.

  • Eager loading retrieves all related entities at the time of the initial query.

  • Example of lazy loading: A user entity loads its profile only when accessed.

  • Example of eager loading: A user entity loads its profile and posts in one query.

Asked in Infosys

2d ago

Q. What is the difference between an abstract class and an interface?

Ans.

Abstract classes can have method implementations; interfaces cannot. Both are used for abstraction in Java.

  • An abstract class can have both abstract methods (without implementation) and concrete methods (with implementation).

  • An interface can only have abstract methods (until Java 8, which introduced default methods).

  • A class can extend only one abstract class but can implement multiple interfaces.

  • Abstract classes can have member variables, while interfaces can only have static ...read more

6d ago

Q. What is oops Difference between while and do while Polymorphism

Ans.

OOPs is a programming paradigm that uses objects to represent real-world entities. While and do-while are looping constructs. Polymorphism is the ability of an object to take on many forms.

  • OOPs stands for Object-Oriented Programming.

  • It is based on the concept of objects, which can contain data and code.

  • While and do-while are looping constructs in Java.

  • While loop executes the code block only if the condition is true.

  • Do-while loop executes the code block at least once, even if ...read more

Q. What are the reasons you prefer to learn the Java programming language?

Ans.

Java is versatile, widely used, and has a strong community, making it an ideal choice for learning programming.

  • Platform Independence: Java's 'Write Once, Run Anywhere' capability allows applications to run on any device with a Java Virtual Machine (JVM).

  • Strong Community Support: Java has a vast community, providing extensive resources, libraries, and frameworks like Spring and Hibernate.

  • Object-Oriented Programming: Java's OOP principles promote code reusability and modularity...read more

3d ago

Q. What is the difference between a TreeMap and a TreeSet?

Ans.

Tree map is a map implementation while tree set is a set implementation in Java.

  • Tree map stores key-value pairs in sorted order based on keys.

  • Tree set stores unique elements in sorted order.

  • Tree map allows duplicate values but not duplicate keys.

  • Tree set does not allow duplicate elements.

  • Both are implemented using Red-Black tree data structure.

Q. How many columns are there in Bootstrap?

Ans.

There are 12 columns in Bootstrap grid system.

  • Bootstrap grid system is divided into 12 columns.

  • Columns can be combined to create different layouts.

  • Example:

    will create a column that spans half of the row.

5d ago

Q. Why was Servlet not removed from Java technology?

Ans.

Servlets are still relevant for web development in Java

  • Servlets provide a lightweight and efficient way to handle HTTP requests and responses

  • They can be used for dynamic web content generation and server-side processing

  • Servlets are extensible and can be integrated with other Java technologies like JSP and JDBC

  • Alternative technologies like Spring MVC and RESTful APIs build on top of Servlets

  • Removing Servlets would break backward compatibility and disrupt existing Java web appl...read more

5d ago

Q. What is jdbc ? Different between jdbc and hibernate

Ans.

JDBC is a Java API for connecting and executing queries on a database. Hibernate is an ORM framework that simplifies database interactions.

  • JDBC is a low-level API for database connectivity in Java, requiring manual handling of SQL queries and connections.

  • Hibernate is a high-level ORM framework that maps Java objects to database tables, abstracting away the need for manual SQL queries.

  • JDBC is more suitable for simple database operations, while Hibernate is preferred for comple...read more

Asked in Apzzo

4d ago

Q. What is collection, type of collection, D/B Array and Arraylist, List ,set and map, overriding, exception handling etc... Questions Fully in core java.

Ans.

Collections in Java are used to store and manipulate groups of objects. They include List, Set, Map, and more.

  • Collection is an interface in Java that represents a group of objects. Examples include List, Set, and Map.

  • ArrayList is a class that implements the List interface and uses an array to store elements. Example: ArrayList<String> names = new ArrayList<>();

  • Set is an interface that does not allow duplicate elements. Example: Set<Integer> numbers = new HashSet<>();

  • Map is an...read more

Asked in Infosys

5d ago

Q. What is a java and explain the concept of oops

Ans.

Java is a high-level programming language used for developing applications and software.

  • Java is an object-oriented programming language.

  • It is platform-independent and can run on any device with a Java Virtual Machine (JVM).

  • Java follows the concept of OOPs (Object-Oriented Programming System).

  • OOPs is a programming paradigm that uses objects to represent real-world entities.

  • It includes concepts like inheritance, encapsulation, polymorphism, and abstraction.

  • Inheritance allows a ...read more

1d ago

Q. How does Java achieve thread safety with ConcurrentHashMap?

Ans.

Java's ConcurrentHashMap ensures thread safety through segment locking and non-blocking algorithms.

  • Segmented locking: The map is divided into segments, allowing multiple threads to access different segments concurrently.

  • Lock-free reads: Read operations do not require locking, improving performance in read-heavy scenarios.

  • Fine-grained locking: Only locks the segment being modified, reducing contention compared to a single lock for the entire map.

  • Atomic operations: Methods like...read more

4d ago

Q. How does the Stream API handle parallel processing in Java?

Ans.

The Stream API in Java enables parallel processing by utilizing multiple threads for efficient data manipulation.

  • Streams can be converted to parallel streams using the 'parallelStream()' method.

  • Parallel streams divide the workload across multiple threads, improving performance on large datasets.

  • Example: List<String> list = Arrays.asList('a', 'b', 'c'); list.parallelStream().forEach(System.out::println);

  • The ForkJoinPool is used by default to manage the threads for parallel pro...read more

1
2
3
4
5
Next

Interview Experiences of Popular Companies

TCS Logo
3.6
 • 11.1k Interviews
Infosys Logo
3.6
 • 7.9k Interviews
Wipro Logo
3.7
 • 6.1k Interviews
HCLTech Logo
3.5
 • 4.1k Interviews
IBM Logo
3.9
 • 2.5k Interviews
View all
interview tips and stories logo
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories
Junior Java Developer Interview Questions
Share an Interview
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits