Synechron
Taxspanner Interview Questions and Answers
Q1. find sum of all odd numbers in a list using stream?
Using Java stream, find the sum of all odd numbers in a list.
Use the filter() method to filter out the odd numbers from the list.
Use the mapToInt() method to convert the filtered numbers to integers.
Use the sum() method to calculate the sum of the filtered odd numbers.
Q2. how to remove duplicated form from array list?
To remove duplicates from an ArrayList of strings, use a HashSet to store unique elements.
Create a HashSet and add all elements from the ArrayList to it.
Create a new ArrayList and add all elements from the HashSet to it.
The new ArrayList will contain only unique elements.
Q3. how hashset and hashmap work internally?
HashSet and HashMap are both data structures in Java that use hashing to store and retrieve elements.
HashSet uses HashMap internally to store its elements as keys with a dummy value.
HashMap uses an array of linked lists called buckets to store key-value pairs.
Both HashSet and HashMap use the hashCode() method to calculate the hash value of keys.
HashSet uses the hash value to determine the bucket where an element should be stored.
HashMap uses the hash value to determine the bu...read more
Q4. What is checked unchecked exceptions?
Checked exceptions are exceptions that must be declared in a method's signature or handled using try-catch blocks.
Checked exceptions are checked at compile-time.
They are typically used for exceptional conditions that can be reasonably recovered from.
Examples of checked exceptions in Java include IOException, SQLException, and ClassNotFoundException.
Q5. How many types of lock are there in java and how to achieve multithreading.
There are two types of locks in Java - synchronized and ReentrantLock. Multithreading can be achieved by using these locks.
Two types of locks in Java are synchronized and ReentrantLock
Synchronized keyword can be used to achieve synchronization in Java
ReentrantLock provides more flexibility and control over locking mechanisms
Example: synchronized block - synchronized(obj) { // code }
Example: ReentrantLock - ReentrantLock lock = new ReentrantLock(); lock.lock(); // code; lock.u...read more
Q6. Write code for producer , consumer in java.
Producer-consumer problem is a classic synchronization problem in multithreading.
Use wait() and notify() methods for synchronization
Create a shared buffer to store data between producer and consumer
Ensure proper handling of synchronization to avoid race conditions
Q7. what is mean by singlton
Singleton is a design pattern in Java where a class is restricted to have only one instance.
Singleton pattern ensures that a class has only one instance and provides a global point of access to it.
It is commonly used in scenarios where a single instance of a class is required to control actions throughout a system.
Example: Database connection classes, Logger classes, Configuration classes.
Q8. Class vs object
A class is a blueprint or template for creating objects, while an object is an instance of a class.
A class defines the properties and behaviors of objects, while an object is a specific instance of a class.
Classes can be used to create multiple objects with similar characteristics.
Objects have state (attributes) and behavior (methods) defined by the class.
Example: Class 'Car' defines properties like 'color' and 'model', while an object 'myCar' can have specific values for the...read more
More about working at Synechron
Interview Process at Taxspanner
Top Java Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month