100% found this document useful (1 vote)
47 views4 pages

Java Developer Interview Questions Guide

The document contains a comprehensive list of interview questions for Java developers, covering fundamental concepts such as data types, exception handling, and object-oriented programming principles. It also includes advanced topics related to Java frameworks like Servlets, JDBC, and Spring Framework, addressing concepts like dependency injection and JPA. The questions are designed to assess both basic and advanced knowledge of Java programming and related technologies.

Uploaded by

bairagiaditya2
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
47 views4 pages

Java Developer Interview Questions Guide

The document contains a comprehensive list of interview questions for Java developers, covering fundamental concepts such as data types, exception handling, and object-oriented programming principles. It also includes advanced topics related to Java frameworks like Servlets, JDBC, and Spring Framework, addressing concepts like dependency injection and JPA. The questions are designed to assess both basic and advanced knowledge of Java programming and related technologies.

Uploaded by

bairagiaditya2
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

JAVA DEVELOPER INTERVIEW QUESTIONS IT EXPERTS

1. What are the Data Types supported by Java ? What is Autoboxing and
Unboxing ?
2. What is the difference between an Interface and an Abstract class?
3. Difference between this() and super() in java ?
4. Why main() method is public, static and void in java ?
5. Difference between overriding and overloading in java?
6. In how many ways we can do exception handling in java?
7. Explain differences between checked and Unchecked exceptions in java?
8. Explain throw keyword in java?
9. Explain importance of throws keyword in java?
10. Explain the life cycle of thread?
11. Explain what is encapsulation?
12. What is inheritance ?
13. Explain importance of inheritance in java?
14. What is polymorphism in java?
15. Difference between Array and ArrayList ?
16. Difference between Comparator and Comparable in java?
17. Difference between arraylist and linkedlist?
18. Difference between Concurrent HashMap and synchronizedHashMap and
Normal Hashmap?
19. Explain the internal working of HashMap ?
20. What is marker Interface ?
21. Difference between == and equals() method in java ?
22. What is Functional Interface ?
23. What is Lambda Expression And how it works internally ?
24. What is Singleton Class and How to make it ?
25. What is Immutable Class How to make our own customizable Immutable
Class ?
26. Explain static keyword ?
27. Explain HashSet Internal Working ?
28. What is Interface explain its features ?
29. How can we Achieve multiple inheritance in java ?
30. What is Co Variant in java ?
JAVA DEVELOPER INTERVIEW QUESTIONS IT EXPERTS

31. Difference between jvm jdk jre ?


32. What is garbage collector in java ?
33. What is deamon thread in java ?
34. What is the difference between final, finally and finalize() ?
35. Difference Between yield, sleep and join method in java ?
36. What is Deadlock ?

ADVANCE JAVA QUESTIONS

1. What is Servlet ?
2. Explain about the servlet lifecycle ?
3. Diffrence between generic servlet and Http servlet ?
4. What is servlet context ?
5. What is [Link] or deployment descriptor ?
6. In how many ways we can deploy our web application in tomcat server ?
7. What is server container and web container ?
8. Explain minimum 5 tags from the [Link] ?
9. What is public and private pages in the servlet ?
10. What is the difference between doGet and doPost method ?
11. How does servlet works ?
12. What is request dispatcher and sendRedirect?
13. What is Jsp ? Explain how it is different from html ?
14. What are scriptlets ?
15. What are expressions ?
16. How are the jsp request handled?
17. What is JDBC ?
18. Explain the role of Driver in JDBC ?
19. What is the purpose of [Link] method ?
20. What is Statement ?
21. What is Prepared Statement and Callable Statement and what is the
difference in both ?
22. What is connection pool ?
JAVA DEVELOPER INTERVIEW QUESTIONS IT EXPERTS

SPRING FRAMEWORK QUESTIONS

1. What is loose coupling?


2. What is a Dependency?
3. What is IOC (Inversion of Control)?
4. What is Dependency Injection?
5. Can you give few examples of Dependency Injection?
6. What is Auto Wiring ?
7. What are the important roles of an IOC Container?
8. What are Bean Factory and Application Context?
9. Can you compare Bean Factory with Application Context?
10. How do you create an application context with Spring?
11. What is Dispatcher Servlet?
12. How do you set up Dispatcher Servlet?
13. What does @Component signify?
14. What does @Autowired signify?
15. What’s the difference Between @Controller, @Component, @Repository,
and @Service Annotations in Spring?
16. What is the default scope of a bean?
17. Are Spring beans thread safe?
18. What are the other scopes available?
19. What are the different types of dependency injections?
20. What is setter injection?
21. What is constructor injection?
22. How do you choose between setter and constructor injections?
23. What are Starter Projects?
24. Can you give examples of important starter projects?
25. What is [Link]?
26. What are some of the important things that can customized in
[Link]?
JAVA DEVELOPER INTERVIEW QUESTIONS IT EXPERTS

27. What is Spring Boot Actuator?


28. How do you monitor web services using Spring Boot Actuator?
29. What is JPA?
30. What is Hibernate?
31. How do you define an entity in JPA?
32. What is an Entity Manager?
33. What is a Persistence Context?
34. How do you map relationships in JPA?
35. What are the different types of relationships in JPA?
36. How do you define One to One Mapping in JPA?
37. How do you define One to Many Mapping in JPA?
38. How do you define Many to Many Mapping in JPA?

Common questions

Powered by AI

A class loader in Java is a part of the Java Runtime Environment (JRE) that dynamically loads Java classes into the Java Virtual Machine (JVM) at runtime. The class loader is vital as it fulfills the responsibility of converting class files into data structures that the JVM can interpret, linking classes and interfaces by resolving symbolic references to actual memory locations during execution. It maintains class namespaces to avoid naming conflicts, supports dynamic loading which is crucial for enabling applications to load and execute code that wasn’t present at compile time, and assists in defining security policies via class loader constraints. This execution model supports Java's platform-independent nature and its ability to defer certain execution decisions until runtime .

Lambda expressions in Java introduce a concise way to represent anonymous methods or functions, reducing boilerplate code and enhancing the code's expressiveness. They enable developers to write fewer lines of code by allowing the declaration of inline functions, particularly for implementing functional interfaces. This leads to cleaner implementation of single-method interfaces, such as Runnable or ActionListener, significantly improving readability by separating execution from the definition. Lambdas also facilitate functional programming styles in Java, allowing operations like filtering, mapping, and collecting to be performed neatly on collections using the Stream API, which is more intuitive and scalable than traditional approaches .

The 'throws' keyword in Java is used in a method signature to declare that this method can potentially throw certain exceptions, thus informing the method caller of the exception handling responsibilities. It is primarily used with checked exceptions as a way to adhere to the checked exception handling mandate set by Java. Developers should use 'throws' to propagate exceptions up the call stack when they decide that it makes more sense for upper layers of code to handle the exception or when exceptions need to be aggregated and logged in higher-level business logic. Correct use of 'throws' can significantly enhance code clarity and error management in a program .

In Java, an 'interface' is a reference type that can contain abstract methods, default methods, static methods, and constant declarations. Interfaces are used to define a contract that implementing classes must fulfill, enabling polymorphic behavior. An 'abstract class', on the other hand, can have abstract methods as well as concrete methods (methods with an implementation). An abstract class can provide a common base with fields and method implementations that its subclasses can inherit. Interfaces should be used when classes need to conform to a shared contract that can be implemented across disparate class hierarchies, whereas abstract classes are suitable for scenarios where there is a need to share state or functionality among closely related classes while allowing subclasses to provide specific behavior .

In Spring, the bean scope determines the lifecycle and visibility of bean instances. The 'singleton' scope, which is the default, ensures that the Spring container creates only one instance of a bean per container and returns that same instance on subsequent lookups. Conversely, the 'prototype' scope dictates that the container creates a new bean instance every time a request for that bean is made, allowing for multiple instances. This is useful when a non-shared, stateful instance is needed for each request. However, unlike singletons, the lifecycle of prototype beans is less managed by Spring, as it does not handle the complete lifecycle including destruction .

Both 'constructor injection' and 'setter injection' are mechanisms of implementing dependency injection in the Spring framework used to decouple the instantiation of objects from their configuration. Constructor injection involves passing dependencies through a class's constructor during instance creation, making dependencies explicit and immutable, promoting thread safety and consistency. Setter injection, on the other hand, uses setter methods to provide dependencies after the object’s instance is created, allowing for more flexible and reconfigurable objects. Choosing between them depends on the complexity and lifecycle of the bean: constructor injection is more suitable for required dependencies and promoting immutability, while setter injection is preferable for optional dependencies or when there's a need to change injection configurations post-instantiation .

Polymorphism in Java allows objects to be accessed through references of their superclass type, enabling a single interface to represent different underlying forms (data types). This reduces code complexity by allowing methods to be written that can operate on objects of many different classes that implement a common superclass or interface, without concern for the specific class of object. It allows for code reuse and flexibility, as new classes can be introduced with minimal changes to existing code due to method overriding. Consequently, polymorphism helps in building systems that are easier to scale and maintain .

Java achieves multiple inheritance through the use of interfaces. Although Java classes do not support multiple inheritance due to the potential ambiguity in method resolution (the 'diamond problem'), interfaces allow a class to implement multiple interfaces simultaneously. Since interfaces can provide default methods (from Java 8 onwards), this allows some flexibility in implementing multiple inheritance-like behavior, as a class can inherit method frameworks from multiple interfaces without ambiguity. This design choice avoids the complexities and limitations of traditional multiple inheritance in object-oriented programming .

ConcurrentHashMap and SynchronizedHashMap both allow for synchronized access to the map by multiple threads, but they handle it differently. A SynchronizedHashMap uses synchronization on the entire map, performing all operations in a synchronized block, which can lead to contention and reduced performance with high concurrency. ConcurrentHashMap, however, divides the map into segments and synchronizes modifications at the bucket level. This allows concurrent read and write operations with considerably greater throughput and reduced contention. This distinction is critical for high-performance multi-threaded applications as ConcurrentHashMap substantially mitigates thread bottlenecks encountered with synchronized approaches, enhancing scalability .

Checked exceptions are those that are checked at compile-time, meaning the Java compiler ensures that the programmer handles these exceptions either by using a try-catch block or by declaring them using a throws clause. They are typically used for conditions that can be reasonably expected during normal operations, such as IOException or SQLException. Unchecked exceptions, on the other hand, are not checked by the compiler and include runtime exceptions or errors like NullPointerException or ArrayIndexOutOfBoundsException. They represent programming bugs or errors that arise from logic issues within the program. This distinction is significant because it enforces error-handling at compile-time for checked exceptions, fostering more robust and predictable code .

You might also like