Fullstack Java Application Developer

30+ Fullstack Java Application Developer Interview Questions and Answers

Updated 19 Sep 2024
search-icon

Q1. which authentication methods used to secure rest api

Ans.

Various authentication methods can be used to secure REST API, including OAuth, JWT, Basic Authentication, and API Keys.

  • OAuth is a popular authentication method that allows users to grant access to third-party applications without sharing their credentials.

  • JWT (JSON Web Tokens) is a stateless authentication mechanism that uses a token to authenticate users.

  • Basic Authentication uses a username and password to authenticate users.

  • API Keys are unique identifiers that are used to ...read more

Q2. which data structure used in array and hashmap

Ans.

Arrays use a linear data structure while HashMap uses a key-value pair data structure.

  • Arrays are indexed collections of elements of the same data type.

  • HashMaps store key-value pairs and allow for fast retrieval of values based on their keys.

  • Arrays have a fixed size while HashMaps can dynamically resize.

  • Arrays are more efficient for simple data structures while HashMaps are better for complex data structures.

Fullstack Java Application Developer Interview Questions and Answers for Freshers

illustration image

Q3. write a program to get duplicate element in array list

Ans.

Program to find duplicate elements in an array list

  • Create a HashSet to store unique elements

  • Loop through the array list and add each element to the HashSet

  • If an element already exists in the HashSet, it is a duplicate

  • Add the duplicate element to another list or print it

Q4. Difference between get session and load in hibernate

Ans.

getSession() retrieves the current session while load() method loads the object by its identifier.

  • getSession() method is used to retrieve the current session from the session factory.

  • load() method is used to load the object by its identifier.

  • getSession() method returns null if there is no current session.

  • load() method throws an exception if the object is not found in the database.

  • getSession() method is used for read and write operations while load() method is used for read-on...read more

Are these interview questions helpful?

Q5. How do one microservice communicate with the another microservice?

Ans.

Microservices can communicate with each other through synchronous HTTP calls, asynchronous messaging, or using a message broker.

  • Synchronous communication: Microservices can communicate directly through HTTP requests, such as REST APIs.

  • Asynchronous communication: Microservices can use messaging protocols like RabbitMQ or Kafka to send and receive messages.

  • Message broker: Microservices can communicate through a message broker like Apache Kafka, which acts as an intermediary for...read more

Q6. what are idempotent methods in rest

Ans.

Idempotent methods in REST are HTTP methods that can be repeated multiple times without changing the result beyond the initial application.

  • Idempotent methods are safe to retry or repeat without causing unintended side effects.

  • GET, HEAD, PUT, and DELETE are idempotent methods.

  • POST is not idempotent because it creates a new resource with a new URI each time it is called.

  • Idempotency is important for ensuring the reliability and consistency of RESTful APIs.

Share interview questions and help millions of jobseekers 🌟

man-with-laptop

Q7. Different design pattern and how you have implement in projects

Ans.

I have implemented design patterns like Singleton, Factory, and Observer in various projects.

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

  • Utilized Factory pattern to create objects without specifying the exact class of object that will be created.

  • Used Observer pattern to establish a one-to-many dependency between objects, so that when one object changes state, all its dependents are notified and updated automatically.

Q8. How to improve the performance of a running application.

Ans.

To improve the performance of a running application, consider optimizing code, database queries, caching, and server resources.

  • Optimize code by identifying and fixing bottlenecks, reducing unnecessary loops, and improving algorithms.

  • Optimize database queries by using indexes, avoiding unnecessary joins, and limiting the amount of data retrieved.

  • Implement caching mechanisms to store frequently accessed data in memory, reducing the need to fetch it from the database repeatedly....read more

Fullstack Java Application Developer Jobs

Application Developer - Java Full Stack 6-10 years
ENIGMATICS LABS PRIVATE LIMITED
0.0
Bangalore / Bengaluru
Application Developer Java Full Stack 6-10 years
Audacious Minds
1.0
Bangalore / Bengaluru

Q9. what is hql? what are it's benefits?

Ans.

HQL stands for Hibernate Query Language. It is an object-oriented query language used to retrieve data from a database.

  • HQL is similar to SQL but uses object-oriented concepts like inheritance, polymorphism, and association.

  • It is database independent and can be used with any database supported by Hibernate.

  • HQL queries are compiled to SQL queries at runtime, which makes it more efficient than using SQL directly.

  • It supports caching and lazy loading, which can improve performance...read more

Q10. how do we handle exceptions in rest

Ans.

Exceptions in REST are handled using try-catch blocks and HTTP status codes.

  • Use try-catch blocks to catch exceptions thrown by the application

  • Map exceptions to appropriate HTTP status codes

  • Return error messages in the response body

  • Use global exception handlers to handle uncaught exceptions

  • Avoid returning sensitive information in error messages

Q11. what are methods of object class

Ans.

Methods of Object class in Java

  • toString() - returns a string representation of the object

  • equals(Object obj) - checks if two objects are equal

  • hashCode() - returns a hash code value for the object

  • getClass() - returns the runtime class of the object

  • wait() - causes the current thread to wait

  • notify() - wakes up a single thread that is waiting on the object

  • notifyAll() - wakes up all threads that are waiting on the object

Q12. association between hashcode and equals to method

Ans.

Hashcode and equals method are related in Java to ensure proper object comparison and hashing.

  • The hashcode method returns an integer value that represents the object's unique identifier.

  • The equals method compares two objects for equality and returns a boolean value.

  • If two objects are equal, their hashcodes must be equal as well.

  • If two objects have the same hashcode, it does not necessarily mean they are equal.

  • It is important to override both methods when creating custom class...read more

Q13. difference between string and string buffer

Ans.

String is immutable while StringBuffer is mutable.

  • StringBuffer is faster for concatenation operations.

  • StringBuffer has methods to modify the string while String does not.

  • StringBuffer is thread-safe while String is not.

  • Example: String str = "hello"; StringBuffer sb = new StringBuffer(str); sb.append(" world");

  • Example: String str = "hello"; str.concat(" world"); // returns a new string, original string is not modified.

Q14. What is singleton class and its implementation

Ans.

Singleton class is a class that can only have one instance and provides a global point of access to it.

  • Singleton class restricts the instantiation of a class to one object.

  • It provides a way to access its unique instance globally.

  • Commonly used in scenarios where only one instance of a class is needed, such as database connections or thread pools.

Q15. how do you use joins in spring boot?

Ans.

Joins in Spring Boot are used to retrieve data from multiple tables in a database using relationships between them.

  • Use @Query annotation with JPQL or native SQL to perform joins in Spring Boot repositories

  • Specify the join condition in the query using ON keyword

  • Use JOIN FETCH to eagerly fetch associated entities in a single query

Q16. How is exception handled in Inheritance

Ans.

Exceptions in inheritance are handled using try-catch blocks in the subclass.

  • Inherited methods can throw exceptions that need to be caught in the subclass.

  • Subclass can override superclass methods and handle exceptions differently.

  • Superclass methods can declare checked exceptions that subclasses must handle.

  • Exceptions can be rethrown or wrapped in a new exception in the subclass.

Q17. how to do xml validation

Ans.

XML validation can be done using XML Schema Definition (XSD) or Document Type Definition (DTD).

  • XSD is the preferred method for XML validation as it provides more features and is easier to use.

  • DTD is an older method and has limited features compared to XSD.

  • XML validation can be done using tools like XMLSpy, Notepad++, and online validators like W3C Markup Validation Service.

  • Validation can be done programmatically using libraries like JAXB, SAX, and DOM in Java.

  • Validation error...read more

Q18. how to secure rest api

Ans.

Secure REST API using authentication, encryption, and authorization.

  • Use HTTPS protocol to encrypt data in transit

  • Implement authentication using tokens or OAuth2

  • Implement authorization using roles and permissions

  • Use input validation and output encoding to prevent injection attacks

  • Implement rate limiting to prevent DDoS attacks

Q19. what is sql injection

Ans.

SQL injection is a type of cyber attack where malicious SQL statements are inserted into an entry field to manipulate the database.

  • SQL injection can be used to steal sensitive information, modify or delete data, or even take control of the entire database.

  • It can be prevented by using parameterized queries, input validation, and limiting user privileges.

  • Example: Entering ' OR 1=1;--' in a login form can bypass authentication and grant access to the system.

  • Example: Entering 'DR...read more

Q20. what is synchronized key word

Ans.

Synchronized keyword is used to control access to shared resources in a multithreaded environment.

  • It ensures that only one thread can access the shared resource at a time.

  • It can be applied to methods or blocks of code.

  • It can cause performance issues if used excessively.

  • Example: synchronized void myMethod() { //code }

  • Example: synchronized(this) { //code }

Q21. describe reflection api in java

Ans.

Reflection API in Java allows inspection and modification of runtime behavior of a program.

  • Reflection API provides classes like Class, Method, Field, Constructor, etc. to inspect and modify the behavior of a program at runtime.

  • It can be used to access private fields and methods of a class.

  • It can be used to create new instances of a class dynamically.

  • It can be used to invoke methods of a class dynamically.

  • It can be used to get information about the class hierarchy and interfac...read more

Q22. Difference between put and post

Ans.

PUT is used to update an existing resource, while POST is used to create a new resource.

  • PUT replaces the entire resource with the new data, while POST appends the new data to the existing resource.

  • PUT is idempotent, meaning multiple identical requests will have the same effect as a single request, while POST is not.

  • PUT requires the client to specify the resource ID in the request URL, while POST does not.

  • Example: PUT /users/123 updates the user with ID 123, while POST /users ...read more

Q23. Describe caching mechanism in hibernate

Ans.

Hibernate provides two levels of caching: first-level cache and second-level cache.

  • First-level cache is enabled by default and is associated with a Session object.

  • Second-level cache is optional and can be configured to use different caching providers like Ehcache, Hazelcast, etc.

  • Caching can improve application performance by reducing the number of database queries.

  • Caching can also cause data inconsistency issues if not used properly.

  • Hibernate provides annotations like @Cachea...read more

Q24. describe cascading in hibernate

Ans.

Cascading in Hibernate refers to the ability to propagate the state of an entity to its associated entities.

  • Cascading is used to automatically persist, update, or delete associated entities when the state of the parent entity changes.

  • There are different types of cascading options available in Hibernate, such as ALL, PERSIST, MERGE, REMOVE, and REFRESH.

  • For example, if a parent entity has a collection of child entities and the cascading option is set to ALL, then any changes ma...read more

Q25. Types of cloning in java

Ans.

There are two types of cloning in Java: Shallow and Deep cloning.

  • Shallow cloning creates a new object with the same field values as the original object, but the fields refer to the same objects as the original object.

  • Deep cloning creates a new object with the same field values as the original object, but the fields refer to new copies of the original objects.

  • Shallow cloning can be done using the clone() method, while deep cloning requires custom implementation.

  • Shallow cloning...read more

Q26. What is the use of Java

Ans.

Java is a versatile programming language used for developing a wide range of applications, from web and mobile apps to enterprise systems.

  • Java is used for developing web applications, mobile applications, desktop applications, and enterprise systems.

  • It is commonly used in backend development for server-side programming.

  • Java is also used in game development, scientific applications, and big data processing.

  • It is platform-independent, meaning Java programs can run on any device...read more

Q27. do you know Caching ?

Ans.

Caching is the process of storing data in a temporary location to reduce access time and improve performance.

  • Caching helps in reducing the load on the server by storing frequently accessed data closer to the user.

  • Examples of caching include browser caching, CDN caching, and database caching.

  • Caching can be implemented at different levels such as application-level caching, database-level caching, and server-level caching.

Q28. design patterns in java

Ans.

Design patterns are reusable solutions to common software problems.

  • Design patterns help in creating flexible, reusable, and maintainable code.

  • Some popular design patterns in Java are Singleton, Factory, Observer, and Decorator.

  • Singleton pattern ensures that only one instance of a class is created.

  • Factory pattern provides an interface for creating objects in a superclass, but allows subclasses to alter the type of objects that will be created.

  • Observer pattern allows objects to...read more

Q29. Find all the pairs with given sum coding

Ans.

The task is to find all pairs in an array that add up to a given sum.

  • Iterate through the array and store each element in a hash set.

  • For each element, check if the difference between the sum and the element exists in the hash set.

  • If it does, add the pair to the result list.

Q30. What is Dependency Injection

Ans.

Dependency Injection is a design pattern in which components are given their dependencies rather than creating them internally.

  • In Dependency Injection, the dependencies of a class are injected from the outside, typically through constructor injection or setter injection.

  • This helps in achieving loose coupling between classes, making the code more modular and easier to test.

  • Example: Spring Framework uses Dependency Injection to manage the dependencies of Java components.

Frequently asked in,

Q31. design patterns in microservices?

Ans.

Design patterns in microservices help in structuring and organizing code for scalability and maintainability.

  • Use patterns like Service Registry, Circuit Breaker, and Gateway for communication between microservices.

  • Implement patterns like Saga, CQRS, and Event Sourcing for managing data consistency and scalability.

  • Apply patterns like API Gateway, Decomposition, and Database per Service for better separation of concerns and scalability.

Q32. how to add dependency

Ans.

To add a dependency, you need to specify it in the project's build file.

  • Open the build file (pom.xml for Maven or build.gradle for Gradle)

  • Add the dependency in the appropriate section

  • Save the file and run the build command to download and install the dependency

  • Example: com.example example-library 1.0.0

Q33. Java overloading overriding differences

Ans.

Overloading is having multiple methods with the same name but different parameters, while overriding is implementing a method in a subclass with the same signature as in the superclass.

  • Overloading allows different methods to have the same name but different parameters.

  • Overriding involves implementing a method in a subclass with the same signature as in the superclass.

  • Overloading is determined at compile time based on the method signature and parameters, while overriding is de...read more

Q34. spring vs spring boot?

Ans.

Spring is a framework for building Java applications, while Spring Boot is a tool that simplifies the setup and configuration of Spring applications.

  • Spring is a comprehensive framework that provides support for various Java technologies like JDBC, JPA, and REST.

  • Spring Boot is an opinionated tool that aims to simplify the development process by providing defaults for configuration and dependencies.

  • Spring Boot includes embedded servers like Tomcat or Jetty, making it easy to ru...read more

Q35. Define a immutable class

Ans.

Immutable class is a class whose instances cannot be modified after creation.

  • Immutable classes have all fields as final and private.

  • Immutable classes do not have any setter methods.

  • Examples of immutable classes in Java are String, Integer, and LocalDate.

Q36. Internal working of hashmap

Ans.

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

  • 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 find the index in the array where it will be stored.

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

  • HashMap allows one null key and multiple null values.

  • The initial capacity and load factor can be specified when c...read more

Frequently asked in, ,
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Interview Questions for Fullstack Java Application Developer Related Skills

Interview experiences of popular companies

3.7
 • 10.3k Interviews
3.9
 • 8k Interviews
3.7
 • 7.5k Interviews
3.8
 • 4.8k Interviews
3.9
 • 3k Interviews
3.8
 • 2.8k Interviews
3.4
 • 264 Interviews
4.1
 • 110 Interviews
2.8
 • 4 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

Fullstack Java Application 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