Synechron
Trooman Technologies Interview Questions and Answers
Q1. How do you convert list to arraylist? And vice versa
To convert list to arraylist, use ArrayList constructor. To convert arraylist to list, use List constructor.
To convert list to arraylist, use ArrayList constructor and pass the list as parameter.
To convert arraylist to list, use List constructor and pass the arraylist as parameter.
Example: List
list = Arrays.asList("one", "two", "three"); ArrayList
arrayList = new ArrayList<>(list); Example: ArrayList
arrayList = new ArrayList<>(Arrays.asList("one", "two", "three")); List
list =...read more
Q2. What are functional interfaces? What is the need to have functional interfaces?
Functional interfaces are interfaces with only one abstract method. They are used for lambda expressions and method references.
Functional interfaces are used for functional programming in Java.
They are used for lambda expressions and method references.
They have only one abstract method.
Examples of functional interfaces are Runnable, Callable, and Comparator.
Functional interfaces can be annotated with @FunctionalInterface to ensure they have only one abstract method.
Q3. How do you handle exceptions in Rest APIs
Exceptions in Rest APIs are handled using try-catch blocks and appropriate error responses.
Use try-catch blocks to catch exceptions that may occur during API execution.
Handle different types of exceptions separately to provide specific error responses.
Return appropriate HTTP status codes and error messages in the response.
Log the exception details for debugging purposes.
Consider using a global exception handler to centralize exception handling logic.
Q4. What is the highest limit of Hashmap?
The highest limit of HashMap is Integer.MAX_VALUE, which is 2^31 - 1.
The highest limit is determined by the maximum capacity of an array in Java, which is Integer.MAX_VALUE.
The default initial capacity of a HashMap is 16, and it automatically increases its capacity as needed.
If the number of elements exceeds the maximum capacity, an OutOfMemoryError will be thrown.
Q5. What are streams in Java and why are they used?
Streams in Java are a sequence of elements that can be processed in parallel or sequentially.
Streams are used to perform operations on collections of data in a concise and functional way.
They can be used to filter, map, reduce, and sort data.
Streams can be processed in parallel to improve performance.
Examples of stream methods include filter(), map(), reduce(), and sorted().
Q6. Run time polymorphism vs compile time polymorphism
Run time polymorphism is method overriding while compile time polymorphism is method overloading.
Compile time polymorphism is resolved at compile time while run time polymorphism is resolved at runtime.
Method overloading is an example of compile time polymorphism while method overriding is an example of run time polymorphism.
Compile time polymorphism is faster than run time polymorphism as it is resolved at compile time.
Run time polymorphism is achieved through inheritance an...read more
Q7. Internal working of HashMap
HashMap is a data structure that stores key-value pairs and provides constant time complexity for basic operations.
HashMap uses hashing to store and retrieve elements
It allows null values and only one null key
Collisions are resolved using separate chaining or open addressing
The initial capacity and load factor can be specified during initialization
The size of the HashMap is dynamically increased as elements are added
More about working at Synechron
Top Java Software Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month