Java Full Stack Developer

20+ Java Full Stack Developer Interview Questions and Answers for Freshers

Updated 7 May 2024
search-icon

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

Q2. 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; }

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

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

Are these interview questions helpful?

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

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

Share interview questions and help millions of jobseekers 🌟

man-with-laptop

Q7. 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';

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

Java Full Stack Developer Jobs

Java Full Stack Developer 7-11 years
Genpact
3.9
Noida
Java Full Stack Developer 6-11 years
Cognizant
3.8
₹ 20 L/yr - ₹ 35 L/yr
Hyderabad / Secunderabad
Job Opportunity For Java Full stack Developer 6-11 years
Cognizant
3.8
Pune

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

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

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

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

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

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

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

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

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

Q18. Write Snippet to create two beans

Ans.

Creating two beans in Java using Spring framework

  • Use @Component annotation to define a bean

  • Specify the bean name using @Component("beanName")

  • Use @Autowired annotation to inject one bean into another

Q19. Attached Entity vs Detached Entity

Ans.

Attached entities are actively managed by the persistence context, while detached entities are no longer actively managed.

  • Attached entities are being managed by the persistence context and any changes made to them will be automatically synchronized with the database.

  • Detached entities are not being managed by the persistence context and changes made to them will not be automatically synchronized with the database.

  • Entities become detached when the persistence context is closed,...read more

Q20. Transaction Management in Hibernate

Ans.

Transaction management in Hibernate ensures ACID properties for database operations.

  • Hibernate provides built-in transaction management support through Session interface.

  • Transactions can be managed programmatically using beginTransaction(), commit(), and rollback() methods.

  • Hibernate also supports declarative transaction management using annotations like @Transactional.

  • Transactions in Hibernate ensure Atomicity, Consistency, Isolation, and Durability for database operations.

Q21. Different Types of Autowiring

Ans.

There are three types of autowiring in Spring: byType, byName, and constructor.

  • byType: Spring looks for a bean of the same type and injects it.

  • byName: Spring looks for a bean with the same name and injects it.

  • constructor: Spring looks for a constructor and injects the arguments.

Q22. Filter a List using Streams

Ans.

Filter a List using Streams in Java

  • Use the filter() method to apply a predicate to each element in the stream

  • Use collect() method to convert the stream back to a List

  • Example: List names = Arrays.asList("Alice", "Bob", "Charlie"); List filteredNames = names.stream().filter(name -> name.startsWith("A")).collect(Collectors.toList());

Q23. Sort an Employee HashMap

Ans.

Sort an Employee HashMap based on keys or values

  • Use TreeMap to automatically sort by keys

  • Use Comparator to sort by values

  • Convert HashMap to List and then sort

Q24. Constructor vs ngOnInit

Ans.

Constructor is a special method used to initialize an object, while ngOnInit is a lifecycle hook in Angular.

  • Constructor is used to create and initialize an object of a class.

  • ngOnInit is a lifecycle hook in Angular that is called after the component is initialized.

  • Constructor is defined using the constructor keyword, while ngOnInit is a method defined in the component class.

  • Constructor is called only once during the creation of an object, while ngOnInit is called every time th...read more

Q25. Iterator vs ListIterator

Ans.

Iterator is a universal interface for iterating over a collection, while ListIterator is a specialized interface for iterating over lists.

  • Iterator can only move forward, while ListIterator can move in both directions.

  • ListIterator has additional methods like previous(), hasPrevious(), and add().

  • ListIterator is only available for List implementations, while Iterator can be used with any collection.

Q26. Promises vs Observables

Ans.

Promises are used for asynchronous programming in JavaScript, while Observables are used for reactive programming.

  • Promises represent a single value that may be available now or in the future.

  • Observables represent a stream of values that can be emitted over time.

  • Promises are eager, meaning they start executing as soon as they are created.

  • Observables are lazy, meaning they only start executing when subscribed to.

  • Promises can be chained using .then() to handle success or failure...read more

Q27. try vs try-with-resources

Ans.

try vs try-with-resources

  • The 'try' statement is used to define a block of code to be tested for exceptions.

  • The 'try-with-resources' statement is used to automatically close resources that implement the AutoCloseable interface.

  • Try-with-resources is more concise and less error-prone compared to try-catch-finally.

  • Try-with-resources can handle multiple resources in a single statement.

Q28. JPA Repository inbuilt methods

Ans.

JPA Repository provides inbuilt methods for common database operations in Spring applications.

  • JPA Repository provides methods like save(), findById(), findAll(), deleteById(), etc.

  • These methods help in performing CRUD operations on entities without writing custom queries.

  • For example, userRepository.save(user) saves a user entity to the database.

Q29. Lazy vs Eager Fetch

Ans.

Lazy fetch loads data only when needed, while eager fetch loads all related data upfront.

  • Lazy fetch is more efficient for performance as it only loads data when required.

  • Eager fetch can lead to performance issues by loading unnecessary data upfront.

  • Lazy fetch is the default behavior in JPA, while eager fetch needs to be explicitly specified.

  • Example: Lazy fetch can be used for loading a list of items in a shopping cart only when the user views the cart.

  • Example: Eager fetch can...read more

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

Interview experiences of popular companies

3.7
 • 10.4k Interviews
3.9
 • 8.1k Interviews
3.7
 • 5.6k Interviews
3.8
 • 5.6k Interviews
3.8
 • 4.8k Interviews
4.0
 • 775 Interviews
3.8
 • 530 Interviews
4.0
 • 484 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