Bounteous x Accolite
SCM Garments Interview Questions and Answers
Q1. Given an array of non-negative integers.Find the length of the longest subsequence such that elements in the subsequence are contiguous integers. The consecutive numbers can be in any order. Example n=7 nums={2...
read moreFind the length of the longest subsequence of contiguous integers in an array.
Sort the array
Iterate through the array and check for consecutive integers
Keep track of the longest subsequence found
Q2. Get list of pincodes from these objects Employee{ id Long, name String, Addresses : List } Addresses{ houseNo long, pindcode long, state String, country String, } Ans. Use flatMap to flatten and then use map to...
read moreUse flatMap and map to extract list of pincodes from Employee objects
Use flatMap to flatten the list of Addresses in each Employee object
Use map to iterate over the flattened list and extract the pincodes
Example: employeeList.stream().flatMap(emp -> emp.getAddresses().stream()).map(address -> address.getPincode()).collect(Collectors.toList())
Q3. What is Database Pooling, Hikari and its configurations. Java 8 to current enchancements and current java version Factory and Builder design patterns to explain and code Project expalantion and details, Cross q...
read moreDatabase pooling is a technique used to manage a pool of database connections for efficient resource utilization. HikariCP is a popular database connection pooling library in Java.
HikariCP is a high-performance database connection pooling library for Java applications.
It is known for its low latency and high throughput.
Configurations for HikariCP include settings such as maximum pool size, connection timeout, and idle timeout.
Example: HikariConfig config = new HikariConfig();...read more
Q4. Design Patterns like Singleton and how to create them
Singleton is a creational design pattern that ensures a class has only one instance and provides a global point of access to it.
To create a Singleton, make the constructor private to prevent direct instantiation
Create a static method that returns the instance of the class
Use lazy initialization to create the instance only when it's needed
Ensure thread safety by using synchronized keyword or double-checked locking
Examples: java.lang.Runtime, java.awt.Desktop, java.util.Calenda...read more
Q5. Method overriding based code question -> guess the output
Method overriding in Java with code example
Output will be 'Child class method' as the method in Child class overrides the method in Parent class
Method overriding is a feature that allows a subclass to provide a specific implementation of a method that is already provided by its superclass
The method in the subclass should have the same name, return type, and parameters as the method in the superclass
Q6. fetch all the duplicate values from an array
To fetch all duplicate values from an array of strings
Iterate through the array and store each element in a HashSet
If an element is already in the HashSet, it is a duplicate value
Add the duplicate values to a separate list and return it
Q7. In given array find the sum a*a+b*b=c*c
Use a nested loop to iterate through the array and check for the sum of squares of two elements equal to the square of a third element.
Iterate through the array using a nested loop to compare all possible combinations of elements.
Calculate the sum of squares of two elements and check if it equals the square of a third element.
Return the elements if a match is found, otherwise continue iterating.
Q8. Write API to save data
API to save data in Java
Use HTTP POST method to send data to the server
Create a RESTful endpoint to handle the data saving
Validate the input data before saving it to the database
Q9. Hashmap iteration ways
There are multiple ways to iterate over a HashMap in Java.
Using keySet() and values() methods
Using entrySet() method
Using forEach() method with lambda expression
Interview Process at SCM Garments
Top Java Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month