DXC Technology
Optimum Technology Interview Questions and Answers
Q1. HOW TO CREATE OUR OWN IMMUTABLE CLASS? WHY IMMUTABLE CLASS
Immutable classes in Java are classes whose objects cannot be modified once they are created.
Make the class final to prevent inheritance
Make all fields private and final
Do not provide setter methods for fields
Ensure that any mutable objects within the class are also immutable
Q2. IN WHICH SITUATION WE USE @PRIMARY AND @ QUALIFIER ?
Use @Primary to specify a primary bean when multiple beans of the same type are present. Use @Qualifier to specify a specific bean when multiple beans of the same type are present.
Use @Primary to indicate the primary bean to be used when multiple beans of the same type are present in the Spring application context.
Use @Qualifier along with @Autowired to specify a specific bean to be injected when multiple beans of the same type are present.
Example: @Primary annotation can be ...read more
Q3. WHAT IS DIFFERENCE BETWEEN COMPOSITION AND AGGREGATION ?
Composition is a strong relationship where the child object cannot exist independently of the parent object, while aggregation is a weak relationship where the child object can exist independently.
Composition is a 'has-a' relationship, where the child object is a part of the parent object.
Aggregation is a 'has-a' relationship, where the child object is not a part of the parent object.
In composition, the child object is created and destroyed along with the parent object.
In agg...read more
Q4. DIFFERENCE BETWEEN INTERFACE AND ABSTRACT CLASS.
Interface is a contract with no implementation, while abstract class can have some implementation.
Interface cannot have any method implementation, while abstract class can have some method implementations.
A class can implement multiple interfaces, but can only extend one abstract class.
Interfaces are used to achieve multiple inheritance in Java.
Abstract classes can have constructors, while interfaces cannot.
Example: Interface - Runnable, Abstract Class - Animal with abstract ...read more
Q5. DIFFERENCE BETWEEN HASHMAP AND CONCURRENTHASH MAP
HashMap is not thread-safe while ConcurrentHashMap is thread-safe.
HashMap is not thread-safe and can lead to ConcurrentModificationException if modified during iteration.
ConcurrentHashMap allows concurrent read and write operations without the need for external synchronization.
ConcurrentHashMap achieves thread-safety by dividing the map into segments, allowing multiple threads to operate on different segments concurrently.
ConcurrentHashMap is more suitable for multi-threaded ...read more
Q6. DIFFERENCE BETWEEN COMPARABLE AND COMPARATOR.
Comparable is an interface used for natural ordering of objects, while Comparator is an interface used for custom ordering of objects.
Comparable interface is implemented by the class whose objects are to be compared, while Comparator interface is implemented by a separate class.
Comparable interface has a single method compareTo() for comparing objects, while Comparator interface has a single method compare() for custom comparison logic.
Comparable interface is used for natural...read more
Q7. DIFFERENCE BETWEEN COLLECTION AND STREAM
Collections store data while streams process data in a functional way.
Collections are used to store and manage groups of objects, while streams are used to process collections of objects.
Collections are mutable, meaning you can add, remove, or modify elements, while streams are immutable and do not change the original data.
Streams use functional programming concepts like map, filter, and reduce to process data efficiently.
Collections are eager, meaning they store all elements...read more
Q8. DESCRIBE TYPES JVM MEMORY.
JVM memory consists of Young Generation, Old Generation, and Permanent Generation.
Young Generation: where new objects are allocated and aged before moving to Old Generation.
Old Generation: where long-lived objects are stored.
Permanent Generation: where metadata such as class definitions and method information are stored.
Top Senior Java Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month