Add office photos
Engaged Employer

Bounteous x AccoliteVerified

3.4
based on 838 Reviews
Video summary
Filter interviews by

100+ Hindustan Unilever Interview Questions and Answers

Updated 26 Apr 2025
Popular Designations

Q1. Topological Sort Problem Statement

You are given a directed acyclic graph (DAG). Your task is to perform topological sorting of the graph and return any valid ordering.

Explanation:

A directed acyclic graph is ...read more

Ans.

Implement a function to perform topological sorting on a directed acyclic graph (DAG) and return any valid ordering.

  • Create a graph representation using adjacency list or matrix

  • Perform depth-first search (DFS) to find the topological ordering

  • Use a stack to keep track of the ordering

  • Return the ordering as an array of integers

Add your answer

Q2. Can you make a constructor private in C++, and if not, what error will you get (Compile Time Error or Runtime Error)?

Ans.

Yes, a constructor can be made private in C++ to restrict object creation outside the class.

  • Private constructors are used in Singleton design pattern to ensure only one instance of the class is created.

  • If a constructor is made private, it can only be accessed by the member functions of the class.

  • Attempting to create an object of a class with a private constructor outside the class will result in a compile-time error.

Add your answer

Q3. What is the difference between a Binary Tree and a Binary Search Tree?

Ans.

Binary Tree is a tree data structure where each node has at most two children. Binary Search Tree is a binary tree with the property that the left subtree of a node contains only nodes with keys lesser than the node's key and the right subtree of a node contains only nodes with keys greater than the node's key.

  • Binary Tree can have any values in the nodes, while Binary Search Tree has a specific order of values.

  • Binary Search Tree allows for efficient searching, insertion, and ...read more

Add your answer

Q4. What are Dynamic-link libraries (DLLs) in C++ and what are their uses?

Ans.

DLL is a library of executable functions and data that can be used by a Windows application.

  • DLLs are loaded at runtime and can be shared by multiple applications.

  • They allow for modular programming and reduce memory usage.

  • DLLs can be used for device drivers, system utilities, and application extensions.

  • Examples of DLLs include kernel32.dll, user32.dll, and msvcr100.dll.

Add your answer
Discover Hindustan Unilever interview dos and don'ts from real experiences

Q5. What are function pointers and what are the differences between a normal function and function pointers?

Ans.

Function pointers are pointers that point to the memory address of a function. They can be passed as arguments or returned from a function.

  • Function pointers allow for dynamic function calls at runtime

  • Function pointers can be used to implement callbacks

  • Function pointers can be used to implement polymorphism

  • Normal functions are called directly, while function pointers are called indirectly

  • Function pointers can be assigned to NULL to indicate that they do not point to a valid fu...read more

Add your answer

Q6. Explain the diamond problem in C++, and how to solve it.

Ans.

Diamond problem occurs in multiple inheritance when two base classes have a common method. It is solved using virtual inheritance.

  • Diamond problem occurs when a derived class inherits from two base classes that have a common method.

  • Virtual inheritance is used to solve the diamond problem.

  • Virtual inheritance ensures that only one instance of the common base class is created.

Add your answer
Are these interview questions helpful?

Q7. What are the ways to prevent instantiation of a class?

Ans.

Ways to prevent instantiation of a class

  • Declare the class as abstract

  • Make the constructor private

  • Implement a static factory method

  • Throw an exception in the constructor

  • Use the Singleton pattern

Add your answer

Q8. Maximum Subarray Problem Statement

Ninja has been given an array, and he wants to find a subarray such that the sum of all elements in the subarray is maximum.

A subarray 'A' is considered greater than a subarr...read more

Ans.

The task is to find the subarray with the maximum sum in a given array.

  • Iterate through the array and keep track of the current sum and maximum sum seen so far.

  • If the current sum becomes negative, reset it to 0 as it won't contribute to the maximum sum.

  • Compare the maximum sum with the sum of the current subarray to update the result.

  • Handle cases where all elements are negative by returning the maximum element in the array.

  • Consider edge cases like empty array or array with only...read more

Add your answer
Share interview questions and help millions of jobseekers 🌟

Q9. Given a list of numbers, find all possible combinations of numbers that add up to a specific target value. There can be any number of elements that add up to the target.

Ans.

The task is to find any number of elements in an array that add up to a given target.

  • Use a recursive approach to find all possible combinations of elements that add up to the target.

  • Start with the first element and recursively call the function with the remaining elements and the reduced target.

  • If the target becomes zero, add the current combination to the result.

  • If the target becomes negative or there are no more elements, backtrack and try the next element.

  • Return all the co...read more

Add your answer

Q10. Given a linked list, rearrange it so that all negative numbers appear before all positive numbers.

Ans.

Separate negative and positive numbers in a linked list.

  • Create two separate linked lists for positive and negative numbers

  • Traverse the original linked list and add nodes to respective lists

  • Join the two lists to get the final linked list with separated numbers

Add your answer

Q11. How can you print the names of 4 threads in a specific order?

Ans.

Printing names of 4 threads in a given order using an array of strings.

  • Create an array of strings with the names of the threads in the desired order.

  • Use a loop to iterate through the array and print each thread name.

  • Ensure that the threads are started in the same order as the names in the array.

Add your answer

Q12. Given a singly linked list, delete the Kth node from the end of the list in a single iteration.

Ans.

Delete Kth node from end of linked list in single iteration

  • Use two pointers, one to traverse the list and another to keep track of Kth node from end

  • Move both pointers simultaneously until the first pointer reaches the end

  • Delete the Kth node from end using the second pointer

Add your answer

Q13. Given a set of positive integers, find if it can be divided into two subsets with equal sum. If possible, also print the two subsets.

Ans.

Equal Sum Partition problem with DP and matrix printing

  • The problem involves dividing an array into two subsets with equal sum

  • Dynamic programming can be used to solve this problem efficiently

  • A matrix can be used to keep track of the subsets

  • Printing the subsets can be done by backtracking through the matrix

Add your answer

Q14. Given an array containing only 0s and 1s, rearrange the array so that all 0s are grouped together followed by all 1s. This should be done in-place.

Ans.

Segregate 0's and 1's in array using Dutch National Flag Algorithm

  • Use three pointers - low, mid, and high

  • low points to the first index of 1

  • mid points to the first index of unknown element

  • high points to the last index of 1

  • If arr[mid] is 0, swap arr[low] and arr[mid], increment low and mid

  • If arr[mid] is 1, increment mid

  • If arr[mid] is 2, swap arr[mid] and arr[high], decrement high

Add your answer

Q15. 8. If not engineering then what?

Ans.

I would have pursued a career in music.

  • I have been playing the guitar for over 10 years.

  • I have performed at local gigs and events.

  • I enjoy writing and composing my own music.

Add your answer

Q16. How do you check for a loop in a linked list?

Ans.

To check for a loop in a linked list, we use the Floyd's cycle-finding algorithm.

  • Create two pointers, slow and fast, and initialize them to the head of the linked list.

  • Move slow pointer by one node and fast pointer by two nodes.

  • If there is a loop, the two pointers will eventually meet.

  • If there is no loop, the fast pointer will reach the end of the linked list.

  • Time complexity of this algorithm is O(n) and space complexity is O(1).

Add your answer

Q17. Given an array of integers, find the maximum product of any three numbers in the array.

Ans.

Find the maximum multiplication of 3 numbers in an array of strings.

  • Convert the array of strings to an array of integers.

  • Sort the array in descending order.

  • Check the product of first three elements and last two elements with the first element.

Add your answer

Q18. Write a function to detect if a given linked list is circular or not.

Ans.

To check if a linked list is circular, we can use Floyd's cycle-finding algorithm.

  • Create two pointers, slow and fast, and initialize them to the head of the linked list

  • Move slow pointer by one node and fast pointer by two nodes

  • If the linked list is circular, the fast pointer will eventually catch up to the slow pointer

  • If the linked list is not circular, the fast pointer will reach the end of the list

  • Time complexity: O(n), Space complexity: O(1)

Add your answer

Q19. Write code to remove duplicates from an unsorted linked list. Follow up: How would you solve this problem if a temporary buffer is not allowed?

Ans.

Remove duplicates from Linked List. Both variants.

  • Variant 1: Using Hash Set to keep track of visited nodes and removing duplicates

  • Variant 2: Using two pointers to compare each node with all subsequent nodes and removing duplicates

  • Example: 1->2->3->2->4->3, Output: 1->2->3->4

Add your answer

Q20. How do you calculate the depth of a tree?

Ans.

Calculating the depth of a tree

  • Depth of a tree is the maximum distance from the root node to any leaf node

  • Can be calculated recursively by finding the maximum depth of left and right subtrees

  • Base case is when the node is null, return 0

Add your answer

Q21. What are registers in C++?

Ans.

Registers are small, fast memory locations in a CPU that store data for quick access.

  • Registers are used to store data that is frequently accessed by the CPU.

  • They are faster than accessing data from RAM.

  • Registers are limited in number and size.

  • Examples of registers include the program counter, stack pointer, and general-purpose registers.

  • Register usage can be optimized for performance in code.

  • Accessing registers can be done using assembly language.

  • In C++, registers can be decl...read more

Add your answer

Q22. Rotting Oranges Problem Statement

You are given a grid containing oranges where each cell of the grid can contain one of the three integer values:

  • 0 - representing an empty cell
  • 1 - representing a fresh orange...read more
Ans.

Find the minimum time required to rot all fresh oranges in a grid.

  • Use Breadth First Search (BFS) to simulate the rotting process

  • Track the time taken to rot all oranges and return -1 if any fresh oranges remain

  • Handle edge cases like no fresh oranges or all oranges already rotten

  • Consider using a queue to efficiently process adjacent oranges

Add your answer

Q23. Intersection of Linked List Problem

You are provided with two singly linked lists containing integers, where both lists converge at some node belonging to a third linked list.

Your task is to determine the data...read more

Ans.

Find the node where two linked lists merge, return -1 if no merging occurs.

  • Traverse both lists to find their lengths and the difference in lengths

  • Move the pointer of the longer list by the difference in lengths

  • Traverse both lists simultaneously until they meet at the merging point

Add your answer

Q24. Given the head of a linked list, reverse the nodes of the list k at a time, and return the modified list. k is a positive integer and is less than or equal to the length of the linked list. If the number of nod...

read more
Ans.

Reverse a linked list in groups of k

  • Create a function to reverse a linked list

  • Iterate through the linked list in groups of k

  • Reverse each group using the function

  • Connect the reversed groups back together

  • Return the new head of the linked list

Add your answer

Q25. What is Runtime polymorphism?

Ans.

Runtime polymorphism is the ability of an object to take on multiple forms during runtime.

  • It is achieved through method overriding

  • It allows for more flexibility and extensibility in code

  • It is a key feature of object-oriented programming

  • Example: Animal class with different subclasses such as Dog, Cat, and Bird

Add your answer

Q26. Reverse Linked List Problem Statement

Given a Singly Linked List of integers, your task is to reverse the Linked List by altering the links between the nodes.

Input:

The first line of input is an integer T, rep...read more
Ans.

Reverse a singly linked list by altering the links between nodes.

  • Iterate through the linked list and reverse the links between nodes

  • Use three pointers to keep track of the current, previous, and next nodes

  • Update the links between nodes to reverse the list

  • Return the head of the reversed linked list

Add your answer

Q27. Merge K Sorted Arrays Problem Statement

You are provided with 'K' different arrays/lists, each sorted in ascending order. Your task is to merge all these arrays/lists into one sorted array/list in ascending ord...read more

Ans.

Merge K sorted arrays into one sorted array in ascending order.

  • Iterate through all arrays/lists and merge them into one sorted array using a priority queue or merge sort algorithm.

  • Ensure to handle edge cases like empty arrays/lists or arrays/lists with different sizes.

  • Time complexity can be optimized by using a min-heap or priority queue to efficiently merge the arrays/lists.

Add your answer

Q28. Given a string, find the number of occurrences of each character.

Ans.

Count the number of occurrences of each character in a given string.

  • Create a dictionary to store the count of each character.

  • Iterate through the string and update the count in the dictionary.

  • Return the dictionary with character count.

View 1 answer

Q29. Left View of a Binary Tree Problem Statement

Given a binary tree, your task is to print the left view of the tree.

Example:

Input:
The input will be in level order form, with node values separated by a space. U...read more
Ans.

Print the left view of a binary tree given in level order form.

  • Traverse the tree level by level and print the first node of each level (leftmost node).

  • Use a queue to perform level order traversal.

  • Keep track of the current level and print the first node encountered at each level.

Add your answer

Q30. Maximum Path Sum Between Two Leaves Problem Description

You are provided with a non-empty binary tree in which each node contains a non-negative integer value. Your task is to find and return the maximum possib...read more

Ans.

Find the maximum path sum between two leaf nodes in a binary tree.

  • Traverse the tree to find the maximum path sum between two leaf nodes.

  • Keep track of the maximum sum found so far.

  • Consider all possible paths between leaf nodes.

  • Handle cases where the tree has only a single leaf node.

  • Implement a recursive function to calculate the maximum path sum.

Add your answer

Q31. Minimum Time To Solve The Problems

Given 'N' subjects, each containing a certain number of problems, and 'K' friends, assign subjects to friends such that each subject goes to exactly one friend, maintaining co...read more

Ans.

Assign subjects to friends to minimize maximum workload, find minimum time for most loaded friend.

  • Sort subjects in descending order

  • Assign subjects to friends one by one until all subjects are assigned

  • The maximum workload will be the sum of problems assigned to the friend with the most problems

  • Return the maximum workload as the minimum time required

Add your answer

Q32. Majority Element Problem Statement

Given an array/list 'ARR' consisting of 'N' integers, your task is to find the majority element in the array. If there is no majority element present, return -1.

Example:

Inpu...read more
Ans.

Find the majority element in an array, return -1 if no majority element exists.

  • Iterate through the array and keep track of the count of each element using a hashmap.

  • Check if any element's count is greater than floor(N/2) to determine the majority element.

  • Return the majority element or -1 if no majority element exists.

Add your answer

Q33. Reverse Words in a String: Problem Statement

You are given a string of length N. Your task is to reverse the string word by word. The input may contain multiple spaces between words and may have leading or trai...read more

Ans.

Reverse words in a string while handling leading/trailing spaces and multiple spaces between words.

  • Split the input string by spaces to get individual words

  • Reverse the list of words

  • Join the reversed words with a single space in between

  • Handle leading/trailing spaces by stripping them before and after reversing

Add your answer

Q34. N-th Node From The End Problem Statement

You are given a Singly Linked List of integers. The task is to find the N-th node from the end of the list.

Example:

Input:
If the given list is (1 -> -2 -> 0 -> 4) and ...read more
Ans.

Find the N-th node from the end of a Singly Linked List of integers.

  • Traverse the list to find the length L of the list.

  • Calculate the position of the N-th node from the beginning as L - N + 1.

  • Traverse the list again to reach the calculated position and return the node's value.

Add your answer

Q35. LCA of Binary Tree Problem Statement

You are given a binary tree consisting of distinct integers and two nodes, X and Y. Your task is to find and return the Lowest Common Ancestor (LCA) of these two nodes.

The ...read more

Ans.

Find the Lowest Common Ancestor (LCA) of two nodes in a binary tree.

  • Traverse the binary tree to find the paths from the root to nodes X and Y.

  • Compare the paths to find the last common node, which is the LCA.

  • Handle cases where one node is an ancestor of the other or when one node is the LCA itself.

Add your answer

Q36. Sum Root to Leaf Numbers

You are given an arbitrary binary tree consisting of N nodes, each associated with an integer value from 1 to 9. Each root-to-leaf path can be considered a number formed by concatenatin...read more

Ans.

Find the total sum of all root to leaf paths in a binary tree formed by concatenating node values.

  • Traverse the binary tree from root to leaf nodes, keeping track of the current path sum

  • Add the current path sum to the total sum when reaching a leaf node

  • Use modulo (10^9 + 7) to handle large outputs

Add your answer

Q37. Ninja and the Maze Problem Statement

Ninja is stuck in a maze represented as a 2D grid. He can move in four directions (Up, Down, Left, Right) until he hits a wall ('1'). Once stopped, he can choose a new direc...read more

Ans.

The problem involves determining if a ninja can reach the destination in a maze by moving in four directions until hitting a wall.

  • Create a function that takes in the maze, starting point, and destination coordinates as input.

  • Implement a recursive algorithm to explore all possible paths in the maze.

  • Check if the destination can be reached from the starting point by moving in four directions.

  • Return 'True' if a path exists, otherwise return 'False'.

View 1 answer

Q38. You are given the heads of two sorted linked lists list1 and list2. Merge the two lists into one sorted list. The list should be made by splicing together the nodes of the first two lists. Return the head of th...

read more
Ans.

Merge two sorted linked lists

  • Create a new linked list

  • Compare the first nodes of both lists and add the smaller one to the new list

  • Move the pointer of the added node to the next node in the list

  • Repeat until one of the lists is empty

  • Add the remaining nodes of the non-empty list to the new list

Add your answer

Q39. Given a string, find all palindromic substrings.

Ans.

Program to find all palindromic strings in a given string.

  • Iterate through the string and check for palindromic substrings using two pointers.

  • Add the palindromic substrings to an array of strings.

  • Return the array of palindromic strings.

Add your answer

Q40. Left Rotations of an Array

Given an array of size N and Q queries, each query requires left rotating the original array by a specified number of elements. Return the modified array for each query.

Input:

The fi...read more
Ans.

Rotate an array left by a specified number of elements for each query.

  • Iterate through each query and rotate the array left by the specified number of elements using array slicing.

  • Handle cases where the number of rotations exceeds the length of the array by taking the modulo of the rotations.

  • Return the modified array after each query.

Add your answer

Q41. Trapping Rain Water Problem Statement

You are given a long type array/list ARR of size N, representing an elevation map. The value ARR[i] denotes the elevation of the ith bar. Your task is to determine the tota...read more

Ans.

Calculate the total amount of rainwater that can be trapped between given elevations in an array.

  • Iterate through the array and calculate the maximum height on the left and right of each bar.

  • Calculate the amount of water that can be trapped at each bar by taking the minimum of the maximum heights on the left and right.

  • Sum up the trapped water at each bar to get the total trapped water for the entire array.

Add your answer

Q42. Distinct Occurrences Problem Statement

You are given two strings 'A' and 'B' of lengths 'N' and 'M' respectively. Your task is to determine how many distinct ways string 'B' occurs as a subsequence in string 'A...read more

Ans.

Count the number of distinct occurrences of one string as a subsequence in another string.

  • Iterate through string A and string B to find all occurrences of B as a subsequence in A.

  • Use dynamic programming to keep track of the number of distinct occurrences.

  • Handle edge cases such as empty strings or strings of different lengths.

  • Example: For strings A='aabbcc' and B='abc', there are 3 distinct occurrences of B in A.

Add your answer

Q43. Write a function to traverse a binary tree and find the minimum value.

Ans.

Use tree traversal to find the minimum number in a tree structure.

  • Start at the root node and compare it with its children to find the minimum value.

  • Use depth-first search or breadth-first search to traverse the tree.

  • Keep track of the minimum value found so far as you traverse the tree.

  • Consider implementing a recursive function to traverse the tree efficiently.

Add your answer

Q44. Median of Two Sorted Arrays

Given two sorted arrays A and B of sizes N and M, find the median of the merged array formed by combining arrays A and B. If the total number of elements, N + M, is even, the median ...read more

Ans.

Find the median of two sorted arrays by merging them and calculating the median of the combined array.

  • Merge the two sorted arrays into one sorted array.

  • Calculate the median of the merged array based on the total number of elements.

  • If the total number of elements is even, take the mean of the two middle elements as the median.

Add your answer

Q45. Distance Between Two Nodes in a Binary Tree

Given a binary tree and the values of two distinct nodes, determine the distance between these two nodes in the tree. The distance is defined as the minimum number of...read more

Ans.

Calculate the distance between two nodes in a binary tree.

  • Traverse the tree to find the paths from the root to each node

  • Find the lowest common ancestor of the two nodes

  • Calculate the distance by summing the distances from each node to the common ancestor

Add your answer

Q46. Implement Merge Sort.

Ans.

Merge Sort is a divide-and-conquer algorithm that recursively divides an array into two halves, sorts them, and then merges them.

  • Divide the array into two halves

  • Recursively sort each half

  • Merge the sorted halves

View 1 answer

Q47. Sort 0 1 2 Problem Statement

Given an integer array arr of size 'N' containing only 0s, 1s, and 2s, write an algorithm to sort the array.

Input:

The first line contains an integer 'T' representing the number of...read more
Ans.

Sort an array of 0s, 1s, and 2s in linear time complexity.

  • Use three pointers to keep track of 0s, 1s, and 2s while iterating through the array.

  • Swap elements based on the values encountered to sort the array in-place.

  • Time complexity should be O(N) and space complexity should be O(1).

Add your answer

Q48. Write an SQL query to find the second highest salary from an employee table.

Ans.

SQL query to find the 2nd highest salary in a table.

  • Use ORDER BY and LIMIT to sort and select the 2nd highest salary.

  • Use subquery to avoid duplicates if necessary.

Add your answer

Q49. 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. For example, if n=...

read more
Ans.

Find 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

Add your answer

Q50. Given a list of Employee objects, where each Employee has a list of Address objects, how would you extract a list of all pincodes using Java?

Ans.

Use 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())

Add your answer

Q51. Code a system to query an API, perform multiprocessing, and improve efficiency.

Ans.

Code a system to query an API, do multiprocessing and improve efficiency

  • Use a library like requests in Python to query the API

  • Implement multiprocessing using a library like multiprocessing or threading in Python

  • Optimize efficiency by caching API responses or using asynchronous programming

Add your answer

Q52. 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 more
Ans.

Database 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

Add your answer
Q53. What is grammar in the context of compiler design?
Ans.

Grammar in compiler design defines the syntax and structure of a programming language.

  • Grammar specifies the rules for forming valid statements in a programming language.

  • It consists of a set of production rules that define how valid programs can be constructed.

  • There are different types of grammars such as context-free grammar, regular grammar, etc.

  • Example: In C programming language, the grammar specifies that a for loop should have a specific syntax like 'for(initialization; c...read more

Add your answer

Q54. Write code to split an array of integers into two subarrays where both arrays have an equal sum.

Ans.

Code to split an array of integers into two subarrays with equal sum.

  • Iterate through the array and calculate the total sum.

  • Divide the sum by 2 to get the target sum for each subarray.

  • Use dynamic programming to find a subset of the array that adds up to the target sum.

  • Return the two subarrays.

  • Example: [1, 2, 3, 4, 5, 6] -> [1, 2, 3, 6], [4, 5]

  • Example: [1, 2, 3, 4, 5] -> [1, 4, 5], [2, 3]

Add your answer

Q55. What are the conditions for a deadlock?

Ans.

Conditions for a deadlock in software engineering

  • Deadlock occurs when each process in a set is waiting for an event that only another process in the set can cause

  • Four conditions for a deadlock: mutual exclusion, hold and wait, no preemption, circular wait

  • Example: Process A holds resource X and waits for resource Y, while Process B holds resource Y and waits for resource X

Add your answer

Q56. Implement a Binary Search Tree (BST) from scratch, including tree traversal algorithms and other common BST operations.

Ans.

Implementing a binary search tree and its traversal methods.

  • Start by defining a Node class with left and right child pointers.

  • Implement insert() method to add nodes to the tree.

  • Implement inorder(), preorder(), and postorder() traversal methods.

  • Implement search() method to find a node in the tree.

  • Implement delete() method to remove a node from the tree.

  • Consider edge cases like empty tree, duplicate nodes, etc.

Add your answer

Q57. What are your thoughts on OOP concepts?

Ans.

OOPs concepts are the fundamental principles of object-oriented programming.

  • Abstraction

  • Encapsulation

  • Inheritance

  • Polymorphism

Add your answer
Q58. What are NP and NP-Hard problems?
Ans.

NP problems are decision problems that can be verified in polynomial time, while NP-Hard problems are at least as hard as the hardest problems in NP.

  • NP problems can be verified in polynomial time but not necessarily solved in polynomial time.

  • NP-Hard problems are at least as hard as the hardest problems in NP, but may not be in NP themselves.

  • Examples of NP problems include the subset sum problem and the traveling salesman problem.

  • Examples of NP-Hard problems include the travel...read more

Add your answer

Q59. What is the process for writing a Bash script to read and parse a CSV file and print the last character of each line?

Ans.

The process for writing a Bash script to read and parse a CSV file and print the last character of each line involves using a combination of commands and loops.

  • Use the 'while read' loop to read each line of the CSV file

  • Use 'awk' command to extract the last character of each line

  • Print the last character using 'echo' command

Add your answer

Q60. What is the SQL query to perform a join on two tables and calculate the aggregate sum using the product ID?

Ans.

SQL query to perform a join on two tables and calculate aggregate sum using product ID.

  • Use JOIN keyword to combine two tables based on a related column (e.g. product ID)

  • Use GROUP BY clause to group the results by product ID

  • Use SUM() function to calculate the aggregate sum of a column (e.g. price)

Add your answer

Q61. What is the SQL query to join two tables and use aggregate functions such as SUM and AVG with GROUP BY?

Ans.

SQL query to join two tables, use aggregate functions like SUM and AVG with GROUP BY

  • Use JOIN keyword to combine two tables based on a common column

  • Use GROUP BY clause to group the results based on a specific column

  • Use aggregate functions like SUM() and AVG() to calculate totals and averages within each group

Add your answer
Q62. What is a token in compiler design?
Ans.

A token in compiler design is a basic unit of syntax that the compiler can understand and process.

  • Tokens are the smallest units of a program that are meaningful to the compiler.

  • Examples of tokens include keywords, identifiers, operators, and punctuation symbols.

  • Tokens are generated by the lexical analysis phase of the compiler.

  • Tokens are used by the parser to build the abstract syntax tree of the program.

Add your answer
Q63. What are the sub-parts or phases of the analysis part in compiler design?
Ans.

The sub-parts or phases of the analysis part in compiler design include lexical analysis, syntax analysis, and semantic analysis.

  • Lexical analysis involves breaking the input into tokens such as keywords, identifiers, and operators.

  • Syntax analysis checks the structure of the tokens to ensure they conform to the grammar rules of the language.

  • Semantic analysis verifies the meaning of the program by checking for type compatibility and other semantic rules.

  • Examples include lexing ...read more

Add your answer
Q64. How many levels of normalization are there in database management systems?
Ans.

There are 3 levels of normalization in database management systems.

  • First Normal Form (1NF) - Eliminate duplicate data and ensure data is stored in a tabular format.

  • Second Normal Form (2NF) - Meet 1NF requirements and ensure all non-key attributes are fully functional dependent on the primary key.

  • Third Normal Form (3NF) - Meet 2NF requirements and ensure that there are no transitive dependencies between non-key attributes.

Add your answer
Q65. What is the difference between Functional Components and Class Components in React?
Ans.

Functional Components are simple functions that take props as input and return JSX, while Class Components are ES6 classes that extend React.Component and have additional features like state and lifecycle methods.

  • Functional Components are simpler and easier to read/write compared to Class Components.

  • Functional Components do not have access to state or lifecycle methods, while Class Components do.

  • Functional Components are stateless, while Class Components can be stateful.

  • Funct...read more

Add your answer

Q66. Given a string, find the unique characters in a window of size k.

Ans.

Find unique characters in a window of k size in a string.

  • Use a sliding window approach.

  • Maintain a hash table to keep track of character frequency.

  • Remove characters from hash table as the window slides.

Add your answer

Q67. Given an array of integers, find the maximum value in each contiguous subarray of size k.

Ans.

Find maximum for each contiguous subarray of size k from an array of size n.

  • Iterate through the array and keep track of maximum for each subarray of size k

  • Use a sliding window approach to efficiently calculate maximum for each subarray

  • Time complexity: O(n)

  • Example: arr = [10, 5, 2, 7, 1, 9, 4], k = 3, output = [10, 7, 7, 9, 9]

Add your answer

Q68. Explain the Singleton design pattern and how to implement it.

Ans.

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

Add your answer

Q69. What version control tools do you use, and can you explain how you utilize them?

Ans.

I primarily use Git for version control, utilizing branches, commits, and merges for collaboration and tracking changes.

  • Primary version control tool is Git

  • Utilize branches for different features or fixes

  • Regularly commit changes with descriptive messages

  • Merge branches to integrate changes

  • Use tools like GitHub or Bitbucket for collaboration

Add your answer

Q70. What is the Bash command to suppress all output and errors?

Ans.

The Bash command to suppress all output and errors is 'command > /dev/null 2>&1'

  • Use '>' to redirect standard output to /dev/null

  • Use '2>&1' to redirect standard error to standard output

  • Combine both to suppress all output and errors: 'command > /dev/null 2>&1'

Add your answer

Q71. If you are given a number, return its corresponding Excel column number.

Ans.

Convert given no to corresponding excel no.

  • Excel no starts from 1 and goes up to 16384

  • Excel no is calculated using column and row numbers

  • For example, 1 corresponds to A, 27 corresponds to AA, 28 corresponds to AB, and so on

Add your answer
Q72. What is segmentation in the context of operating systems?
Ans.

Segmentation in operating systems is a memory management technique where memory is divided into segments of variable sizes.

  • Segments are logical units of a program such as code, data, stack, etc.

  • Each segment has its own base address and length.

  • Segmentation allows for more efficient memory management and protection.

  • Examples include Intel x86 architecture with segment registers like CS, DS, SS, etc.

Add your answer

Q73. What is the Singleton design pattern?

Ans.

Singleton design pattern restricts the instantiation of a class to one object.

  • Ensures only one instance of a class exists

  • Provides a global point of access to that instance

  • Used when only one instance of a class is needed throughout the application

  • Example: Database connection manager

Add your answer
Q74. What is a regular language?
Ans.

A regular language is a language that can be recognized by a finite automaton.

  • Regular languages can be described by regular expressions.

  • Regular languages are closed under union, concatenation, and Kleene star operations.

  • Examples of regular languages include the set of all strings over an alphabet that contain an even number of 'a's.

View 1 answer

Q75. How do you troubleshoot an internet issue?

Ans.

To troubleshoot an internet issue, check the connection, restart the router, check for software issues, and contact the service provider if needed.

  • Check the physical connection of the router and modem

  • Restart the router and modem

  • Check for any software issues on the device (e.g. network settings, firewall)

  • Contact the internet service provider for further assistance

Add your answer

Q76. Write a program to find repeating characters in a string.

Ans.

The program finds repeating characters in a given string.

  • Iterate through each character in the string

  • Store each character in a data structure

  • If a character is already present in the data structure, it is a repeating character

View 1 answer

Q77. Given an array containing only 0s and 1s, how would you segregate the 0s and 1s with the minimum number of swaps?

Ans.

Segregate an array of 0s and 1s with minimum swaps.

  • Count the number of 0s in the array.

  • Swap the 1s with the 0s until all 0s are on one side and 1s on the other.

  • The minimum number of swaps required is half the number of 1s on the side with fewer 1s.

Add your answer

Q78. Memory Management in Python

Ans.

Memory management in Python involves automatic memory allocation and deallocation through garbage collection.

  • Python uses automatic memory management through garbage collection to allocate and deallocate memory.

  • Memory is managed using reference counting and a cycle-detecting garbage collector.

  • Python's memory management is efficient for most use cases, but can lead to memory leaks if circular references are not handled properly.

Add your answer

Q79. How do you handle an irate customer?

Ans.

I remain calm, listen actively, empathize with their situation, apologize for any inconvenience, and work towards finding a solution.

  • Remain calm and composed

  • Listen actively to understand their concerns

  • Empathize with their situation

  • Apologize for any inconvenience caused

  • Work towards finding a solution to address their issue

Add your answer

Q80. Explain the automation framework that you would suggest to automate the Amazon application.

Ans.

I suggest using a hybrid automation framework for testing Amazon application.

  • Use Selenium WebDriver for web automation

  • Use Appium for mobile automation

  • Use TestNG for test management and reporting

  • Use Page Object Model for better code maintenance

  • Use data-driven approach for test data management

  • Use Jenkins for continuous integration and deployment

Add your answer

Q81. What is the concept of lock isolation in Spring Framework?

Ans.

Lock isolation in Spring Framework ensures that each transaction operates independently without interfering with other transactions.

  • Lock isolation prevents concurrent transactions from affecting each other's data.

  • Different levels of lock isolation can be set in Spring, such as READ_COMMITTED and REPEATABLE_READ.

  • For example, setting a higher level of lock isolation like REPEATABLE_READ ensures that a transaction will not see changes made by other transactions until it is compl...read more

Add your answer

Q82. How did you implement multithreading in your project?

Ans.

Implemented multithreading using Java's Thread class and Executor framework.

  • Used Thread class to create and manage threads.

  • Utilized Executor framework for managing thread pools and executing tasks.

  • Implemented synchronization mechanisms like locks and semaphores to prevent race conditions.

  • Used Java's concurrent data structures like ConcurrentHashMap and BlockingQueue for thread-safe operations.

Add your answer

Q83. How do you implement security measures for your microservices?

Ans.

Implementing security measures for microservices involves using authentication, authorization, encryption, and monitoring.

  • Implement authentication mechanisms such as OAuth, JWT, or API keys to verify the identity of clients accessing the microservices.

  • Enforce authorization rules to control access to different parts of the microservices based on roles and permissions.

  • Use encryption techniques like TLS/SSL to secure communication between microservices and external clients.

  • Imple...read more

Add your answer

Q84. In which scenario Div and span will be used? Difference between == and === in javascript

Ans.

Div is a block-level element for layout, while span is an inline element for styling text.

  • Div is used for grouping larger sections of content, e.g., <div class='container'>...</div>

  • Span is used for styling small portions of text, e.g., <span class='highlight'>text</span>

  • Div elements take up the full width available, while span elements only take up as much width as their content.

  • Div can contain other block elements, while span is typically used within block elements.

Add your answer
Q85. What are props in React?
Ans.

Props are short for properties and are used to pass data from parent to child components in React.

  • Props are read-only and cannot be modified by the child component.

  • Props are passed down from parent to child components using attributes.

  • Props can be any type of data, including strings, numbers, arrays, objects, or functions.

  • Example: <ChildComponent name='John' age={25} />

Add your answer

Q86. What is your approach to building basic logic skills?

Ans.

My approach to building basic logic skills involves practicing problem-solving exercises, breaking down complex problems into smaller parts, and seeking feedback to improve.

  • Practice problem-solving exercises regularly to strengthen logical thinking abilities.

  • Break down complex problems into smaller, more manageable parts to better understand the problem and find solutions.

  • Seek feedback from peers or mentors to identify areas for improvement and refine logic skills.

  • Utilize res...read more

Add your answer

Q87. What are the advantages of Angular?

Ans.

Angular is a popular front-end framework for building web applications.

  • Angular is developed and maintained by Google.

  • It uses TypeScript for building scalable and maintainable applications.

  • Angular has a powerful CLI for generating components, services, and more.

  • It has a large and active community with many third-party libraries and plugins available.

  • Angular has a modular architecture that allows for easy code reuse and testing.

Add your answer

Q88. Write a program to find the frequency of a given character in a sorted string.

Ans.

Use binary search to find the first and last occurrence of the character, then calculate the frequency.

  • Use binary search to find the first occurrence of the character in the string.

  • Use binary search to find the last occurrence of the character in the string.

  • Calculate the frequency by subtracting the indices of the last and first occurrences and adding 1.

Add your answer

Q89. Sync Api vs Async Api, Sync Microservice and Async microservice example

Ans.

Sync API waits for a response before continuing, while Async API allows the program to continue executing without waiting for a response.

  • Sync API is blocking and waits for a response before proceeding

  • Async API is non-blocking and allows the program to continue executing while waiting for a response

  • Sync microservice handles requests sequentially, while Async microservice can handle multiple requests concurrently

  • Example of Sync API: REST API that waits for a response before ret...read more

Add your answer

Q90. 1. diff between throw ,throws 2. jit compiler 3. diff between compiler and compellers 4. acid properties 5. normalization

Ans.

Answers to various technical questions related to programming and database concepts.

  • throw is used to throw an exception in Java, while throws is used in method signature to declare the exceptions that can be thrown by the method

  • JIT compiler stands for Just-In-Time compiler, which compiles Java bytecode into native machine code at runtime for improved performance

  • Compiler is a software program that translates high-level programming languages into machine code, while compellers ...read more

Add your answer

Q91. How can HashMap collisions be reduced?

Ans.

Implement strategies to minimize collisions in HashMap for better performance and efficiency.

  • Use a better hash function: A well-distributed hash function reduces clustering. Example: Use prime numbers in calculations.

  • Increase the initial capacity: Start with a larger size to minimize resizing and collisions. Example: Set initial capacity to 16 instead of 8.

  • Utilize linked lists or trees: In case of collisions, store entries in a linked list or tree structure. Example: Java use...read more

Add your answer
Q92. How does Redux work?
Ans.

Redux is a predictable state container for JavaScript apps.

  • Redux stores the entire state of an application in a single immutable object.

  • State changes are made by dispatching actions, which are plain JavaScript objects.

  • Reducers specify how the state changes in response to actions.

  • Components can subscribe to the Redux store to access the state and re-render when it changes.

Add your answer

Q93. How do you handle distributed transactions in microservices using the Saga pattern?

Ans.

Saga pattern is used to manage distributed transactions in microservices by breaking them into smaller, independent transactions.

  • Saga pattern involves breaking down a long transaction into a series of smaller, independent transactions.

  • Each step in the saga is a separate transaction that can be rolled back if needed.

  • Compensating transactions are used to undo the effects of a previously completed step in case of failure.

  • Sagas can be implemented using choreography or orchestrati...read more

Add your answer

Q94. Given a string, find all possible permutations of the string.

Ans.

Permutations of a string

  • Use recursion to swap characters and generate permutations

  • Iterate through the string and swap each character with the first character

  • Repeat the above step for each character in the string

Add your answer

Q95. Write a program to determine if a number is prime.

Ans.

Program to check if a number is prime or not

  • A prime number is only divisible by 1 and itself

  • Loop through numbers from 2 to n-1 and check if n is divisible by any of them

  • If n is divisible by any number, it is not prime

  • If n is not divisible by any number, it is prime

Add your answer
Q96. What is Redux?
Ans.

Redux is a predictable state container for JavaScript apps.

  • Redux is a state management library for JavaScript applications.

  • It helps in managing the state of an application in a predictable way.

  • Redux stores the entire state of the application in a single immutable object.

  • Actions are dispatched to update the state, and reducers specify how the state changes in response to actions.

  • Redux is commonly used with React to manage the state of complex applications.

Add your answer

Q97. Threading in Java

Ans.

Threading in Java allows concurrent execution of code, improving performance and responsiveness in applications.

  • Java provides the Thread class and Runnable interface for creating threads.

  • Example: Implementing Runnable interface: 'public class MyRunnable implements Runnable { public void run() { ... } }'

  • Threads can be started using 'new Thread(new MyRunnable()).start();'

  • Synchronization is crucial to avoid thread interference; use 'synchronized' keyword.

  • Example of synchronizati...read more

Add your answer

Q98. What are your weaknesses?

Ans.

One of my weaknesses is procrastination.

  • I tend to put off tasks until the last minute.

  • To overcome this, I have started using time management techniques such as the Pomodoro technique.

  • I also try to break down tasks into smaller, more manageable chunks.

  • I have found that setting deadlines for myself and holding myself accountable helps me stay on track.

Add your answer

Q99. Given an array, find three elements a, b, and c such that a*a + b*b = c*c.

Ans.

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.

Add your answer

Q100. What is hashing, and does it use keys?

Ans.

Hashing is a process of converting data into a fixed-size output. It has a key that is used to access the data.

  • Hashing is used to store and retrieve data quickly.

  • It uses a hash function to generate a unique key for each input data.

  • The key is used to access the data in constant time.

  • Hashing is used in password storage, data indexing, and cryptography.

  • Examples of hash functions include MD5, SHA-1, and SHA-256.

Add your answer
1
2
Contribute & help others!
Write a review
Share interview
Contribute salary
Add office photos

Interview Process at Hindustan Unilever

based on 174 interviews
Interview experience
3.6
Good
View more
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Interview Questions from Similar Companies

3.9
 • 135 Interview Questions
3.6
 • 121 Interview Questions
3.9
 • 118 Interview Questions
4.2
 • 117 Interview Questions
3.7
 • 112 Interview Questions
4.2
 • 100 Interview Questions
View all
Top Bounteous x Accolite Interview Questions And Answers
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
75 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter