Backend Java Developer

20+ Backend Java Developer Interview Questions and Answers

Updated 30 Nov 2024
search-icon

Q1. Take a list and find the list containing prime numbers in list, Find the highest salary of employees using streams and also basic SQL queries on joins

Ans.

Use Java streams to filter prime numbers from a list, find highest employee salary, and demonstrate basic SQL joins.

  • Use Java streams to filter prime numbers from the list

  • Use streams to find the highest salary of employees

  • Demonstrate basic SQL queries for joins

Q2. What are JDK, JRE & JVM? Signify public static void main (String [] args). Difference between ArrayList and LinkedList?

Ans.

JDK is Java Development Kit, JRE is Java Runtime Environment, and JVM is Java Virtual Machine. public static void main (String [] args) is the entry point of a Java program. ArrayList and LinkedList are both implementations of the List interface in Java, but ArrayList uses a dynamic array for storing elements while LinkedList uses a doubly linked list.

  • JDK (Java Development Kit) is a software development kit used for developing Java applications.

  • JRE (Java Runtime Environment) ...read more

Backend Java Developer Interview Questions and Answers for Freshers

illustration image

Q3. Can we create static method or variable inside static main()

Ans.

No, static methods or variables cannot be created inside static main() method.

  • Static methods or variables cannot be created inside another static method.

  • Static methods or variables can only be created at the class level, outside of any method.

  • Example: public class MyClass { static int myVariable = 10; }

Q4. Advantages of Spring Boot framework? Annotations in Spring or Spring Boot? What are Primary key and foreign key in SQL? What is @Qualofier in Spring Boot?

Ans.

Spring Boot framework provides rapid development, easy configuration, and built-in features. Annotations simplify development. Primary key uniquely identifies a record in a table, foreign key establishes a relationship between tables. @Qualifier in Spring Boot is used to specify which bean to autowire.

  • Spring Boot offers rapid development, easy configuration, and built-in features like embedded servers.

  • Annotations in Spring or Spring Boot simplify development by reducing boile...read more

Are these interview questions helpful?

Q5. Java memory types and which object stores where?

Ans.

Java memory types and where objects are stored

  • Java memory consists of stack and heap

  • Primitive data types are stored in stack

  • Objects and arrays are stored in heap

  • References to objects are stored in stack

  • Example: int num = 5; // num is stored in stack, value 5 is stored in stack

  • Example: String str = new String(); // str reference is stored in stack, actual String object is stored in heap

Q6. What is idempotent term in patch and put?

Ans.

Idempotent term in patch and put means that multiple identical requests have the same effect as a single request.

  • Idempotent means that the result of a successful request is the same regardless of how many times it is repeated.

  • In PATCH and PUT requests, idempotent means that sending the same request multiple times will not have any additional side effects.

  • For example, if a PATCH request updates a resource with specific data, sending the same PATCH request multiple times will n...read more

Share interview questions and help millions of jobseekers 🌟

man-with-laptop

Q7. What is JVM ? What is JRE ? What is Multithreading ? JDBC Loop

Ans.

JVM is a virtual machine that executes Java bytecode. JRE is a runtime environment for Java programs. Multithreading is the ability of a program to execute multiple threads concurrently. JDBC is a Java API for connecting to databases. Loop is a control structure that allows a program to repeat a set of instructions.

  • JVM executes Java bytecode

  • JRE provides a runtime environment for Java programs

  • Multithreading allows for concurrent execution of threads

  • JDBC is used for connecting ...read more

Q8. Difference between query and path param in spring boot

Ans.

Query param is used to pass parameters in the URL query string, while path param is used to define parameters in the URL path itself.

  • Query param is specified after the '?' in the URL, like '?param=value'

  • Path param is specified in the URL path itself, like '/{param}'

  • Query params are optional and can be used for filtering or sorting data

  • Path params are used to define variables in the URL path, like IDs or names

Backend Java Developer Jobs

Backend Java Developer 6-11 years
UST
3.8
₹ 15 L/yr - ₹ 30 L/yr
Kochi
Backend Java Developer 1-2 years
Airtel
4.0
Gurgaon / Gurugram
Backend Java Developer For Device Tech 7-8 years
Hitachi Ltd.
4.0
Bangalore / Bengaluru

Q9. What is the internal working of Hashmap?

Ans.

HashMap is a data structure that stores key-value pairs and uses hashing to efficiently retrieve values based on keys.

  • HashMap internally uses an array of linked lists to store key-value pairs.

  • When a key-value pair is added, the key is hashed to determine the index in the array where the pair will be stored.

  • If multiple keys hash to the same index, a linked list is used to handle collisions.

  • Retrieving a value involves hashing the key to find the index and then traversing the li...read more

Q10. How will you create custom exception

Ans.

Custom exceptions can be created by extending the Exception class in Java.

  • Create a new class that extends the Exception class

  • Override the constructors to provide custom messages and error codes

  • Throw the custom exception using the 'throw' keyword

Q11. Hashmap java 7 and java 8 difference?

Ans.

Java 8 introduced new methods for HashMap such as forEach, compute, merge, etc.

  • Java 8 introduced new methods like forEach, compute, merge for HashMap operations

  • Java 8 allows using lambda expressions for iterating over HashMap entries

  • Java 8 introduced default methods in Map interface for HashMap

Q12. Difference between abstract and interface

Ans.

Abstract class can have both abstract and non-abstract methods, while interface can only have abstract methods.

  • Abstract class can have constructors, fields, and methods, while interface cannot have any of these.

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

  • Abstract classes are used to provide a common base for subclasses, while interfaces are used to define a contract for classes to implement.

  • Example: Abstract class 'Animal' with abstract m...read more

Frequently asked in, ,

Q13. Difference between array and array list

Ans.

Arrays have fixed size, while ArrayLists can dynamically resize. ArrayLists are part of Java Collections framework.

  • Arrays have a fixed size, while ArrayLists can dynamically resize.

  • Arrays can hold primitive data types and objects, while ArrayLists can only hold objects.

  • Arrays use square brackets [] for declaration, while ArrayLists use angle brackets <>.

  • Arrays are faster than ArrayLists for accessing elements directly by index.

  • Example: String[] names = new String[5]; ArrayLis...read more

Q14. Smallest integer in unsorted array

Ans.

Find the smallest integer in an unsorted array.

  • Iterate through the array and keep track of the smallest integer found so far.

  • Use a for loop or a stream to iterate through the array.

  • If the array is empty, return null or throw an exception.

  • If the array contains only one element, return that element.

Q15. Verify whether a Palindrome list

Ans.

A palindrome list is a list that reads the same backward as forward.

  • Traverse the list and store the elements in an array

  • Compare the first element with the last element, second with second last and so on

  • If all elements match, then the list is a palindrome

Q16. What is polymorphism?

Ans.

Polymorphism is the ability of a single function or method to operate on different types of data.

  • Polymorphism allows objects of different classes to be treated as objects of a common superclass.

  • There are two types of polymorphism: compile-time (method overloading) and runtime (method overriding).

  • Example: Inheritance in Java allows a subclass to override a method of its superclass, exhibiting polymorphic behavior.

Frequently asked in, ,

Q17. What is profile in springboot

Ans.

Profile in Spring Boot is a set of configurations that can be used to customize the behavior of an application.

  • Profiles allow developers to define different configurations for different environments (e.g. development, testing, production).

  • Profiles can be activated using the 'spring.profiles.active' property in the application.properties file.

  • Profiles can be used to specify different database connections, logging levels, or other settings based on the environment.

  • Example: 'app...read more

Q18. Hash map store unique name?

Ans.

Yes, hash map stores unique keys.

  • Hash map in Java does not allow duplicate keys. If you try to insert a duplicate key, it will replace the existing value with the new one.

  • However, hash map allows duplicate values.

  • Example: HashMap map = new HashMap<>(); map.put("John", 25); map.put("Jane", 30); map.put("John", 35); // 'John' key will now have value 35.

Q19. What is exception in Java

Ans.

An exception in Java is an event that disrupts the normal flow of a program's instructions.

  • Exceptions are objects that are thrown when an abnormal condition occurs during the execution of a program.

  • They can be caught and handled using try-catch blocks.

  • Unchecked exceptions do not need to be declared in a method's throws clause, while checked exceptions do.

  • Examples of exceptions in Java include NullPointerException, ArrayIndexOutOfBoundsException, and IOException.

Q20. What is inheritance?

Ans.

Inheritance is a mechanism in object-oriented programming where a class inherits properties and behaviors from another class.

  • Allows a class to inherit attributes and methods from another class

  • Promotes code reusability and reduces redundancy

  • Creates a parent-child relationship between classes

  • Derived class can override inherited methods or add new methods

  • Example: Class Car can inherit from class Vehicle

Frequently asked in, ,

Q21. Design singleton class

Ans.

A singleton class is a class that can only have one instance created and provides a global point of access to that instance.

  • Ensure the class has a private constructor to prevent external instantiation.

  • Provide a static method to access the single instance of the class.

  • Use lazy initialization to create the instance only when needed.

  • Consider thread safety if the singleton will be accessed by multiple threads.

Q22. What is StreamsAPI

Ans.

StreamsAPI is a feature in Java that allows for processing sequences of elements in a functional style.

  • StreamsAPI provides a way to work with collections of objects in a more concise and declarative manner.

  • It supports operations like filter, map, reduce, and collect.

  • Example: List names = Arrays.asList("Alice", "Bob", "Charlie"); names.stream().filter(name -> name.startsWith("A")).forEach(System.out::println);

Q23. Design a REST API

Ans.

Design a REST API for a backend Java developer

  • Define the resources and endpoints

  • Use HTTP methods like GET, POST, PUT, DELETE

  • Implement authentication and authorization

  • Use JSON for data exchange

  • Include error handling and status codes

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

Top Interview Questions for Backend Java Developer Related Skills

Interview experiences of popular companies

3.7
 • 10.5k Interviews
3.6
 • 7.6k Interviews
3.8
 • 3k Interviews
4.0
 • 2.4k Interviews
4.0
 • 838 Interviews
3.3
 • 775 Interviews
3.5
 • 38 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

Backend 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

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