0% found this document useful (0 votes)
100 views2 pages

Java Interview Questions Overview

This document lists frequently asked interview questions about Java programming concepts and technologies including Java 8 features, OOP concepts, functional interfaces, lambda expressions, memory, streams, multi-threading, Spring, Hibernate, SQL, and scenario-based Java programs. It includes questions on data structures, algorithms, design patterns, REST APIs, databases and how to connect them with Java applications.

Uploaded by

S.S. Ammar
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
0% found this document useful (0 votes)
100 views2 pages

Java Interview Questions Overview

This document lists frequently asked interview questions about Java programming concepts and technologies including Java 8 features, OOP concepts, functional interfaces, lambda expressions, memory, streams, multi-threading, Spring, Hibernate, SQL, and scenario-based Java programs. It includes questions on data structures, algorithms, design patterns, REST APIs, databases and how to connect them with Java applications.

Uploaded by

S.S. Ammar
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
  • Frequently Asked Interview Questions

Frequently asked interview questions Part 1

1. JAVA 8 FEATURES
2. OOPS
3. POLYMORPHISM
4. INHERITANCE
5. ENCAPSULATION
6. ABSTRACTION
7. FUNCTIONAL INTERFACE
8. LAMDA EXPRESSION
9. EXPLAIN FUNCTION INTERFACE PREDICATE, CONSUMER, SUPPLIER
10. MARKER INTERFACE
11. COMPARABLE VS COMPARATOR INTERFACE
12. ABSTRACT CLASS VS INTERFACE
13. MEMORY- HEAP, STACK, STATIC
14. STREAM IN JAVA
15. EQUALS AND HASHCODE IN JAVA
16. WHY STRING IS IMMUTABLE
17. STRING BUFFER AND STRING BUILDER
18. WHAT IS MICROSERVICE
19. DEEP COPY, SHALLOW COPY
20. STRING CONSTANT POOL
21. MULTI THREADING
22. CALLABLE RUNNABLE
23. DOCKER
24. STATIC METHOD
25. CLASS AND OBJECT
26. TERNARY OPERATOR
27. REFLECTION
28. FAIL SAFE FAIL FAST
29. SERIALIZAITON IN JAVA
30. SERVLET & JSP
31. HOW TO INSTANTIATE AN OBJECT IN JAVA
32. STATUS CODE, RESTFUL API
33. DEPENDECNY INJECTION
34. HASH MAP AND ITS INTERNAL WORKING
35. ARRAY VS ARRAYLIST
36. LIST VS SET
37. HASH MAP VS CONCURRENT HASH MAP VS SYNCHRONISED HASH MAP
38. SPRING VS SPRING BOOT
39. @OVERRIDE ANNOTATION
40. SPECIFIC ANNOTATION TO START SPRING BOOT APP AND WHAT IS THAT COMBINED OF
41. SPRING BOOT ACTUATOR
42. DIFFERENT ANNOTATION USED IN SPRING BOOT
43. @TRANSACTIONAL
44. @PATH VARIABLE VS @REQUESTPARAM
45. SPRING BOOT FEATURES
46. SPRING MVC
47. DIFFERENCE CONTROLLER & REST CONTROLLER
48. @PROFILE
49. APPLICATION PROPERTIES
50. CHANGE DEFAULT SERVER IN SPRING BOOT
51. SCOPE OF BEANS AND DEFAULT SCOPE
52. DIFFERENT DESIGN USED
53. SINGLETON DESIGN PATTERN, SINGLETON CLASS
54. GET, POST, PUT , DELETE
55. REST API
56. JOINS
57. BREAK
58. HOW TO AVOID DUPLICATES IN SQL
59. WHY HIBERNATE PREFERRED OVER JDBC
60. WANT ONLY 10 RECORDS OF 100 WRITE SQL QUERY
61. INDEXING A DATABASE
62. TABLE, ENTITY
63. PRIMARY KEY VS FOREIGN KEY
64. HIBERNATE OVERVIEW
65. CONNECTING DATABASE AND JAVA
66. EAGER AND LAZY LOADING IN HIBERNATE
67. JPA VS JDBC, SPRING DATA JPA
Write a java program for
1. REVERSE STRING
2. FABIONACCI SERIES
3. FACTORIAL
4. PRIME OR NOT
5. PALINDROME OR NOT
6. ODD OR EVEN
7. FIND DUPLICATE CHAR IN STRING
8. COUNT DUPLICATE CHAR IN STRING
9. COUNT [Link] WORDS IN STRING
10. MAX ELEMENT IN A ARRAY
11. SECOND LARGEST ELEMENT IN ARRAY
12. SUM OF ODD AND EVEN NUMBERS IN A ARRAY
13. SWAP 2 NUMBERS
14. ARRAY{1,2,3,4} --> WRITE A JAVA PROGRAM FOR SPLITTING ARRAY SO THAT SUM IS SAME
THAT IS LIKE -->{1,4} & {2,3}
15. SORT EMPLOYEES BASED ON NAME IF NAME SAME THEN AGE
Scenario based programs
1. SINGLETON CLASS JAVA PROGRAM
2. AVOID DUPLICATES IN HASH MAP
3. LIST TO SET
4. LIST TO MAP
5. STREAM MAP SCENARIO BASED
6. VARIOUS WAYS OF SORTING PROGRAM SCENARIO BASED ANY ONE SORTING METHOD OF
ARRAY
7. [Link] VS == --> SCENARIO BASED
8. STRING , NEW STRING DIFFERENCE --> SCENARIO BASED
9. WHEN WE USE LAMBDA EXPRESSION --> SCENARIO BASED
10. WRITE SQL QUERY FOR SECOND LARGEST SALARY

Common questions

Powered by AI

Spring Boot simplifies application development by providing defaults for common configuration settings, thus eliminating the need for extensive XML configuration typical in traditional Spring applications. It offers embedded servers to reduce deployment complexity, auto-configuration to automatically set up Spring applications based on the included libraries, and 'starter' dependencies to simplify dependency management . These features enhance developer productivity and accelerate application bootstrapping by minimizing setup and configuration overhead, allowing developers to focus more on functionality than configuration .

Functional interfaces in Java 8 are interfaces with a single abstract method, providing a target for lambda expressions which enhance their utility by offering a clear and concise syntax to express instances of these interfaces. This leads to more readable and maintainable code. Lambda expressions eliminate the need for anonymous class implementations, promote the use of high-order functions, and enable the convenience of behavior parameterization . They simplify the implementation of instances, allowing focus on the behavior rather than the boilerplate code.

Lazy loading is preferable when you have large datasets you don't want to load completely at once for performance reasons. It allows for on-demand initialization of objects to conserve memory and improve initial load times . Eager loading is suited for smaller datasets where accessing the data immediately after loading the object is critical to ensure availability and minimize repeated queries. Lazy loading reduces memory footprint but increases runtime complexity by repeatedly querying the database, while eager loading might lead to redundant data retrieval and increased initial load time .

The equals() method determines if another object is "equal" to this one. The hashCode() method provides a unique integer representing the object instance and is used for bucketing in hash algorithms. Consistent overriding is crucial because if two objects are equal as per equals(), they must return the same hashCode() to ensure the objects function correctly in hash-based collections like HashMap. Inconsistent implementation can lead to the logical contradiction where equal objects inhabit different buckets .

String immutability in Java is beneficial, especially in multi-threaded environments, primarily because it ensures thread safety. As strings cannot change after creation, they can be shared across multiple threads without synchronization, reducing the overhead of locking mechanisms. The immutability also optimizes memory usage by enabling the String Pool, where identical strings share a single storage location . This leads to a reduction in memory footprint and improves performance.

An abstract class can have member variables and defined methods, whereas interfaces can only have constants (variables are implicitly 'public static final') and abstract methods (before Java 8). You choose an abstract class when you need a common base class with shared code, but use an interface to define a contract for classes to implement, enabling multiple inheritance . Choose interfaces when multiple inheritance and unrelated class sharing a contract is needed, and abstract classes for common base class functionality.

HashMap is non-synchronized and allows null values and keys, designed for single-threaded scenarios while ConcurrentHashMap is synchronized for concurrent use, preventing null keys and values . ConcurrentHashMap enhances performance in concurrent applications by allowing concurrent reads and simultaneous writes in a segment-based manner, reducing contention. Its segmented locks lead to higher throughput and reduced overhead compared to synchronized maps where a complete lock serializes access .

Polymorphism enhances flexibility and maintainability by allowing objects to be treated as instances of their parent class. This decouples the code specifics from the code dynamics, allowing changes in object implementations without altering the system’s behavior. Using polymorphism, new types can be introduced into the system with minimal changes to existing code. It facilitates a single interface to interact with different types and encourages method overriding, allowing dynamic method resolution at runtime .

Encapsulation in object-oriented programming allows for restricting access to certain components of an object and bundling data and methods that work on the data within a single unit or class. This design principle contributes to robust software design by protecting object integrity and hiding the internal implementation details, only exposing a controlled interface. Object interaction is well-defined and less dependency on changes in other parts of the program are ensured, thus leading to a more maintainable codebase .

The @Transactional annotation simplifies transaction management by abstracting boilerplate code required for starting, committing, and rolling back transactions. Unlike traditional manual management that requires explicit coding of transaction boundaries, @Transactional allows these activities to be handled declaratively, enhancing readability and reducing error chances in complex transaction scripts . It promotes cleaner code and easier maintenance by centralizing transaction policy within configuration and metadata rather than code logic, enabling flexibility in transaction management policies without extensive code alterations .

Frequently asked interview questions Part 1 
1. JAVA 8 FEATURES 
2. OOPS 
3. POLYMORPHISM 
4. INHERITANCE 
5. ENCAPSULATION
49. APPLICATION PROPERTIES 
50. CHANGE DEFAULT SERVER IN SPRING BOOT 
51. SCOPE OF BEANS AND DEFAULT SCOPE 
52. DIFFERENT DES

You might also like