Bounteous x Accolite
100+ Ajanta Pharma Interview Questions and Answers
Q1. Loot Houses Problem Statement
A thief is planning to steal from several houses along a street. Each house has a certain amount of money stashed. However, the thief cannot loot two adjacent houses. Determine the...read more
Q2. 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
Q3. Total time: 110 mins 1. Find missing and duplicate numbers from given array(algo, code, optimization, dry run, complexity analysis) 2. Flatten Binary tree to Linked List Conversion (algo, code, optimization, dr...
read moreInterview questions for Software Engineer position
Array manipulation and linked list operations
Tree data structure and balancing techniques
Database concepts and differences between SQL and NoSQL
Web development frameworks and protocols
Concepts of Deadlock and Race Condition
Use of pointers in function oriented programming and their absence in Java
Q4. Can you make a constructor private in Cpp, if not what error will you get (Compile Time Error or Runtime Error)
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.
Q5. 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
Q6. What is the difference between Binary Tree and Binary Search Tree
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
Q7. What are the Dynamic-link library (DLL) in Cpp and its use?
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.
Q8. What are function pointers and the differences between normal function and function pointers?
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
Q9. Explain the diamond problem in Cpp, and how to solve it.
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.
Q10. What are the ways to prevent Instantiation of Class?
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
Q11. A tweak to the pair sum problem: there can be any number of elements that add up to the target
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
Q12. Separate negative and positive numbers in a linked list.
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
Q13. 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
Q14. 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
Q15. How can you print names of 4 threads in the given order?
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.
Q16. Delete Kth node from the end of the linked list in single iteration
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
Q17. Segregate 0's and 1's in array - Dutch National Flag Algo Again
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
Q18. Equal Sum Partition along with print that 2 arrays (DP + matrix printing)
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
Q19. 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
Q20. 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
Q21. 8. If not engineering then what?
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.
Q22. 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
Q23. 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
Q24. How to check for a loop in linked list?
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).
Q25. Max multiplication of 3 numbers in an array
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.
Q26. 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
Q27. 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
Q28. 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
Q29. 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
Q30. What is finally and will it execute if System.exit() is called?
Finally is a block of code that executes after try-catch block. It will not execute if System.exit() is called.
Finally block is used to execute a block of code after try-catch block
It will execute even if an exception is thrown
Finally block will not execute if the JVM exits before the block is executed
System.exit() terminates the JVM and finally block will not execute
Q31. 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
Q32. Project Explanation which includes Q&A as well.
Developed a project management tool for tracking tasks and deadlines.
Implemented user authentication and authorization for secure access.
Utilized a relational database to store project data and user information.
Designed a user-friendly interface with drag-and-drop functionality for task management.
Q33. 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
Q34. 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
Q35. Check if a linked list is circular or not
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)
Q36. Remove duplicates from Linked List. Both variants.
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
Q37. 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
Q38. Calculating the depth of a tree
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
Q39. What are registers in Cpp?
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
Q40. 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
Q41. what is level order traversal of tree?Write code for the same.
Level order traversal is a tree traversal algorithm that visits nodes level by level.
Start at the root node and visit all nodes at the current level before moving to the next level
Use a queue to keep track of nodes at each level
Enqueue the root node, then dequeue and visit each node while enqueueing its children
Repeat until the queue is empty
Time complexity: O(n), space complexity: O(w) where w is the maximum width of the tree
Q42. 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
Q43. Kth Largest Element Problem
Given an array containing N
distinct positive integers and a number K
, determine the Kth largest element in the array.
Example:
Input:
N = 6, K = 3, array = [2, 1, 5, 6, 3, 8]
Output...read more
Q44. Reverse the linked list in groups of k
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
Q45. Encapsulation and its real-time examples
Encapsulation is a mechanism of wrapping data and code together into a single unit.
Encapsulation helps in achieving data hiding and abstraction.
It provides better control over the data by making it private and accessible only through public methods.
Real-time examples of encapsulation include a car's engine, which is encapsulated and can only be accessed through the car's interface.
Another example is a mobile phone, where the internal components are encapsulated and can only b...read more
Q46. 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
Q47. What is Runtime polymorphism
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
Q48. 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
Q49. Coding question: Given a string, find the number of occurences of each character.
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.
Q50. Inheritance and its disadvantages
Inheritance allows a subclass to inherit properties and methods from a superclass, but it has some disadvantages.
Inheritance can lead to tight coupling between classes, making it difficult to modify the superclass without affecting the subclass.
Inheritance can also lead to the creation of deep class hierarchies, which can be difficult to understand and maintain.
Inheritance can result in code duplication if multiple subclasses need to override the same method or property.
Inher...read more
Q51. 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
Q52. Dutch national flag problem
The Dutch national flag problem is a sorting problem that involves sorting an array of 3 distinct values.
The problem involves sorting an array of 3 distinct values: red, white, and blue.
The goal is to sort the array in-place, without using any additional data structures.
The solution involves using three pointers to keep track of the boundaries between the different values.
Q53. Merge two sorted linked lists
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
Q54. Find all palindromic strings in a string program
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.
Q57. Tree traversal to find minimum number
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.
Q58. 1. Write a code to split an array of integers into two subarray where both the array has equal sum.
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]
Q59. What is the Look and Say sequence, and how can a program be written to generate the next number in this sequence?
Look and Say sequence is a sequence of numbers where each term is formed by describing the previous term.
Start with the number 1
Read off the digits of the previous number, counting the number of digits in groups of the same digit
For example, starting with 1, the sequence would be: 1, 11, 21, 1211, 111221, ...
Q60. What is the process for writing a Bash script to read and parse a CSV file and print the last character of each line?
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
Q61. What is the SQL query to perform a join on two tables and calculate the aggregate sum using the product ID?
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)
Q62. What is the SQL query to join two tables and use aggregate functions such as SUM and AVG with GROUP BY?
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
Q63. Coding question: Implement Merge Sort
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
Q65. Find 2nd max salary- SQL
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.
Q66. To write code to build up a binary tree from scratch (implement a BST) and then to write all the methods like all the tree traversal algo, and all other stuffs.
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.
Q68. 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
Q69. 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())
Q70. 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
Q71. What is method overriding
Method overriding is a feature in object-oriented programming where a subclass provides a specific implementation of a method that is already provided by its parent class.
Occurs when a subclass provides a specific implementation of a method that is already provided by its parent class
The method in the subclass must have the same name, return type, and parameters as the method in the parent class
Allows for polymorphism, where a subclass can be treated as an instance of its par...read more
Q72. What are the principles of Continuous Integration and Continuous Deployment (CI/CD)?
CI/CD is a software development practice where code changes are automatically built, tested, and deployed frequently.
Continuous Integration (CI) involves automatically integrating code changes into a shared repository multiple times a day.
Continuous Deployment (CD) involves automatically deploying code changes to production after passing automated tests.
CI/CD helps in detecting and fixing integration errors early, ensuring code quality, and enabling faster delivery of feature...read more
Q73. What version control tools do you use, and can you explain how you utilize them?
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
Q74. What is the Bash command to suppress all output and errors?
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'
Q75. Code a system to query an API, do multiprocessing and improve the efficiency
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
Q76. Java core features and advantages
Java is a popular programming language known for its platform independence and object-oriented features.
Platform independence allows Java code to run on any platform without recompilation
Object-oriented features like encapsulation, inheritance, and polymorphism make code modular and reusable
Java has a vast standard library with built-in support for networking, I/O, and concurrency
Java is highly secure with features like bytecode verification and automatic memory management
Q77. Find the maximum for each and every contiguous subarray of size k from an arr of size n.
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]
Q78. Would it be acceptable to work shift timings from 6:30 AM to 3:30 PM considering that the client is based in New Zealand?
Yes, it would be acceptable to work shift timings from 6:30 AM to 3:30 PM for a client based in New Zealand.
Working from 6:30 AM to 3:30 PM would align with the standard working hours in New Zealand due to the time zone difference.
This shift timing would allow for better communication and collaboration with the client in New Zealand.
It is important to ensure that the team is able to adjust to the early start time and maintain productivity throughout the day.
Q80. How do you troubleshoot if a having internet issue?
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
Q81. 2. find unique character in a window of k size in a string
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.
Q83. DBMS types and features known
DBMS types include relational, NoSQL, object-oriented, and hierarchical. Each has unique features and use cases.
Relational DBMS: structured data, ACID compliance, SQL queries (e.g. MySQL, Oracle)
NoSQL DBMS: unstructured data, flexible schema, horizontal scaling (e.g. MongoDB, Cassandra)
Object-oriented DBMS: data stored as objects, supports inheritance and polymorphism (e.g. db4o)
Hierarchical DBMS: data organized in a tree-like structure, good for storing nested data (e.g. IBM...read more
Q84. 1. If you given a no return its corresponding excel no.
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
Q85. Program to find repeating characters in a string
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
Q86. 1.Implement merge sort. 2. Kth largest element.
Implement merge sort and find kth largest element in an array.
Merge sort is a divide and conquer algorithm that recursively divides the array into two halves, sorts them and then merges them.
Kth largest element can be found using quick select algorithm or by sorting the array and returning the kth element from the end.
Merge sort has a time complexity of O(nlogn) and space complexity of O(n).
Quick select has a time complexity of O(n) in average case and O(n^2) in worst case.
So...read more
Q87. conditions for a deadlock
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
Q88. Types of props and their how do they work?
Props are inputs passed to React components. There are two types: ownProps and childrenProps.
ownProps are passed directly to the component from its parent
childrenProps are passed to the component through its children
ownProps can be accessed using this.props in the component
childrenProps can be accessed using this.props.children in the component
Q89. 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
Q91. What is the purpose of the @Primary and @Qualifier annotations in Spring Framework?
The @Primary annotation is used to give a higher priority to a bean when multiple beans of the same type are present. The @Qualifier annotation is used to specify which bean to inject when multiple beans of the same type are present.
Use @Primary annotation to specify the primary bean to be used when multiple beans of the same type are present.
Use @Qualifier annotation along with the bean name to specify which bean to inject when multiple beans of the same type are present.
Exa...read more
Q92. concets on oops
OOPs concepts are the fundamental principles of object-oriented programming.
Abstraction
Encapsulation
Inheritance
Polymorphism
Q94. What are joins? How are they useful?
Joins are used to combine data from two or more tables based on a related column.
Joins are useful for retrieving data from multiple tables that have a relationship.
There are different types of joins such as inner join, left join, right join, and full outer join.
Inner join returns only the matching rows from both tables.
Left join returns all the rows from the left table and matching rows from the right table.
Right join returns all the rows from the right table and matching row...read more
Q95. Segregate an array containing 0 and 1 with minimum number of swaps.
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.
Q96. How to find the Second highest salary from employees table. Write the logic for pre-order, inorder and post-order traversal of a binary tree
To find the second highest salary from employees table and traverse a binary tree in pre-order, in-order, and post-order.
To find the second highest salary, you can use a subquery or window function like ROW_NUMBER() or DENSE_RANK().
For pre-order traversal, visit the root node first, then recursively do a pre-order traversal of the left subtree, followed by the right subtree.
For in-order traversal, recursively do an in-order traversal of the left subtree, visit the root node, ...read more
Q98. What is Singleton design pattern.
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
Q99. Explain Automation framework that u suggest to automate amazon application
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
Q100. How did you implement multithreading in your project?
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.
Top HR Questions asked in Ajanta Pharma
Interview Process at Ajanta Pharma
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month