Junior Java Developer
100+ Junior Java Developer Interview Questions and Answers
Q1. What are the dependencies present in Spring, and can you explain them?
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
Q2. Why we need Oops concepts? What is Constructor? Need of Constructor? StringBuilder? etc.
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
Junior Java Developer Interview Questions and Answers for Freshers
Q3. Can you override a static method?
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.
Q4. What are the aggregate functions in SQL?
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
Q5. What is the String pool in Java, and when would you use a String versus a character array for sensitive data?
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
Q6. 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.
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 🌟
Q7. What types of applications can be developed using the Java programming language?
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
Q8. String is an object,it provide sequence of characters 1.mutable string 2.immutable string Java support immutable string
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.
Junior Java Developer Jobs
Q9. What are the interfaces and classes in the Java Collection Framework?
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
Q10. What is Hibernate and what are its uses?
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
Q11. What is responsible for executing Java programs?
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.
Q12. How can you implement stateless authentication in a Spring Boot application?
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.
Q13. In what scenarios would you choose to use a LinkedList over an ArrayList?
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
Q14. what are 4 pillars of OOPs diffrence between String,String Buffer,String Builder Some questions on Collection framework
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
Q15. Write an SQL query to find the maximum mark in maths from a student table.
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.
Q16. What is oops Difference between while and do while Polymorphism
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
Q17. What are the reasons you prefer to learn the Java programming language?
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
Q18. What is the difference between a TreeMap and a TreeSet?
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.
Q19. How many columns are there in Bootstrap?
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.
Q20. Why was Servlet not removed from Java technology?
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
Q21. What is jdbc ? Different between jdbc and hibernate
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
Q22. What is collection, type of collection, D/B Array and Arraylist, List ,set and map, overriding, exception handling etc... Questions Fully in core java.
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
Q23. What is a java and explain the concept of oops
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
Q24. Which technology are you best at?
I am best in Java technology.
Strong knowledge of Java programming language
Experience with Java frameworks like Spring and Hibernate
Familiarity with Java development tools like Eclipse or IntelliJ IDEA
Q25. Tell me why we use the @Qualifier annotation in this project.
The @Qualifier annotation is used in Spring to specify which bean should be autowired when multiple beans of the same type are present.
Used to disambiguate beans of the same type
Helps in selecting a specific bean when multiple beans of the same type are available
Can be used in conjunction with @Autowired annotation
Q26. What is jvm .why jvm. String string buffer stringbuilder . constructor. Static .this. super. Collection Dif btwn arrya and arraylist
JVM is Java Virtual Machine, responsible for running Java programs. String, StringBuffer, and StringBuilder are classes for manipulating strings. Static, this, and super are keywords in Java. Arrays and ArrayList are both used to store collections of elements.
JVM is an abstract computing machine that enables a computer to run Java programs.
String, StringBuffer, and StringBuilder are classes used for manipulating strings in Java.
Static keyword is used to create class-level var...read more
Q27. Is Java an interpreted or compiled language?
Java is a compiled language that is first compiled into bytecode and then interpreted by the Java Virtual Machine (JVM).
Java is first compiled into bytecode by the Java compiler.
The bytecode is then interpreted by the Java Virtual Machine (JVM) at runtime.
This combination of compilation and interpretation makes Java a compiled language with some interpreted features.
Q28. How do you print the occurrence of duplicate characters in a string?
Print duplicate character occurrences in a string.
Iterate through the string and store character counts in a HashMap.
Print characters with count greater than 1 to find duplicates.
Q29. What makes Java a platform-independent programming language?
Java is platform-independent due to its use of the Java Virtual Machine (JVM) and bytecode compilation.
Java code is compiled into bytecode, which is platform-independent.
The Java Virtual Machine (JVM) interprets bytecode on any operating system.
This allows Java applications to run on any device with a compatible JVM.
For example, a Java program written on Windows can run on Linux or macOS without modification.
Q30. Create a Spring Boot program using GET and POST APIs.
Create a Spring Boot program with GET and POST APIs
Use @RestController annotation to create RESTful APIs
Define a method with @GetMapping annotation for GET API
Define a method with @PostMapping annotation for POST API
Use @RequestBody annotation to map POST request body to Java object
Example: @RestController public class ApiController { @GetMapping("/getData") public String getData() { return "Data"; } @PostMapping("/addData") public String addData(@RequestBody String data) { r...read more
Q31. Why is Java a platform-independent language?
Java is platform independent because it uses the concept of bytecode and virtual machine.
Java code is compiled into bytecode, which is a platform-independent representation of the code.
The bytecode is then executed by the Java Virtual Machine (JVM), which is platform-specific.
The JVM interprets the bytecode and translates it into machine code that can be executed on any platform.
This allows Java programs to run on different operating systems without the need for recompilation...read more
Q32. Insertion in single linked list Deletion in single linked list
Insertion and deletion operations in a single linked list.
Insertion: Add a new node at the beginning, middle, or end of the list by updating pointers.
Deletion: Remove a node by updating pointers to skip over the node to be deleted.
Example: Insert a node at the beginning - create a new node, point its next to the current head, and update head to the new node.
Q33. What are the differences between abstract classes and interfaces in Java?
Abstract classes can have both abstract and non-abstract methods, while interfaces can only have abstract methods.
Abstract classes can have constructors, interfaces cannot
A class can only extend one abstract class, but can implement multiple interfaces
Abstract classes can have instance variables, interfaces cannot
Interfaces are used to achieve abstraction and provide a contract for implementing classes
Example of abstract class: public abstract class Animal { public abstract v...read more
Q34. What is a class loader in Java?
Class loader is a part of JVM that loads classes into memory during runtime.
Class loader is responsible for finding and loading class files.
There are three types of class loaders: Bootstrap, Extension, and System.
Custom class loaders can also be created.
Class loaders follow a delegation model to load classes.
Class loaders can be used for dynamic class loading and unloading.
Example: Class.forName() method uses class loader to load the class.
Example: Web application servers use...read more
Q35. Is Java object-oriented?
Yes, Java is object oriented.
Java is a fully object-oriented programming language.
It supports the four main principles of OOP: encapsulation, inheritance, polymorphism, and abstraction.
In Java, everything is an object except for primitive data types.
Example: classes, objects, inheritance, polymorphism, etc.
Q36. What is string?types of strings?
String is a sequence of characters. Types include immutable and mutable strings.
String is a class in Java used to represent a sequence of characters.
Immutable strings cannot be modified once created, while mutable strings can be modified.
Examples of immutable strings include String literals and String objects created using the String constructor.
Examples of mutable strings include StringBuilder and StringBuffer.
Q37. How do you print the differences between the elements of an array?
Use nested loops to compare each pair of elements and print the differences.
Use nested loops to compare each pair of elements in the array.
Calculate the absolute difference between each pair of elements.
Print the differences between the array elements.
Q38. Write a program to print the character occurrences in a string.
Count the occurrence of each character in a given string.
Create a map to store character counts
Iterate through the string and update the counts in the map
Print the character counts from the map
Q39. Write a program to print the count of duplicate elements in a list.
Count duplicate elements in a list of strings.
Create a HashMap to store the count of each element in the list.
Iterate through the list and update the count in the HashMap.
Finally, iterate through the HashMap and print the count of elements with count greater than 1.
Q40. Given the input string "a:a1/b:b2/c:c3", write a program to produce the output string "A1:A/B2:B/C3:C".
Program to convert input string to specified output format
Split the input string by '/'
For each element, split by ':' and capitalize the first letter of the second part
Join the elements with '/' and ':' as specified in the output format
Q41. What are the core concepts of OOP?
OOPs concepts are the fundamental principles of object-oriented programming.
Encapsulation: bundling of data and methods that operate on that data within a single unit
Inheritance: ability of a class to inherit properties and methods from a parent class
Polymorphism: ability of objects to take on multiple forms or have multiple behaviors
Abstraction: hiding of complex implementation details and providing a simplified interface for the user
Q42. What is Overloading and Overriding?
Overloading is having multiple methods in the same class with the same name but different parameters. Overriding is implementing a method in a subclass that is already defined in the parent class.
Overloading allows a class to have multiple methods with the same name but different parameters.
Overriding involves implementing a method in a subclass that is already defined in the parent class.
Overloading is resolved at compile time while overriding is resolved at runtime.
Example ...read more
Q43. Which set implementation maintains insertion order?
The set that maintains insertion order is LinkedHashSet.
LinkedHashSet is a subclass of HashSet and implements Set interface.
It maintains the order of insertion of elements.
It does not allow duplicate elements.
Example: LinkedHashSet<String> set = new LinkedHashSet<>();
Q44. What are the differences between String, StringBuffer, and StringBuilder?
String is immutable, StringBuffer is synchronized and mutable, StringBuilder is not synchronized and mutable.
String is immutable, meaning its value cannot be changed once it is created.
StringBuffer is synchronized, making it thread-safe, but slower than StringBuilder.
StringBuilder is not synchronized, making it faster than StringBuffer but not thread-safe.
Q45. Which data structure in the Java Collections Framework offers the fastest performance?
The fastest data structure in collection is HashMap.
HashMap provides constant time complexity O(1) for insertion, deletion, and retrieval operations.
It uses hashing technique to store and retrieve elements.
It allows null values and null keys.
It is not synchronized, so it is not thread-safe by default.
ConcurrentHashMap can be used for thread-safe operations.
Q46. What is overriding and overloading?
Overriding is when a subclass provides a different implementation of a method inherited from its superclass. Overloading is when multiple methods with the same name but different parameters are defined in a class.
Overriding is used to achieve runtime polymorphism.
Overriding methods must have the same name, return type, and parameters as the method in the superclass.
Overloading is used to achieve compile-time polymorphism.
Overloaded methods must have the same name but differen...read more
Q47. What is jdk,jre , thread , collection
jdk is Java Development Kit, jre is Java Runtime Environment, thread is a unit of execution, collection is a group of objects.
JDK is a software development kit used to develop Java applications.
JRE is a runtime environment used to run Java applications.
Thread is a lightweight unit of execution within a process.
Collection is a group of objects that can be manipulated as a single unit.
Q48. What is inheritance, and can you explain it?
Inheritance is a mechanism in object-oriented programming where a new class is created by inheriting properties of an existing class.
Inheritance allows for code reuse and promotes code organization.
The existing class is called the superclass or parent class, while the new class is called the subclass or child class.
The subclass inherits all the properties and methods of the superclass, and can also add its own unique properties and methods.
For example, a subclass 'Car' can in...read more
Q49. What is a constructor?
A constructor is a special method that is used to initialize objects in Java.
Constructors have the same name as the class they belong to.
They are called automatically when an object is created.
They can take parameters to initialize the object's state.
If a class does not have a constructor, a default constructor is provided.
Constructors can be overloaded to provide multiple ways to initialize an object.
Q50. What do you know about collections?
Collections in Java are groups of objects that can be manipulated as a single unit.
Collections framework in Java provides interfaces (e.g. List, Set, Map) and classes (e.g. ArrayList, HashSet, HashMap) for storing and manipulating groups of objects.
Collections offer methods for adding, removing, and accessing elements in the group.
Examples of collections include ArrayList, LinkedList, HashSet, and HashMap.
Interview Questions of Similar Designations
Top Interview Questions for Junior Java Developer Related Skills
Interview experiences of popular companies
Calculate your in-hand salary
Confused about how your in-hand salary is calculated? Enter your annual salary (CTC) and get your in-hand salary
Reviews
Interviews
Salaries
Users/Month