Amdocs
400+ R1 RCM Interview Questions and Answers
Q1. First Unique Character in a Stream Problem Statement
Given a string A
consisting of lowercase English letters, determine the first non-repeating character at each point in the stream of characters.
Example:
Inp...read more
Given a string of lowercase English letters, find the first non-repeating character at each point in the stream.
Create a hashmap to store the frequency of each character as it appears in the stream.
Iterate through the stream and check the frequency of each character to find the first non-repeating character.
Output the first non-repeating character at each point in the stream.
Q2. Find the Third Greatest Element
Given an array 'ARR' of 'N' distinct integers, determine the third largest element in the array.
Input:
The first line contains a single integer 'T' representing the number of te...read more
Find the third largest element in an array of distinct integers.
Sort the array in descending order and return the element at index 2.
Handle cases where there are less than 3 elements in the array separately.
Make sure to handle duplicates properly.
Q3. Palindromic Substrings Problem Statement
Given a string S
, your task is to return all distinct palindromic substrings of the given string in alphabetical order.
Explanation:
A string is considered a palindrome ...read more
Return all distinct palindromic substrings of a given string in alphabetical order.
Iterate through all possible substrings of the given string.
Check if each substring is a palindrome.
Store distinct palindromic substrings in alphabetical order.
Q4. Cycle Detection in a Singly Linked List
Determine if a given singly linked list of integers forms a cycle or not.
A cycle in a linked list occurs when a node's next
points back to a previous node in the list. T...read more
Detect if a singly linked list forms a cycle by checking if a node's next pointer points back to a previous node.
Use Floyd's Cycle Detection Algorithm to determine if there is a cycle in the linked list.
Maintain two pointers, one moving at twice the speed of the other, and check if they meet at any point.
If the fast pointer reaches the end of the list (null), there is no cycle.
If the fast and slow pointers meet at some point, there is a cycle in the linked list.
Q5. Merge Sort Problem Statement
You are given a sequence of numbers, ARR
. Your task is to return a sorted sequence of ARR
in non-descending order using the Merge Sort algorithm.
Explanation:
The Merge Sort algorit...read more
Implement Merge Sort algorithm to sort a sequence of numbers in non-descending order.
Divide the input array into two halves recursively until each array has only one element.
Merge the sorted halves to produce a completely sorted array.
Time complexity of Merge Sort is O(n log n).
Example: Input: [3, 1, 4, 1, 5], Output: [1, 1, 3, 4, 5]
Q6. Pythagorean Triplet Problem
Determine if there exists a Pythagorean triplet within a given array of integers. A Pythagorean triplet consists of three numbers, x, y, and z, such that x^2 + y^2 = z^2.
Explanation...read more
Check if a Pythagorean triplet exists in a given array of integers.
Iterate through all possible combinations of three numbers in the array and check if they form a Pythagorean triplet.
Use a nested loop to generate all possible combinations efficiently.
Check if the sum of squares of two numbers is equal to the square of the third number.
Q7. Anagram Pairs Verification Problem
Your task is to determine if two given strings are anagrams of each other. Two strings are considered anagrams if you can rearrange the letters of one string to form the other...read more
Check if two strings are anagrams of each other by comparing their sorted characters.
Sort the characters of both strings and compare them.
Use a dictionary to count the frequency of characters in each string and compare the dictionaries.
Ensure both strings have the same length before proceeding with the comparison.
Example: For input 'spar' and 'rasp', after sorting both strings, they become 'aprs' which are equal, so return True.
Q8. Nth Fibonacci Number Problem Statement
Calculate the Nth term in the Fibonacci sequence, where the sequence is defined as follows: F(n) = F(n-1) + F(n-2)
, with initial conditions F(1) = F(2) = 1
.
Input:
The inp...read more
Calculate the Nth Fibonacci number efficiently using dynamic programming.
Use dynamic programming to store and reuse previously calculated Fibonacci numbers.
Start with base cases F(1) and F(2) as 1, then calculate subsequent Fibonacci numbers.
Optimize the solution to avoid redundant calculations and improve efficiency.
Q9. Reverse Linked List Problem Statement
Given a singly linked list of integers, return the head of the reversed linked list.
Example:
Initial linked list: 1 -> 2 -> 3 -> 4 -> NULL
Reversed linked list: 4 -> 3 -> 2...read more
Reverse a singly linked list of integers and return the head of the reversed linked list.
Iterate through the linked list and reverse the pointers to point to the previous node instead of the next node.
Use three pointers - prev, current, and next to reverse the linked list in O(N) time and O(1) space complexity.
Update the head of the reversed linked list as the last node encountered during the reversal process.
Q10. Find First Unique Character in a String
You are given a string S
of length N
. Your task is to find the index (considering 1-based indexing) of the first unique character in the string. If there are no unique ch...read more
Find the index of the first unique character in a given string, return -1 if no unique characters are found.
Create a hashmap to store the frequency of each character in the string.
Iterate through the string and find the first character with frequency 1.
Return the index of the first unique character or -1 if no unique characters are found.
Q11. Puzzle:- you have two jars 3L and 5L and unlimited supply of water. How will you calculate 4L of water.
To measure 4L of water using 3L and 5L jars, fill the 5L jar, pour 3L into the 3L jar, empty the 3L jar, and pour the remaining 2L from the 5L jar into the 3L jar. Finally, fill the 5L jar again and pour 1L into the 3L jar. Now, the 5L jar contains 4L of water.
Fill the 5L jar completely
Pour 3L from the 5L jar into the 3L jar
Empty the 3L jar
Pour the remaining 2L from the 5L jar into the 3L jar
Fill the 5L jar again
Pour 1L from the 5L jar into the 3L jar
Q12. Minimum Spanning Tree Problem Statement
You are provided with an undirected, connected, and weighted graph G(V, E). The graph comprises V vertices (numbered from 0 to V-1) and E edges.
Determine and return the ...read more
Find the total weight of the Minimum Spanning Tree in a graph using Kruskal's algorithm.
Implement Kruskal's algorithm to find the Minimum Spanning Tree.
Sort the edges based on their weights and add them to the MST if they don't form a cycle.
Keep track of the total weight of the MST and return it as the output.
Q13. Maximum Points On Straight Line Problem Statement
You are provided with a 2-D plane and a set of integer coordinates. Your task is to determine the maximum number of these coordinates that can be aligned in a s...read more
Find the maximum number of points that can be aligned in a straight line on a 2-D plane.
Iterate through each pair of points and calculate the slope between them.
Store the slope in a hashmap and keep track of the frequency of each slope.
The maximum frequency of slopes + 1 gives the maximum number of points on a straight line.
Q14. Maximum Sum Increasing Subsequence of Length K Problem Statement
You are given an array NUMS
consisting of N integers and an integer K. Your task is to determine the maximum sum of an increasing subsequence of ...read more
Find the maximum sum of an increasing subsequence of length K in an array.
Iterate through the array and maintain a dynamic programming table to store the maximum sum of increasing subsequences of different lengths.
For each element, check all previous elements to find the increasing subsequences and update the maximum sum accordingly.
Return the maximum sum of the increasing subsequence of length K.
Example: For input [1, 2, 5, 4, 8] and K = 3, the maximum sum increasing subsequ...read more
Q15. Find Duplicates in an Array
Given an array ARR
of size 'N', where each integer is in the range from 0 to N - 1, identify all elements that appear more than once.
Return the duplicate elements in any order. If n...read more
Find duplicates in an array of integers within a specified range.
Iterate through the array and keep track of the count of each element using a hashmap.
Return elements with count greater than 1 as duplicates.
Time complexity can be optimized to O(N) using a set to store duplicates.
To check for integer overflow when multiplying two integers, use the properties of integer overflow and check if the result is within the valid range of the integer type.
Check if the signs of the two integers are the same to avoid overflow in case of multiplication.
Use the properties of integer overflow to detect if the result exceeds the maximum or minimum value of the integer type.
Consider using a larger data type or a library that supports arbitrary-precision arithmetic if...read more
Q17. Reverse Stack with Recursion
Reverse a given stack of integers using recursion. You must accomplish this without utilizing extra space beyond the internal stack space used by recursion. Additionally, you must r...read more
Reverse a given stack of integers using recursion without using extra space or loops.
Use recursion to pop all elements from the original stack and store them in function call stack
Once the stack is empty, push the elements back in reverse order using recursion
Use the top(), pop(), and push() methods to manipulate the stack
Use SQL query with GROUP BY and HAVING clause to delete duplicate emails from a database.
Use GROUP BY clause to group emails together
Use HAVING clause to filter out groups with more than one email
Use DELETE statement to remove duplicate emails
Q19. First Unique Character in a String Problem Statement
Given a string STR
consisting of lowercase English letters, identify the first non-repeating character in the string and return it. If no such character exis...read more
Identify the first non-repeating character in a given string and return it, or '#' if none exists.
Iterate through the string to count the frequency of each character
Iterate through the string again to find the first character with frequency 1
Return the first non-repeating character or '#' if none exists
Q20. Implement Atoi Function
You have a string 'STR' of length 'N'. Your task is to implement the atoi function, which converts the string into an integer. If the string does not contain any numbers, the function sh...read more
Implement a function to convert a string to an integer, ignoring non-numeric characters and considering negative numbers.
Iterate through the characters of the string and check if they are numeric.
Handle negative numbers by checking the first character of the string.
Ignore non-numeric characters while converting the string to an integer.
Return 0 if there are no numbers in the string.
Ensure the resulting number is within the given constraints.
Constructor is a special method used to initialize objects, while a method is a regular function that performs a specific task.
Constructor is called automatically when an object is created, while a method needs to be called explicitly.
Constructors have the same name as the class, while methods have unique names.
Constructors do not have a return type, while methods have a return type.
Example: Constructor - public ClassName() { // initialization code }, Method - public void met...read more
Use three threads to print numbers from 1 to 100 in sequence.
Create three threads, each responsible for printing numbers in a specific range (e.g. 1-33, 34-66, 67-100).
Use synchronization mechanisms like mutex or semaphore to ensure proper sequencing of numbers.
Thread 1 prints numbers 1-33, Thread 2 prints numbers 34-66, Thread 3 prints numbers 67-100.
DELETE removes specific rows from a table, while TRUNCATE removes all rows and resets auto-increment values.
DELETE is a DML command, while TRUNCATE is a DDL command.
DELETE can be rolled back, while TRUNCATE cannot be rolled back.
DELETE triggers ON DELETE triggers, while TRUNCATE does not trigger any triggers.
DELETE is slower as it maintains logs, while TRUNCATE is faster as it does not maintain logs.
Example: DELETE FROM table_name WHERE condition; TRUNCATE table_name;
Q24. Subarray with Equal Occurrences Problem Statement
You are provided with an array/list ARR
of length N
containing only 0s and 1s. Your goal is to determine the number of non-empty subarrays where the number of 0...read more
Count the number of subarrays where the number of 0s is equal to the number of 1s in a given array of 0s and 1s.
Iterate through the array and keep track of the count of 0s and 1s encountered so far.
Use a hashmap to store the count of 0s and 1s encountered at each index.
For each index, check if the count of 0s and 1s encountered so far are equal. If yes, increment the total count of subarrays.
Use a 3-liter can and a 5-liter can to measure exactly 4 liters of water.
Fill the 3-liter can and pour it into the 5-liter can, leaving 2 liters in the 3-liter can.
Empty the 5-liter can, then pour the remaining 2 liters from the 3-liter can into the 5-liter can.
Fill the 3-liter can again and pour it into the 5-liter can, which already has 2 liters, making it 4 liters.
Q26. Minimum Umbrellas Problem
You are provided with ‘N’ types of umbrellas, where each umbrella type can shelter a certain number of people. Given an array UMBRELLA
that indicates the number of people each umbrella...read more
The problem involves determining the minimum number of umbrellas required to shelter a specific number of people based on the capacity of each umbrella.
Iterate through the array of umbrella capacities to find the combination that covers exactly 'M' people.
Keep track of the minimum number of umbrellas used to cover 'M' people.
If it is not possible to cover 'M' people exactly, return -1.
Example: For input [2, 3, 4] and M=5, the minimum number of umbrellas required is 2 (2-capac...read more
Overloading is having multiple methods in the same class with the same name but different parameters, while overriding is implementing a method in a subclass that is already defined in the superclass.
Overloading involves multiple methods with the same name but different parameters.
Overriding involves implementing a method in a subclass that is already defined in the superclass.
Overloading is determined at compile time based on the method signature, while overriding is determi...read more
SOLID principles are a set of five design principles that help make software designs more understandable, flexible, and maintainable.
S - Single Responsibility Principle: A class should have only one reason to change.
O - Open/Closed Principle: Objects should be open for extension but closed for modification.
L - Liskov Substitution Principle: Subtypes should be substitutable for their base types.
I - Interface Segregation Principle: Clients should not be forced to depend on inte...read more
To take a backup of a table in MySQL, you can use the mysqldump command.
Use the mysqldump command followed by the database name and table name to backup a specific table.
You can also specify the username and password for the MySQL server using the -u and -p flags.
To backup all tables in a database, use the --all-databases flag with the mysqldump command.
Q30. What is singleton calss?Write a program to make a class singleton?
Singleton class is a class that can only have one instance at a time.
It is used to control access to a shared resource or limit the instantiation of a class to one object.
To make a class singleton, make the constructor private and provide a static method to get the instance.
Example: public class Singleton { private static Singleton instance = new Singleton(); private Singleton() {} public static Singleton getInstance() { return instance; } }
Q31. Pythagorean Triplets Detection
Determine if an array contains a Pythagorean triplet by checking whether there are three integers x, y, and z such that x2 + y2 = z2 within the array.
Input:
The first line contai...read more
Detect if an array contains a Pythagorean triplet by checking if x^2 + y^2 = z^2.
Iterate through all possible combinations of three numbers in the array.
Check if the sum of squares of any two numbers is equal to the square of the third number.
Return 'yes' if a Pythagorean triplet is found, otherwise return 'no'.
Normalization is the process of organizing data in a database to reduce redundancy and improve data integrity, while denormalization is the process of intentionally adding redundancy to improve query performance.
Normalization involves breaking down a table into smaller tables and defining relationships between them to reduce redundancy and dependency.
Denormalization involves combining tables or adding redundant data to improve query performance by reducing the number of joins...read more
Q33. Challenges faced in your RPA experience and how you resolved it?
Challenges faced in RPA experience and how resolved
One challenge was automating a process with multiple decision points, resolved by creating a decision tree
Another challenge was handling exceptions, resolved by implementing exception handling mechanisms
Integration with legacy systems was a challenge, resolved by creating custom connectors
Lack of standardization in input data was a challenge, resolved by implementing data validation and cleansing mechanisms
Q34. K - Sum Path In A Binary Tree
Given a binary tree where each node contains an integer value, and a value 'K', your task is to find all the paths in the binary tree such that the sum of the node values in each p...read more
Find all paths in a binary tree where the sum of node values equals a given value 'K'.
Traverse the binary tree using depth-first search (DFS) and keep track of the current path and its sum.
When reaching a leaf node, check if the sum equals 'K' and add the path to the result.
Continue DFS traversal for both left and right children, passing updated path and sum.
Return the list of paths that sum up to 'K'.
Q35. Fibonacci Number Verification
Identify if the provided integer 'N' is a Fibonacci number.
A number is termed as a Fibonacci number if it appears in the Fibonacci sequence, where each number is the sum of the tw...read more
The task is to determine if a given integer is a Fibonacci number or not.
Iterate through the Fibonacci sequence until the current number exceeds the given integer 'N'.
Check if the given integer 'N' matches any number in the Fibonacci sequence.
If a match is found, output 'YES'; otherwise, output 'NO'.
Serialization is the process of converting an object into a byte stream, while deserialization is the reverse process.
Serialization is used to persist object state or transmit objects over a network.
Deserialization reconstructs the object from the byte stream.
Java provides Serializable interface for serialization and ObjectInputStream/ObjectOutputStream classes for deserialization.
Example: Serializing an object to a file or sending it over a network.
Q37. Remove the Kth Node from the End of a Linked List
You are given a singly Linked List with 'N' nodes containing integer data and an integer 'K'. Your task is to delete the Kth node from the end of this Linked Li...read more
Remove the Kth node from the end of a singly linked list.
Traverse the linked list to find the length 'N'.
Calculate the position to delete from the beginning as 'N - K + 1'.
Delete the node at the calculated position.
Handle edge cases like deleting the head or tail node.
Singleton class in Java ensures that a class has only one instance and provides a global point of access to it.
Singleton class restricts the instantiation of a class to one object.
It provides a way to access its unique instance globally.
Commonly implemented using a private constructor, static method, and a static instance variable.
Example: Logger class in Java can be implemented as a Singleton to ensure only one instance is used for logging.
Q39. Priority Queue Implementation
Ninja is tasked with implementing a priority queue using the Heap data structure. Since Ninja is busy with tournament preparations, your help is requested to complete this task.
Pr...read more
Implement a priority queue using Heap data structure with functions like push, pop, getMaxElement, and isEmpty.
Implement push() function to insert element into the priority queue.
Implement pop() function to delete the largest element from the queue.
Implement getMaxElement() function to return the largest element.
Implement isEmpty() function to check if the queue is empty.
Q40. What is vptr and vptr table? how many instances of them are created and when?
vptr stands for virtual pointer and vptr table is a table of function pointers used in polymorphism in C++.
vptr is a hidden member variable in C++ objects that points to the vptr table.
vptr table is a table of function pointers that maps virtual functions to their addresses.
Each object of a class with virtual functions has its own vptr and shares the same vptr table with other objects of the same class.
vptr and vptr table are created when an object of a class with virtual fun...read more
Q41. Palindrome String Validation
Determine if a given string 'S' is a palindrome, considering only alphanumeric characters and ignoring spaces and symbols.
Note:
The string 'S' should be evaluated in a case-insensi...read more
Check if a given string is a palindrome after removing special characters, spaces, and converting to lowercase.
Remove special characters and spaces from the input string
Convert the string to lowercase
Check if the modified string is a palindrome by comparing characters from start and end
Q42. What is serialization and Deserialization?write a program
Serialization is the process of converting an object into a stream of bytes, while deserialization is the reverse process.
Serialization is used for data storage, transmission, and object persistence.
Deserialization is used to recreate the original object from the serialized data.
Examples of serialization formats include JSON, XML, and binary formats like Protocol Buffers and Apache Avro.
Serialization can also be used for deep copying objects.
Deserialization can be vulnerable ...read more
Piping in Unix/Linux allows the output of one command to be used as the input for another command.
Piping is done using the | symbol
It helps in chaining multiple commands together
Example: ls -l | grep .txt
Q44. 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
Find the node where two linked lists merge
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 node
Q45. Nth Fibonacci Number Problem
Calculate the Nth term in the Fibonacci sequence using the formula: F(n) = F(n-1) + F(n-2)
where F(1) = F(2) = 1
.
Given a number N, determine the Nth Fibonacci number.
Input:
N
Outp...read more
Calculate the Nth Fibonacci number using the given formula and constraints.
Implement a function to calculate the Nth Fibonacci number using the formula F(n) = F(n-1) + F(n-2) with base cases F(1) = F(2) = 1.
Use dynamic programming or recursion to efficiently compute the Fibonacci number for large N values.
Ensure the input N is within the constraints 1 <= N <= 10000.
Example: For N = 5, the output should be 5 as the 5th Fibonacci number is 5.
Q46. All Prime Numbers Problem Statement
Given an integer 'N', your task is to print all the prime numbers that lie within the range from 2 to 'N' (inclusive).
Input:
Integer N
Output:
Prime numbers printed on separ...read more
Print all prime numbers within the range from 2 to N.
Iterate from 2 to N and check if each number is prime
A prime number is a number greater than 1 that has no positive divisors other than 1 and itself
Use a nested loop to check divisibility by numbers less than the current number
Q47. Write a program to find duplicate elements in arraylist by min number of iterations?
Program to find duplicate elements in arraylist with minimum iterations
Use HashSet to store unique elements and ArrayList to store duplicates
Iterate through the ArrayList only once
Use contains() method to check if element is already in HashSet
Q48. Ways To Make Coin Change
Given an infinite supply of coins of varying denominations, determine the total number of ways to make change for a specified value using these coins. If it's not possible to make the c...read more
The task is to determine the total number of ways to make change for a specified value using given denominations.
Create a function that takes in the number of denominations, the denominations array, and the value to make change for as input parameters.
Use dynamic programming to iterate through all possible combinations of coins to make the change.
Keep track of the number of ways to make change for each value from 0 to the target value.
Return the total number of ways to make c...read more
Q49. You have been given 9 balsa of same shape and size by using weighing scale you need to determine the heavy weight ball by weighing 3 times.
Weigh 3 groups of 3 balls each, then weigh 2 heaviest balls from the heaviest group to find the heaviest ball.
Divide the 9 balls into 3 groups of 3 balls each.
Weigh the first 2 groups against each other.
If one group is heavier, weigh 2 balls from that group against each other to find the heaviest ball.
If both groups weigh the same, weigh the third group to find the heaviest group.
Weigh 2 heaviest balls from the heaviest group to find the heaviest ball.
Check for a loop in a linked list by using two pointers moving at different speeds.
Use two pointers, one moving at double the speed of the other.
If there is a loop, the two pointers will eventually meet at the same node.
Example: 1 -> 2 -> 3 -> 4 -> 5 -> 2 (loop back to 2), the two pointers will meet at node 2.
Q51. Sort Array Problem Statement
Given an array consisting of 'N' positive integers where each integer is either 0, 1, or 2, your task is to sort the given array in non-decreasing order.
Input:
Each input starts wi...read more
Sort an array of 0s, 1s, and 2s in non-decreasing order.
Use a counting sort algorithm to count the occurrences of 0s, 1s, and 2s in the array.
Then reconstruct the array by placing the counted elements in order.
Time complexity of the counting sort algorithm is O(N).
Q52. Merge Two Sorted Linked Lists Problem Statement
You are provided with two sorted linked lists. Your task is to merge them into a single sorted linked list and return the head of the combined linked list.
Input:...read more
Merge two sorted linked lists into a single sorted linked list with linear time complexity and constant space usage.
Create a dummy node to start the merged list
Compare the values of the two linked lists and add the smaller value to the merged list
Move the pointer of the merged list and the pointer of the smaller value list forward
Continue this process until one of the lists is fully traversed
Append the remaining elements of the other list to the merged list
Return the head of ...read more
Q53. Swap Two Numbers Problem Statement
Given two integers a
and b
, your task is to swap these numbers and output the swapped values.
Input:
The first line contains a single integer 't', representing the number of t...read more
Swap two numbers 'a' and 'b' and output the swapped values.
Create a temporary variable to store one of the numbers before swapping
Assign the value of 'a' to 'b' and the temporary variable to 'a'
Output the swapped values as 'b' followed by 'a'
Q54. Coding- String reversal and separation of vowel and consonants Swap two variables without using 3rd variable Pattern printing
Answering coding questions on string reversal, variable swapping, and pattern printing.
For string reversal, use a loop to iterate through the string and append each character to a new string in reverse order.
To separate vowels and consonants, use a loop to iterate through the string and check if each character is a vowel or consonant.
To swap two variables without a third variable, use arithmetic operations or XOR bitwise operator.
For pattern printing, use nested loops to prin...read more
Q55. Why we use const reference in copy constructor?
Const reference in copy constructor is used to avoid unnecessary object copying and improve performance.
Const reference allows us to pass objects by reference without modifying them.
Using const reference in copy constructor avoids creating a temporary copy of the object being passed.
It helps in preventing unnecessary memory allocation and improves performance.
Const reference ensures that the original object is not modified during the copy construction process.
Write a SQL query to join two tables on a common attribute and select matching records.
Use the JOIN keyword to combine tables A and B on the common attribute ID
Specify the common attribute in the ON clause of the JOIN
Select the desired columns (ID_NAME) from the joined tables
Q57. write a program to display pattern. output - 1 12 123 1234
Program to display a pattern of numbers in a pyramid shape.
Use nested loops to print the numbers in the desired pattern.
The outer loop controls the number of rows and the inner loop prints the numbers in each row.
Use a variable to keep track of the number to be printed in each row.
Print a new line after each row is printed.
Q58. LRU Cache Design Question
Design a data structure for a Least Recently Used (LRU) cache that supports the following operations:
1. get(key)
- Return the value of the key if it exists in the cache; otherwise, re...read more
Design a Least Recently Used (LRU) cache data structure that supports get and put operations with capacity constraint.
Implement a doubly linked list to keep track of the order of keys based on their recent usage.
Use a hashmap to store key-value pairs for quick access and update.
When capacity is reached, evict the least recently used item before inserting a new item.
Q59. swaping of number using call by value , address and reference
Swapping of numbers can be done using call by value, address and reference.
Call by value: Pass the values of variables as arguments to the function. Swap the values inside the function.
Call by address: Pass the addresses of variables as arguments to the function. Swap the values using pointers inside the function.
Call by reference: Pass the references of variables as arguments to the function. Swap the values using references inside the function.
Q60. how to create Back Up table in mysql?
To create a backup table in MySQL, use the CREATE TABLE statement with SELECT INTO.
Use the CREATE TABLE statement with SELECT INTO to create a backup table.
Specify the name of the backup table and the name of the original table.
Use the SELECT INTO statement to copy the data from the original table to the backup table.
Example: CREATE TABLE backup_table SELECT * FROM original_table;
Make sure to regularly update the backup table to ensure data consistency.
Q61. Explain 4 words of OOPs. Encapsulation, Inheritance,Abstraction,Polymorphism
OOPs concepts include Encapsulation, Inheritance, Abstraction, and Polymorphism.
Encapsulation: bundling of data and methods that operate on that data
Inheritance: creating new classes from existing ones
Abstraction: hiding implementation details and showing only necessary information
Polymorphism: ability of objects to take on multiple forms or behaviors
Q62. whats are the diffrent position properties of css ?
CSS position properties are used to position elements on a web page.
The position property specifies the type of positioning method used for an element.
The top, bottom, left, and right properties are used to position the element.
The static, relative, absolute, fixed, and sticky values are used for the position property.
Static is the default value and elements are positioned according to the normal flow of the page.
Relative positions the element relative to its normal position....read more
Race horses in groups of 5, then race the winners to determine the top 3 fastest horses.
Divide the 25 horses into 5 groups of 5 horses each.
Race the horses in each group to determine the fastest horse in each group.
Race the winners from each group to determine the top 3 fastest horses.
Q64. What are the key concepts of Object-Oriented Programming (OOP)?
Key concepts of OOP include encapsulation, inheritance, polymorphism, and abstraction.
Encapsulation: Bundling data and methods that operate on the data into a single unit (object).
Inheritance: Allowing a class to inherit properties and behavior from another class.
Polymorphism: Objects of different classes can be treated as objects of a common superclass.
Abstraction: Hiding complex implementation details and showing only the necessary features to the outside world.
Q65. What is the internal working mechanism of a HashMap?
HashMap is a data structure that stores key-value pairs and uses hashing to quickly retrieve values based on keys.
HashMap internally uses an array of linked lists to store key-value pairs.
When a key-value pair is added, the key is hashed to determine the index in the array where the pair will be stored.
If multiple keys hash to the same index (collision), a linked list is used to store these pairs.
To retrieve a value, the key is hashed again to find the index and then the link...read more
Inner Join in SQL is used to combine rows from two or more tables based on a related column between them.
Inner Join returns only the rows that have matching values in both tables
It is the most common type of join used in SQL
Syntax: SELECT columns FROM table1 INNER JOIN table2 ON table1.column = table2.column
Example: SELECT orders.order_id, customers.customer_name FROM orders INNER JOIN customers ON orders.customer_id = customers.customer_id
Q67. write multi-threading program to print 1 2 1 2 using 2 thread.
A multi-threading program to print 1 2 1 2 using 2 threads.
Create two threads and pass a flag to each thread to print either 1 or 2.
Use a synchronization mechanism like mutex or semaphore to ensure alternate printing.
Join the threads to wait for their completion.
Q68. How to convert a string containing a number into integer without using inbuilt function?
Convert string to integer without using inbuilt function
Iterate through each character and multiply by 10 and add the integer value of the character
Use ASCII values to convert character to integer
Handle negative numbers separately
Q69. What is right outer join and it's use in real world scenario
Right outer join is a type of join operation that returns all the rows from the right table and the matching rows from the left table.
Right outer join is denoted by the RIGHT JOIN keyword in SQL.
It is used to combine rows from two tables based on a related column.
In the result set, unmatched rows from the right table will have NULL values for the columns of the left table.
A real-world scenario for using a right outer join is when analyzing customer data and sales data. The ri...read more
Q70. What is multithreading and POSIX thread and its synchronisation .
Multithreading is the ability of a CPU to execute multiple threads concurrently. POSIX thread is a standard for thread creation and management.
Multithreading allows multiple threads to run concurrently, improving performance and responsiveness.
POSIX thread (pthread) is a standard for creating and managing threads in Unix-based systems.
Thread synchronization is the coordination of threads to ensure that they do not interfere with each other's execution.
Mutexes, semaphores, and...read more
Q71. what is Garbage collector in java?
Garbage collector in Java is an automatic memory management system that frees up memory by removing unused objects.
Garbage collector runs in the background and identifies objects that are no longer in use
It frees up memory by removing those unused objects
It helps prevent memory leaks and improves performance
Java provides different types of garbage collectors such as Serial, Parallel, CMS, and G1
Example: If an object is created but not used anymore, the garbage collector will ...read more
Views in SQL are virtual tables that are generated based on the result set of a SELECT query.
Views are used to simplify complex queries by storing them as virtual tables.
They can be used to restrict access to certain columns or rows of a table.
Views do not store data themselves, but display data from the underlying tables.
Changes made to the underlying tables are reflected in the views.
Example: CREATE VIEW vw_employee AS SELECT emp_id, emp_name FROM employees;
Java is platform-independent because the code is compiled into bytecode which can run on any platform with a JVM, making the JVM platform-dependent.
Java code is compiled into bytecode, which is a platform-independent intermediate code
The JVM interprets and executes the bytecode on different platforms
The JVM acts as a layer of abstraction between the Java code and the underlying platform
The JVM is platform-dependent because it needs to be implemented specifically for each plat...read more
To determine which switch controls which bulb with only one entry to the bulb room.
Turn on the first switch and leave it on for a few minutes, then turn it off.
Turn on the second switch and enter the room.
The bulb that is on corresponds to the second switch, the bulb that is off and warm corresponds to the first switch, and the bulb that is off and cold corresponds to the third switch.
Q75. What is volatile keyword and its Real time use
Volatile keyword is used to indicate that a variable's value can be changed unexpectedly.
It is used in multi-threaded programming to ensure that the value of a variable is always up-to-date and consistent across all threads.
It prevents the compiler from optimizing code that accesses the variable, ensuring that the variable is always read from memory and not from a cache.
Examples include hardware registers, shared memory, and global variables that can be accessed by multiple t...read more
Essential UNIX commands include ls, cd, pwd, mkdir, and rm.
ls - list directory contents
cd - change directory
pwd - print working directory
mkdir - make directory
rm - remove files or directories
Q77. write a program to reverse the string any language
Program to reverse a string in any language
Create an empty string variable to store the reversed string
Loop through the original string from the end to the beginning
Append each character to the empty string variable
Return the reversed string
Q78. What is sdlc stlc waterfall model,smoke testing, black box testing, what is quality, what is strub and driver, different levels of testing, UAT, system testing. What is defect, Defect life cycle.
SDLC, STLC, Waterfall model, smoke testing, black box testing, quality, stub and driver, levels of testing, UAT, system testing, defect, defect life cycle.
SDLC (Software Development Life Cycle) is a process followed for software development.
STLC (Software Testing Life Cycle) is a process followed for software testing.
Waterfall model is a linear sequential approach to software development.
Smoke testing is a preliminary test to check if the software is stable enough for further...read more
Primary key uniquely identifies a record in a table, while unique key ensures no duplicate values in a column.
Primary key is used to uniquely identify each record in a table
Primary key does not allow NULL values
Unique key ensures that all values in a column are unique
Unique key allows NULL values, except for the column with unique constraint
A table can have only one primary key, but multiple unique keys
Left Outer Join includes all records from the left table and matching records from the right table. Right Outer Join includes all records from the right table and matching records from the left table.
Left Outer Join returns all records from the left table and the matched records from the right table. Unmatched records from the right table will have NULL values.
Right Outer Join returns all records from the right table and the matched records from the left table. Unmatched reco...read more
To find the second highest salary in a table, you can use a SQL query with the ORDER BY and LIMIT clauses.
Use a SQL query to select the distinct salaries in descending order: SELECT DISTINCT salary FROM table_name ORDER BY salary DESC
Use the LIMIT clause to retrieve the second row: LIMIT 1,1
Combine both queries to find the second highest salary: SELECT DISTINCT salary FROM table_name ORDER BY salary DESC LIMIT 1,1
Q82. Tell me about different types of joins in SQL
Different types of joins in SQL include inner join, left join, right join, and full outer join.
Inner join: Returns rows when there is a match in both tables.
Left join: Returns all rows from the left table and the matched rows from the right table.
Right join: Returns all rows from the right table and the matched rows from the left table.
Full outer join: Returns rows when there is a match in either table.
Q83. What is interfaces and demonstrate by example
Interfaces in software development define a contract for classes to implement certain methods or properties.
Interfaces in programming are like blueprints that define the structure of a class.
Classes that implement an interface must provide definitions for all the methods and properties specified in the interface.
Interfaces allow for polymorphism and code reusability.
Example: An interface 'Shape' may have methods like 'calculateArea' and 'calculatePerimeter', which classes lik...read more
Q84. Given a circular cake and a specified number of straight cuts, what is the maximum number of pieces into which the cake can be divided?
The maximum number of pieces a circular cake can be divided into with a specified number of straight cuts.
Each cut will increase the number of pieces by 1
The formula to calculate the maximum number of pieces is n(n+1)/2 + 1, where n is the number of cuts
For example, with 3 cuts, the maximum number of pieces is 7: 3(3+1)/2 + 1 = 7
The life cycle of a thread in Java involves creation, running, waiting, and termination.
A thread is created using the 'new' keyword or by implementing the Runnable interface.
The thread starts running when the start() method is called.
During execution, a thread can enter a waiting state using methods like sleep() or wait().
A thread terminates when its run() method completes or when the stop() method is called.
Run time polymorphism in C++ allows objects of different classes to be treated as objects of a common parent class.
Run time polymorphism is achieved through virtual functions and function overriding.
It allows a function to behave differently based on the object it is called on.
Example: Using a base class pointer to call a virtual function that is overridden in a derived class.
Q87. 1)How to run failed test case: using failed.xml 2)how to use click in diff ways: by actions class click and by javascriptexecuter 3)array logical program *array reverse *array sec highest number 1 12 123 1234 1...
read moreInterview questions for Automation Test Engineer
To run failed test case, use failed.xml
Click can be used via Actions class or JavascriptExecutor
Array programs: reverse, second highest number
Constructor in abstract class
Test plan and scenario definition
Roles and responsibilities in current organization
Disable test cases using keyword or include/exclude in suite
Polymorphism concept
Unix commands used in day to day activity
TestNG annotations and keywords
Code for scroll up and dow...read more
Q88. What is views in sql?
Views in SQL are virtual tables that display data from one or more tables.
Views are created using SELECT statements.
They can be used to simplify complex queries.
They can also be used to restrict access to sensitive data.
Views do not store data themselves, but rather display data from other tables.
Example: CREATE VIEW myView AS SELECT * FROM myTable WHERE column = 'value';
Q89. Differentiate between null pointer and, dangling pointer
Null pointer points to nothing, while dangling pointer points to memory that has been deallocated.
Null pointer is a pointer that does not point to any memory location.
Dangling pointer is a pointer that points to memory that has been deallocated.
Accessing a null pointer will result in a segmentation fault.
Accessing a dangling pointer can lead to unpredictable behavior or crashes.
Example: int* nullPtr = nullptr; int* danglingPtr = new int; delete danglingPtr; danglingPtr = null...read more
Q90. What would be your Expected CTC?
My expected CTC would depend on the job role, company size, location, and benefits package.
Consider the job role and responsibilities when determining expected CTC.
Research industry standards and average salaries for similar positions.
Factor in the company size and location, as cost of living varies.
Take into account additional benefits such as healthcare, retirement plans, and bonuses.
Be prepared to negotiate based on your skills, experience, and market demand.
Q91. Difference between constructor and method?
Constructor is used to initialize an object while method is used to perform an action on an object.
Constructor is called automatically when an object is created while method is called explicitly.
Constructor has the same name as the class while method has a unique name.
Constructor does not have a return type while method has a return type.
Example of constructor: public class Car { public Car() { //initialize variables } }
Example of method: public void startEngine() { //perform...read more
DELETE removes specific rows from a table, while TRUNCATE removes all rows and resets auto-increment values.
DELETE is a DML command, while TRUNCATE is a DDL command.
DELETE can be rolled back, while TRUNCATE cannot be rolled back.
DELETE triggers delete triggers, while TRUNCATE does not trigger them.
DELETE is slower as it logs individual row deletions, while TRUNCATE is faster as it logs the deallocation of the data pages.
Example: DELETE FROM table_name WHERE condition; TRUNCAT...read more
Q93. Program for reverse of string in minimum iteration
Program to reverse a string in minimum iteration
Use two pointers, one at the start and one at the end of the string
Swap the characters at the two pointers and move the pointers towards each other
Repeat until the pointers meet in the middle of the string
Q94. Which is a best technique to generate automated test report ?
The best technique to generate automated test report is to use a reporting tool that integrates with the automation framework.
Choose a reporting tool that supports the programming language and automation framework being used
Configure the reporting tool to generate reports in the desired format
Include relevant information in the report such as test case name, status, and duration
Add screenshots or videos to the report to provide additional context
Schedule the report to be gene...read more
Q95. What is process and its synchronisation
Process is a program in execution. Synchronization is the coordination of multiple processes or threads.
Process is a program in execution that has its own memory space and resources.
Synchronization is the coordination of multiple processes or threads to ensure they do not interfere with each other.
Synchronization can be achieved through various mechanisms such as locks, semaphores, and monitors.
Examples of synchronization include ensuring only one thread accesses a shared res...read more
Q96. What is recursion?Explain it graphically?How compiler executed recursion?
Recursion is a process in which a function calls itself repeatedly until a base condition is met.
Recursion involves breaking down a problem into smaller subproblems and solving them recursively.
It uses a stack to keep track of function calls and their parameters.
Examples include factorial, Fibonacci sequence, and binary search.
Compiler executes recursion by allocating memory for each function call and storing the return address and local variables on the stack.
It then pops th...read more
Q97. Design class diagram for Flower shop
Design class diagram for Flower shop
Create a Flower class with attributes like name, color, price, etc.
Create a Bouquet class that has a list of Flower objects
Create a Customer class with attributes like name, address, phone number, etc.
Create an Order class that has a Customer object and a Bouquet object
Create a Payment class with attributes like payment method, amount, etc.
Create a Delivery class with attributes like delivery address, delivery date, etc.
Q98. What is the architecture of Spring MVC?
Spring MVC follows a Model-View-Controller architecture pattern for building web applications.
Spring MVC separates the application into three main components: Model, View, and Controller.
Model represents the data of the application and the business logic to manipulate the data.
View is responsible for rendering the data to the user interface.
Controller handles the user input, processes it, and interacts with the Model and View.
Spring MVC uses DispatcherServlet as the front con...read more
Q99. Write a program to reverse link list?
Program to reverse a linked list
Create a new empty linked list
Traverse the original linked list and insert each node at the beginning of the new list
Return the new reversed linked list
Q100. PLSQL= 1.What is cursor &types 2. Diff btw primay key &unique key. 3.triggers & its type. 4. View &its types. 4.bulk collection. 5.what is dynamic query & how to implement.
Answers to questions related to PL/SQL concepts like cursor, primary key, unique key, triggers, views, bulk collection, and dynamic queries.
A cursor is a pointer to a private SQL area that stores information about the processing of a SELECT or DML statement
Primary key uniquely identifies each record in a table, while a unique key ensures that all values in a column are distinct
Triggers are stored programs that are fired automatically in response to specific events or changes ...read more
Top HR Questions asked in R1 RCM
Interview Process at R1 RCM
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month