Junior Java Developer

90+ Junior Java Developer Interview Questions and Answers

Updated 25 Oct 2024

Popular Companies

search-icon

Q1. 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

Q2. Can you override 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.

Junior Java Developer Interview Questions and Answers for Freshers

illustration image

Q3. What are the dependencies that are present in spring and 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

Q4. 1)What are the aggregade functions 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

Are these interview questions helpful?

Q5. 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

Q6. 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.

Share interview questions and help millions of jobseekers 🌟

man-with-laptop

Q7. what is meant by the hibernate and explain it's 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

Q8. Which is responsible for execute java program

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.

Junior Java Developer Jobs

Junior Java Developer 4-6 years
Oracle
3.7
₹ 10 L/yr - ₹ 15 L/yr
Mumbai
Junior Java Developer 1-2 years
Anblicks Solutions
4.4
Ahmedabad
SutiSoft - Junior Java Developer - Spring Frameworks (0-2 yrs) 0-2 years
SutiSoft Pvt. Ltd
3.7
₹ 3 L/yr - ₹ 6 L/yr

Q9. 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

Q10. What are the interfaces and classes in java collection ?

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

Q11. 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

Q12. Why are not remove Servlet 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

Q13. 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

Q14. Write a sql query to find the maximum mark of maths subject in 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.

Q15. 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 names = new ArrayList<>();

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

  • Map is an interface that s...read more

Q16. What is Diffrence between tree map and tree set

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.

Q17. 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

Q18. Tell me @qualifier annotation why we are using in project

Ans.

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

Q19. What is jvm .why jvm. String string buffer stringbuilder . constructor. Static .this. super. Collection Dif btwn arrya and arraylist

Ans.

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

Q20. In Bootstrap how many columns are there ?

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.

Q21. Is Java Interpreted or Compiler language ?

Ans.

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.

Q22. To create a spring boot program using two apis get and post

Ans.

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

Q23. Print the duplicate character occurrence in a string?

Ans.

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.

Q24. Why is java a platform independent language?

Ans.

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

Q25. Insertion in single linked list Deletion in single linked list

Ans.

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.

Q26. Difference between Abstract classes and interfaces in Java

Ans.

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

Q27. In which technology you are best ?

Ans.

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

Q28. What is class loader in java?

Ans.

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

Q29. What is string?types of strings?

Ans.

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.

Q30. Print the character occurance in a string?

Ans.

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

Q31. Print the differences between the array elements?

Ans.

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.

Q32. Print the duplicate elements count in a list?

Ans.

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.

Q33. There is 2 programs 1) input "a:a1/b:b2/c:c3" Output "A1:A/B2:B/C3:C"

Ans.

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

Q34. What is oops concepts?

Ans.

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

Frequently asked in, ,

Q35. Which set maintains the insertion order

Ans.

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 set = new LinkedHashSet<>();

Q36. difference betweeen string, stringbuffer and string builder

Ans.

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.

Q37. What is Overloading and Overriding?

Ans.

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

Q38. Fastest data structure in collection

Ans.

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.

Q39. What is overriding and overloading?

Ans.

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

Q40. What is jdk,jre , thread , collection

Ans.

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.

Q41. What is a inheritance and explain

Ans.

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

Q42. What is constructor?

Ans.

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.

Frequently asked in, ,

Q43. Is java object oriented or not

Ans.

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.

Q44. Spring boot crud example

Ans.

Spring Boot CRUD example is a basic implementation of Create, Read, Update and Delete operations using Spring Boot framework.

  • Create a Spring Boot project with required dependencies

  • Define entity classes and their relationships

  • Create repository interfaces extending JpaRepository

  • Implement service classes with business logic

  • Create RESTful API endpoints using @RestController

  • Use HTTP methods to perform CRUD operations

  • Test the API using tools like Postman

Q45. What is local storage?

Ans.

Local storage is a web browser feature that allows websites to store data locally on a user's device.

  • Local storage is a key-value storage mechanism.

  • It is a part of the web storage API.

  • Data stored in local storage persists even after the browser is closed.

  • It is limited to storing data in string format.

  • Local storage can be accessed and modified using JavaScript methods like localStorage.setItem() and localStorage.getItem().

Q46. Explain API you used in your project

Ans.

I used the Spring Boot API in my project.

  • Spring Boot is a popular Java framework for building web applications.

  • It provides a variety of tools and features for building RESTful APIs.

  • I used Spring Boot's annotations to define endpoints and handle requests.

  • I also used Spring Data JPA to interact with a MySQL database.

  • Some examples of Spring Boot APIs I used include @RestController, @GetMapping, and @PostMapping.

Q47. How to call rest api's

Ans.

To call REST APIs, use HTTP methods like GET, POST, PUT, DELETE with the API endpoint URL.

  • Use a HTTP client library like Apache HttpClient or OkHttp

  • Pass any required parameters in the request body or as query parameters

  • Handle the response returned by the API

  • Add appropriate headers like Authorization or Content-Type if required

Q48. What is wrapper class?

Ans.

Wrapper class is a class that wraps or encapsulates the primitive data types in Java.

  • Wrapper classes provide a way to use primitive data types as objects.

  • They have methods to convert between primitive types and objects.

  • Wrapper classes are immutable.

  • Examples of wrapper classes include Integer, Double, Boolean, etc.

Q49. Array list vs hash map

Ans.

Array list is used for ordered collection while hash map is used for key-value pair mapping.

  • Array list maintains the order of elements while hash map does not.

  • Array list is accessed using index while hash map is accessed using keys.

  • Array list is good for small collections while hash map is good for large collections.

  • Example: Array list can be used to store a list of names while hash map can be used to store a list of phone numbers with names as keys.

Q50. Traverse Varaible without using Third Variable

Ans.

Traverse variable without using third variable

  • Use bitwise XOR operation to swap values without using a third variable

  • Example: a = 5, b = 10; a = a ^ b; b = a ^ b; a = a ^ b; // a = 10, b = 5

1
2
Next
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Interview experiences of popular companies

3.7
 • 10k Interviews
3.7
 • 7.3k Interviews
3.7
 • 5.2k Interviews
3.6
 • 3.6k Interviews
4.1
 • 2.3k Interviews
View all

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

Junior Java Developer Interview Questions
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

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

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter