Java Full Stack Developer

80+ Java Full Stack Developer Interview Questions and Answers

Updated 31 Dec 2024
search-icon

Q1. Coding question - 1. Create a immutable class of orders. What happens when two objects are created out of it. 2.Using the immutable orders create a set of orders and how will you sort these out. 3.Given a List ...

read more
Ans.

Creating immutable class of orders, sorting orders, finding average of lists of integers.

  • Create an immutable class Orders with private final fields and no setter methods.

  • Override equals() and hashCode() methods to ensure uniqueness of objects.

  • Use Collections.unmodifiableSet() to create a set of orders and Collections.sort() to sort them.

  • Iterate through the List of List of String of integers, convert to integers, and calculate average for each list.

Q2. What is the difference between methode overloading and overriding?

Ans.

Method overloading is having multiple methods with the same name but different parameters. Method overriding is having a method in the subclass with the same name and parameters as in the superclass.

  • Method overloading is done in the same class while method overriding is done in different classes.

  • Method overloading is used to provide different ways of calling the same method while method overriding is used to provide a specific implementation of a method in the subclass.

  • Method...read more

Java Full Stack Developer Interview Questions and Answers for Freshers

illustration image

Q3. How are 4-5 microservices connected in rest api's? which technique you are using?

Ans.

Microservices are connected in REST APIs using communication protocols like HTTP, messaging queues, and service discovery.

  • Microservices communicate with each other using HTTP requests and responses.

  • Messaging queues like RabbitMQ or Kafka can be used for asynchronous communication between microservices.

  • Service discovery tools like Eureka or Consul help in locating and connecting to different microservices.

  • API Gateway can be used to aggregate multiple microservices into a singl...read more

Q4. Explain Spring Cloud and how you are using in microservices?

Ans.

Spring Cloud is a set of tools and frameworks for building cloud-native applications in Java.

  • Spring Cloud provides tools for service discovery, load balancing, configuration management, and more in microservices architecture.

  • It includes projects like Eureka for service discovery, Ribbon for client-side load balancing, and Config Server for externalized configuration.

  • Spring Cloud integrates with Spring Boot to simplify the development of distributed systems.

  • Using Spring Cloud,...read more

Are these interview questions helpful?

Q5. How do you connect to database with java and update data ?

Ans.

To connect to a database with Java and update data, use JDBC API.

  • Load the JDBC driver

  • Establish a connection to the database using DriverManager.getConnection()

  • Create a Statement object using the connection.createStatement() method

  • Execute the SQL query using the Statement.executeUpdate() method

  • Close the connection and statement objects

Q6. Suppose we have more 2 interfaces with the same default method. What will happen when we try to implment both the interfaces in the same class.?

Ans.

The class will have to provide its own implementation of the conflicting default method.

  • When implementing multiple interfaces with the same default method, a class must provide its own implementation of the conflicting method.

  • The class cannot inherit the default implementation from both interfaces.

  • The class can choose to implement one of the default methods and provide its own implementation for the other.

  • Alternatively, the class can provide a completely new implementation fo...read more

Share interview questions and help millions of jobseekers 🌟

man-with-laptop

Q7. What are th annotations do you use in Spring boot application

Ans.

Annotations used in Spring Boot applications

  • @SpringBootApplication - main annotation to enable Spring Boot features

  • @RestController - to define RESTful web services

  • @Autowired - to inject dependencies

  • @GetMapping, @PostMapping, @PutMapping, @DeleteMapping - to map HTTP requests to methods

  • @PathVariable - to extract values from the URI

  • @RequestBody - to bind the request body to a Java object

  • @ResponseStatus - to set the HTTP response status code

  • @Configuration - to define Spr...read more

Q8. How do you handle exception in spring boot project

Ans.

Exception handling in Spring Boot project

  • Use @ExceptionHandler annotation to handle exceptions

  • Use @ControllerAdvice to handle exceptions globally

  • Use try-catch block to handle exceptions in specific methods

  • Use ResponseEntity to return custom error messages

  • Use logging to track and debug exceptions

Java Full Stack Developer Jobs

C++ & Java Full Stack Developer 2-7 years
SAP India Pvt.Ltd
4.2
Bangalore / Bengaluru
Software Engineer III AWS Cloud - Java Full Stack Developer React 3-8 years
JPMorgan Chase
4.1
Hyderabad / Secunderabad
Java full stack developer 1-5 years
CGI Information Systems and Management Consultants
4.0
Bangalore / Bengaluru

Q9. If a person walk 3km towards west and turn left and walk 4 km then what is the shortest distance of that person from his starting point ?

Ans.

The shortest distance from the starting point is 5 km.

  • The person walks 3 km towards west, forming a right angle triangle with the starting point.

  • Then the person turns left and walks 4 km, forming another side of the right angle triangle.

  • The shortest distance from the starting point is the hypotenuse of the right angle triangle, which can be calculated using Pythagoras theorem as sqrt(3^2 + 4^2) = 5 km.

Q10. Explain Microservices Architecture used in your project

Ans.

Microservices architecture is a design approach where a single application is composed of small, independent services that communicate with each other.

  • Each microservice is responsible for a specific business function or capability

  • Microservices communicate with each other through APIs

  • Each microservice can be developed, deployed, and scaled independently

  • Microservices architecture promotes flexibility, scalability, and resilience

  • Examples: Netflix, Amazon, Uber

Q11. what are microservices according to you?

Ans.

Microservices are a software development technique where an application is divided into smaller, independent services that communicate with each other through APIs.

  • Microservices are small, independent services that focus on specific business functions.

  • Each microservice can be developed, deployed, and scaled independently.

  • Microservices communicate with each other through APIs, typically using lightweight protocols like HTTP or messaging queues.

  • They promote flexibility, scalabi...read more

Q12. What is the use of inheritance?

Ans.

Inheritance is a mechanism in OOP where a new class is derived from an existing class.

  • It allows code reusability and saves time and effort in writing code.

  • The derived class inherits the properties and methods of the base class.

  • The derived class can also add new properties and methods or override the existing ones.

  • It helps in achieving polymorphism and abstraction.

  • Example: A Car class can be inherited by a SportsCar class which can add new properties like top speed and overrid...read more

Q13. How does string work in java meaning, how its stored and how its reference is saved in pool

Ans.

Strings in Java are stored in the String pool, which is a special area in the Java heap memory.

  • Strings in Java are immutable, meaning once a string is created, it cannot be changed.

  • When a string is created in Java, it is stored in the String pool if it does not already exist.

  • String literals are stored in the String pool, while strings created using the 'new' keyword are stored in the heap memory.

  • String pool helps in saving memory by reusing common strings, which improves perf...read more

Q14. Are ready to work on all technologies which are still not is market?

Ans.

Yes, I am willing to work on new technologies that are not yet in the market.

  • I am always eager to learn and adapt to new technologies to stay ahead in the industry.

  • Working on emerging technologies can provide valuable experience and opportunities for growth.

  • Examples of technologies I am interested in exploring include blockchain, quantum computing, and artificial intelligence.

Q15. What is the use of optional class

Ans.

Optional class is used to handle null values in Java 8 and above.

  • Optional class is a container object that may or may not contain a non-null value.

  • It provides methods to check if a value is present or not, and to retrieve the value if it is present.

  • It helps to avoid NullPointerExceptions and makes the code more readable and concise.

  • Example: Optional name = Optional.ofNullable(person.getName());

  • If person.getName() returns null, then name will be an empty Optional object.

Q16. How to to compare two objects with same class (equals & Hashcode methods)

Ans.

To compare two objects with the same class, override the equals and hashCode methods in the class.

  • Override the equals method to compare the fields of the objects for equality.

  • Override the hashCode method to generate a unique hash code based on the object's fields.

  • Ensure that the equals and hashCode methods are consistent with each other.

  • Example: public class Person { private String name; private int age; }

Q17. What are the different types of data binding in Angular?

Ans.

Data binding in Angular allows automatic synchronization of data between the model and the view.

  • Interpolation: {{ }} - binds data from the component to the view

  • Property binding: [] - binds data from the component to an element property

  • Event binding: () - binds an event from the view to a method in the component

  • Two-way binding: [()] - combines property and event binding to achieve two-way data flow

Q18. When to use Inline Template vs External Template in Angular?

Ans.

Inline templates are used for small, simple templates, while external templates are used for larger, complex templates.

  • Inline templates are defined within the component's TypeScript file using the template property.

  • External templates are defined in separate HTML files and linked to the component using the templateUrl property.

  • Inline templates are useful for small components or when the template is simple and doesn't require much HTML code.

  • External templates are beneficial for...read more

Q19. Explain React and it's components and states,redux etc.

Ans.

React is a JavaScript library for building user interfaces.

  • React is component-based, meaning UI is broken down into reusable pieces

  • Components can have states, which are mutable data that affect rendering

  • Redux is a state management library that can be used with React

  • Redux helps manage complex states and data flow in larger applications

Q20. What is the difference between the DELETE and TRUNCATE commands in SQL?

Ans.

DELETE command removes specific rows from a table, while TRUNCATE command removes all rows from a table.

  • DELETE command is used to remove specific rows from a table based on a condition.

  • TRUNCATE command is used to remove all rows from a table, resetting auto-increment values.

  • DELETE command is slower as it logs individual row deletions, while TRUNCATE is faster as it does not log individual deletions.

  • DELETE can be rolled back using a transaction, while TRUNCATE cannot be rolled...read more

Q21. Write how do you connect jpa, update some values from database.

Ans.

To connect JPA and update values from the database, you need to use entity manager and transactions.

  • Create an entity class representing the table in the database

  • Use EntityManager to retrieve the entity from the database

  • Update the values of the entity

  • Begin a transaction, commit the transaction after updating the values

Q22. Explain how Spring Framework works? Explain microservices and its uses? Explain the difference between MySQL database & MongoDB

Ans.

Spring Framework is a popular Java framework for building enterprise applications. Microservices are a software development technique that structures an application as a collection of loosely coupled services. MySQL is a relational database management system, while MongoDB is a NoSQL database.

  • Spring Framework is a comprehensive framework that provides support for developing Java applications. It offers features like dependency injection, aspect-oriented programming, and more....read more

Q23. Given a string containing just the characters '{','}','(',')', '[',']' determine if the input string is valid. Leetcode #20

Ans.

Check if a string containing only specific characters is valid by ensuring all opening brackets have corresponding closing brackets.

  • Use a stack to keep track of opening brackets and pop when a closing bracket is encountered.

  • If stack is empty at the end, return true. Otherwise, return false.

  • Example: Input: '()[]{}', Output: true

Q24. What is difference between object and instance in java

Ans.

An object is a physical entity in memory, while an instance is a specific realization of an object.

  • An object is a general concept, while an instance is a specific occurrence of that concept.

  • Objects are created using classes, while instances are created using the 'new' keyword.

  • Each instance has its own state (values of attributes) and behavior (methods).

  • Example: 'Car' is an object, while 'Toyota Camry' is an instance of the 'Car' object.

Q25. Multiply two array of each element of both the array.

Ans.

Multiply two arrays element-wise.

  • Loop through both arrays and multiply each element at the same index.

  • Store the result in a new array.

  • Return the new array.

Q26. What are the two types of compiler in angular?

Ans.

The two types of compiler in Angular are JIT (Just-in-Time) compiler and AOT (Ahead-of-Time) compiler.

  • JIT compiler compiles the code at runtime in the browser.

  • AOT compiler compiles the code before the application is deployed to the browser.

  • JIT compilation is slower but allows for faster development and debugging.

  • AOT compilation is faster but requires additional build step before deployment.

Q27. Which module is used for http calls in Angular?

Ans.

HttpClient module is used for http calls in Angular.

  • HttpClient module is part of the @angular/common/http package.

  • It provides a simplified API for making HTTP requests.

  • It supports various HTTP methods like GET, POST, PUT, DELETE, etc.

  • It also supports features like request/response headers, query parameters, error handling, etc.

  • Example: import { HttpClient } from '@angular/common/http';

Q28. Write code for Builder/Factory Pattern, basically anything other than Singleton

Ans.

Builder/Factory Pattern is used to create objects with complex initialization logic.

  • Builder Pattern separates the construction of a complex object from its representation.

  • Factory Pattern creates objects without specifying the exact class of object that will be created.

  • Builder Pattern is often used to create immutable objects with many optional parameters.

  • Factory Pattern is used when there is a need to create multiple instances of a class with similar characteristics.

Q29. Java vs Javascript , Meaning of Synchronization in Java , Multihreading in Js

Ans.

Java is a backend language, Javascript is a frontend language. Synchronization in Java ensures only one thread can access a resource at a time. JavaScript is single-threaded but can handle asynchronous operations using callbacks, promises, and async/await.

  • Java is a backend language used for server-side development, while JavaScript is a frontend language used for client-side scripting.

  • Synchronization in Java is a technique that allows only one thread to access a shared resour...read more

Q30. Write a pojo class to display the Employee Details,Pojo vs Bean

Ans.

A Pojo class is a simple Java class that contains only private fields, public getters and setters, and no-arg constructor.

  • Create private fields for employee details like name, id, salary, etc.

  • Generate public getters and setters for each field.

  • Include a no-arg constructor in the class.

  • Example: public class Employee { private String name; private int id; public String getName() { return name; } public void setName(String name) { this.name = name; } public int getId() { return i...read more

Q31. Explain your deployment build config?

Ans.

Deployment build config includes settings for deploying the application.

  • Use tools like Maven or Gradle to manage dependencies and build the project

  • Specify deployment environment configurations in a separate file (e.g. application.properties)

  • Define build scripts for tasks like compiling, packaging, and deploying the application

  • Leverage CI/CD pipelines for automated builds and deployments

Q32. Any basic concepts of java full stack developer

Ans.

Java Full Stack Developer should have knowledge of both front-end and back-end development using Java technologies.

  • Java programming language

  • Spring Framework

  • Hibernate

  • HTML/CSS/JavaScript

  • RESTful APIs

  • Database management

  • Version control systems

Q33. What is the difference between ai and ml?

Ans.

AI is a broader concept of machines being able to carry out tasks in a smart way, while ML is a subset of AI that allows machines to learn from data.

  • AI is the broader concept of machines being able to carry out tasks in a smart way, often involving decision-making and problem-solving.

  • ML is a subset of AI that focuses on the development of computer programs that can access data and use it to learn for themselves.

  • AI can involve various techniques like rule-based systems, expert...read more

Q34. What are projections in Spring Data JPA?

Ans.

Projections in Spring Data JPA allow customizing the shape of the data returned from a query.

  • Projections are used to retrieve specific fields or a subset of fields from an entity.

  • They help in reducing the amount of data transferred over the network.

  • Projections can be defined using interfaces or classes.

  • They can be used with both JPQL and native SQL queries.

  • Projections can be used to fetch related entities as well.

Q35. Design a database system for gym management system.

Ans.

A database system for gym management system

  • Create tables for members, trainers, classes, and equipment

  • Include columns for personal information, membership status, and payment history

  • Track attendance, class schedules, and equipment maintenance

  • Implement security measures to protect sensitive information

Q36. Explain Routes and how it is handled in React js

Ans.

Routes in React js are used to define the navigation paths and handle the rendering of different components based on the URL.

  • Routes are defined using the React Router library

  • Each route is associated with a specific URL path and a corresponding component

  • When a user navigates to a specific URL, the corresponding component is rendered

  • Routes can also have parameters that can be accessed in the component

  • Nested routes can be defined to create complex navigation structures

Q37. What are the different annotations in Spring Boot

Ans.

Spring Boot provides various annotations for different purposes.

  • The @RestController annotation is used to create RESTful web services.

  • The @Autowired annotation is used for automatic dependency injection.

  • The @RequestMapping annotation is used to map HTTP requests to specific methods.

  • The @Component annotation is used to mark a class as a Spring component.

  • The @Service annotation is used to mark a class as a Spring service.

  • The @Repository annotation is used to mark a class as a S...read more

Q38. How do you write a code for button in html

Ans.

To create a button in HTML, use the <button> tag with the desired text or image inside.

  • Use the <button> tag to create a button element

  • Add text or image inside the <button> tag to display on the button

  • Specify any desired attributes like id, class, onclick event, etc. for the button

Q39. How do you write a code for factorial in c

Ans.

Factorial in C can be calculated using a recursive function or a loop.

  • Use a recursive function to calculate factorial

  • Use a loop to calculate factorial

  • Handle edge cases like 0 and negative numbers

Q40. Is there any chances in code optimization?

Ans.

Yes, code optimization can improve performance, reduce memory usage, and enhance readability.

  • Optimizing algorithms and data structures can improve performance.

  • Minimizing redundant code and using efficient coding techniques can reduce memory usage.

  • Refactoring code to make it more readable and maintainable can enhance code quality.

  • Using appropriate design patterns and libraries can optimize code.

  • Profiling and benchmarking code can help identify areas for optimization.

Q41. Write snippet for creating an Entity Class.

Ans.

Creating an Entity Class in Java

  • Define class with @Entity annotation

  • Add @Id annotation for primary key

  • Include fields with appropriate data types

Q42. What is class and object in java

Ans.

A class is a blueprint for creating objects in Java, while an object is an instance of a class.

  • A class defines the properties and behaviors of objects.

  • An object is created using the 'new' keyword followed by the class name.

  • Multiple objects can be created from the same class.

Q43. Mention about the design patterns you worked so far

Ans.

I have worked with various design patterns such as Singleton, Factory, Observer, and MVC.

  • Implemented Singleton pattern to ensure only one instance of a class exists

  • Utilized Factory pattern to create objects without specifying the exact class

  • Implemented Observer pattern to establish a one-to-many dependency between objects

  • Utilized MVC pattern to separate the concerns of data, presentation, and user input

Q44. logic for sorting integers of an array.

Ans.

Sorting integers in an array using various sorting algorithms.

  • Use built-in sorting methods like Arrays.sort() for quick implementation.

  • Implement sorting algorithms like Bubble Sort, Selection Sort, Merge Sort, etc. for learning purposes.

  • Consider the time complexity of the sorting algorithm when choosing the best approach.

Q45. What is the importance of java language?

Ans.

Java is a widely used programming language known for its platform independence and versatility.

  • Java is platform independent, meaning it can run on any device with a Java Virtual Machine (JVM)

  • Java is versatile and can be used for developing a wide range of applications such as web, mobile, desktop, and enterprise applications

  • Java has a large and active community, providing support, resources, and libraries for developers

  • Java is known for its performance, security, and scalabil...read more

Q46. Why is Redux used in React

Ans.

Redux is used in React to manage the application state in a predictable way.

  • Centralized state management for React applications

  • Predictable state changes with actions and reducers

  • Easier debugging and testing of state changes

  • Facilitates communication between components

Q47. explain how garbabe collector works ?

Ans.

Garbage collector is a program in Java that automatically manages memory by reclaiming unused memory.

  • Garbage collector runs in the background and identifies objects that are no longer needed.

  • It frees up memory by removing these unused objects, making the memory available for new objects.

  • There are different types of garbage collectors in Java such as Serial, Parallel, CMS, G1, etc.

Q48. Terminal vs Intermediate Operations in streams

Ans.

Terminal operations in streams produce a result or a side effect, while intermediate operations transform or filter the data.

  • Terminal operations are the final operations in a stream pipeline, such as forEach, collect, or reduce.

  • Intermediate operations are operations that can be chained together, such as filter, map, or sorted.

  • Terminal operations trigger the processing of the stream and produce a result or a side effect.

  • Intermediate operations transform or filter the data in t...read more

Q49. Most occured letter in string ? Problem to code

Ans.

Find the most occurred letter in a given string.

  • Iterate through the string and count the occurrences of each letter

  • Store the counts in a map or array

  • Find the letter with the highest count

Q50. What is java and features of java

Ans.

Java is a high-level programming language known for its platform independence and object-oriented features.

  • Java is platform-independent, meaning it can run on any device with a Java Virtual Machine (JVM)

  • Java is object-oriented, allowing for the creation of reusable code and modular programs

  • Java is known for its robust standard library, which includes tools for networking, I/O, and more

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

Interview experiences of popular companies

3.7
 • 10.2k Interviews
3.9
 • 8k Interviews
3.7
 • 5.5k Interviews
3.8
 • 5.5k Interviews
3.8
 • 4.7k Interviews
4.0
 • 761 Interviews
3.8
 • 517 Interviews
4.0
 • 480 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

Java Full Stack 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