TCS
6000+ Amazon Interview Questions and Answers
Q101. Distance Greater Than K Problem Statement
You are provided an undirected graph, a source vertex, and an integer k
. Determine if there is any simple path (without any cycle) from the source vertex to any other v...read more
Check if there is a path from source vertex to any other vertex with distance greater than k in an undirected graph.
Use Depth First Search (DFS) to traverse the graph and keep track of the distance from the source vertex.
If at any point the distance exceeds k, return true.
If DFS traversal completes without finding a path with distance greater than k, return false.
Q102. Middle of a Linked List
You are given the head node of a singly linked list. Your task is to return a pointer pointing to the middle of the linked list.
If there is an odd number of elements, return the middle ...read more
Return the middle element of a singly linked list, or the one farther from the head node in case of even number of elements.
Traverse the linked list using two pointers, one moving at twice the speed of the other.
When the faster pointer reaches the end, the slower pointer will be at the middle.
Return the element pointed to by the slower pointer.
Q103. Factorial Calculation Problem
Given an integer N
, determine the factorial value of N
. The factorial of a number N
is the product of all positive integers from 1 to N
.
Input:
First line of input: An integer 'T',...read more
Calculate the factorial of a given integer N.
Iterate from 1 to N and multiply each number to get the factorial value.
Handle edge cases like N=0 or N=1 separately.
Use recursion or iteration to calculate the factorial value.
Q104. Make Palindrome Problem Statement
You are provided with a string STR
of length N
comprising lowercase English alphabet letters. Your task is to determine and return the minimum number of characters that need to...read more
The task is to find the minimum number of characters needed to make a given string a palindrome.
Iterate from both ends of the string and compare characters to find the number of characters needed to make it a palindrome.
Use dynamic programming to optimize the solution by storing previously calculated results.
Handle edge cases like an already palindrome string or an empty string.
Consider using recursion or iteration to solve the problem efficiently.
Ensure to handle the case wh...read more
Q105. 1.what is cloud computing?? 2. How many types of clouds? 3. What is Virtualization? 4. Difference between Saas and Paas? 5. What are data types? 6. What is Artificial Intelligence? 7. Write a program to print p...
read moreAnswers to technical questions related to cloud computing, programming, and software development.
Cloud computing is the delivery of computing services over the internet.
There are three types of clouds: public, private, and hybrid.
Virtualization is the creation of a virtual version of something, such as an operating system, server, storage device, or network resource.
SaaS (Software as a Service) provides software applications over the internet, while PaaS (Platform as a Servic...read more
Permutations of a string with fixed characters.
For 1st character fixed: Generate permutations for the remaining characters.
For 1st and 2nd characters fixed: Generate permutations for the remaining characters.
For 1st, 2nd, and 3rd characters fixed: Generate permutations for the remaining characters.
Q107. SUPPOSE THERE ARE THREE MACHINE 1-GIVE TEA,2-GIVE COFFEE,3-GIVE EITHER TEA OR COFFEE.ALL MACHINE HAD A LABEL WHICH MACHINE GIVE WHAT.BUT THE LABEL GIVING INFORMATION ARE WRONG.YOU HAVE TO USE ONLY ONE MACHINE A...
read moreQ108. What is the use of private variables even though they are accessible via getters and setters from some other class?
Private variables provide encapsulation and data hiding.
Private variables can only be accessed within the class they are declared in, providing encapsulation and preventing direct modification from outside the class.
Getters and setters provide controlled access to private variables, allowing for validation and manipulation of the data before it is accessed or modified.
For example, a class may have a private variable for a person's age, but the getter can return a calculated a...read more
Q109. What is mutating table or mutating trigger?
A mutating table or mutating trigger occurs when a trigger tries to update a table that is currently being modified.
Mutating table occurs when a trigger references the table that is being modified.
It can happen when a trigger is fired by an INSERT, UPDATE, or DELETE statement on the table.
This can lead to unpredictable results or errors, such as ORA-04091: table is mutating, trigger/function may not see it.
To avoid mutating table errors, use row-level triggers instead of stat...read more
Q110. 1) cucumber 2) Defects worked on, tell me about the bugs you found during testing 3) Functional Testing 4) Automation testing tools you worked on how you worked on in detail
Questions related to cucumber, defects found, functional and automation testing tools.
Cucumber is a BDD tool used for testing
Found defects related to UI, functionality, and performance
Functional testing involves testing the application's features and functionality
Worked on automation tools like Selenium, Appium, and TestNG
Used automation tools to create test scripts and execute them
Integrated automation scripts with CI/CD pipeline for continuous testing
Q111. Find Maximum Triangle Area
Given a 2D array/list POINTS
containing 'N' distinct points on a 2D coordinate system, where POINTS[i] = [Xi, Yi]
, you need to find the maximum area of the triangle that can be formed...read more
Find the maximum area of a triangle formed by 3 points in a 2D coordinate system.
Iterate through all possible combinations of 3 points to calculate the area of the triangle using the formula for area of a triangle given 3 points.
Keep track of the maximum area found so far and return it as the result.
Ensure to handle edge cases like collinear points or points with the same coordinates.
Q112. Tell me the scenarios of the water bottle or login page
For water bottle - scenarios include filling, emptying, spilling, and cleaning. For login page - scenarios include successful login, incorrect password, forgotten password, and account creation.
Water bottle: filling with water, emptying water, spilling water, cleaning the bottle
Login page: successful login, incorrect password, forgotten password, account creation
Water bottle: dropping the bottle, losing the cap, refilling the bottle, carrying the bottle
Login page: password re...read more
Q113. Architecture of Firewalls worked, Previous role & responsibilities, What all things need to checked if enduser faces issues while accessing website or server, What if there is latency Any exceptional cases hand...
read moreInterview questions for Network Administrator role
Architecture of Firewalls
Previous role & responsibilities
Troubleshooting end-user website/server access issues
Handling latency issues
Exceptional cases in firewall troubleshooting
Understanding 3-way handshake
HSRP and its feasibility with different geolocations
TCP vs UDP differences
Understanding ISO OSI model
Q114. Search an Element in a Sorted Array
Given a sorted array 'A' of 'N' integers, determine whether a number 'X' exists within this array for a series of queries. For each query, print 1 if 'X' exists in the array,...read more
Search for a number in a sorted array and determine its existence for multiple queries.
Iterate through each query integer 'X' and perform binary search on the sorted array 'A' to check for its existence.
Output 1 if 'X' is found in 'A', otherwise output 0.
Ensure to handle multiple test cases as per the given constraints.
Q115. Smallest Number with Given Digit Product
Given a positive integer 'N', find and return the smallest number 'M', such that the product of all the digits in 'M' is equal to 'N'. If such an 'M' is not possible or ...read more
Find the smallest number with given digit product equal to a positive integer N.
Iterate from 2 to 9 and find the smallest digit that divides N, then add it to the result.
Repeat the process until N is reduced to 1 or a prime number.
If N cannot be reduced to 1 or a prime number, return 0.
Q116. Delete Alternate Nodes from a Singly Linked List
Given a Singly Linked List of integers, remove all the alternate nodes from the list.
Input:
The first and the only line of input will contain the elements of th...read more
Remove alternate nodes from a singly linked list of integers.
Traverse the linked list and skip every alternate node while connecting the previous node to the next node.
Update the next pointers accordingly to remove the alternate nodes.
Ensure to handle edge cases like empty list or list with only one node.
Q117. Reverse the String Problem Statement
You are given a string STR
which contains alphabets, numbers, and special characters. Your task is to reverse the string.
Example:
Input:
STR = "abcde"
Output:
"edcba"
Input...read more
Reverse a given string containing alphabets, numbers, and special characters.
Iterate through the string from the end to the beginning and append each character to a new string.
Use built-in functions like reverse() or StringBuilder in languages like Python or Java for efficient reversal.
Handle edge cases like empty string or strings with only one character.
Ensure to consider the constraints provided in the problem statement while implementing the solution.
Q118. Explain the difference between ArrayList and LinkedList in Java. ArrayList is implemented as a dynamic array, while LinkedList is a doubly linked list. ArrayList provides fast random access (O(1) complexity) bu...
read moreArrayList is preferred for frequent retrieval operations due to fast random access, while LinkedList is suitable for frequent insertions/deletions.
Use ArrayList when frequent retrieval operations are required, such as searching for elements in a large collection.
Choose LinkedList when frequent insertions/deletions are needed, like maintaining a queue or stack.
Consider memory overhead and performance trade-offs when deciding between ArrayList and LinkedList.
For example, use Ar...read more
Q119. Describe the differences between checked and unchecked exceptions in Java. Checked exceptions must be handled using try-catch or declared with throws. Unchecked exceptions (RuntimeException and its subclasses)...
read moreChecked exceptions must be handled explicitly, while unchecked exceptions do not require explicit handling.
Use custom exceptions when you want to create your own exception types to handle specific scenarios.
Custom exceptions can be either checked or unchecked, depending on whether you want to enforce handling or not.
For example, a custom InvalidInputException could be a checked exception if you want to ensure it is caught and handled, or an unchecked exception if it indicates...read more
Q120. Explain the concept of immutability in Java and its advantages. An immutable object cannot be changed after it is created. The String class is immutable, meaning modifications create new objects. Immutable obje...
read moreImmutability in Java prevents objects from being changed after creation, promoting thread safety and preventing unintended side effects.
Immutable objects cannot be modified after creation, promoting thread safety
String class in Java is immutable, modifications create new objects
Use final fields and avoid setters to create immutable classes
Collections can be made immutable using Collections.unmodifiableList()
Immutability is useful for caching and maintaining consistency
Excessi...read more
Q121. Explain the Singleton design pattern in Java. Singleton ensures that only one instance of a class exists in the JVM. It is useful for managing shared resources like database connections. A simple implementation...
read moreSingleton design pattern ensures only one instance of a class exists in the JVM, useful for managing shared resources like database connections.
Avoid using Singleton when multiple instances of a class are required.
Avoid Singleton for classes that are not thread-safe.
Avoid Singleton for classes that need to be easily mockable for testing purposes.
Q122. What are the uses of OOPS?
OOPS is used for creating modular, reusable and maintainable code.
Encapsulation: Hiding implementation details and exposing only necessary information.
Inheritance: Reusing code and creating a hierarchy of classes.
Polymorphism: Using a single interface to represent multiple types of objects.
Abstraction: Simplifying complex systems by breaking them down into smaller, more manageable parts.
Examples: Java, C++, Python, Ruby, etc.
Q123. Difference between DELETE, DROP and TRUNCATE command in DBMS. What is RDBMS? [Read about it from any trusted website such as GeeksForGeeks].
Explanation of DELETE, DROP and TRUNCATE commands in DBMS and definition of RDBMS.
DELETE command removes specific rows from a table.
DROP command removes an entire table from the database.
TRUNCATE command removes all rows from a table.
RDBMS stands for Relational Database Management System.
It is a type of DBMS that stores data in the form of tables with relationships between them.
Q124. Difference between Roles & Profiles, Difference between Workflow-ProcessBuilder-Flow,Types of Workflow and how to set them up,Trigger context variables
Explaining the difference between Roles & Profiles, Workflow-ProcessBuilder-Flow, types of Workflow, and Trigger context variables.
Roles define the level of access a user has to records in an organization, while profiles define the level of access a user has to objects and fields.
Workflow, Process Builder, and Flow are automation tools used to automate business processes in Salesforce.
Workflow rules are used to automate standard internal procedures and processes to save time ...read more
Q125. What will happen if you replace class with struct What is vector Can I add particular element in vector Use insert function Tell me about all the commands you know Tell me all the command in Linux you know Case...
read moreInterview questions for a software developer on topics like class vs struct, vectors, Linux commands, inheritance, and pointer safety.
Replacing class with struct changes the default access level to public
Vector is a dynamic array that can be resized at runtime
Elements can be added to vector using push_back() or insert() function
Inheritance allows a derived class to inherit properties and methods from a base class
To call base class function with derived class object, use scope...read more
Q126. What is digital communication and analogue communication. What's the difference between both of them?
Digital communication is the transmission of data in discrete binary form, while analogue communication uses continuous signals.
Digital communication uses discrete signals represented by 0s and 1s.
Analogue communication uses continuous signals that vary in amplitude, frequency, or phase.
Digital communication is more immune to noise and distortion compared to analogue communication.
Examples of digital communication include email, text messaging, and internet browsing.
Examples ...read more
Q127. 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
Q128. What is the difference b/w assignment and initialization?
Assignment is assigning a value to a variable, while initialization is declaring and assigning a value to a variable.
Assignment changes the value of an existing variable, while initialization creates a new variable and assigns a value to it.
Initialization is done only once, while assignment can be done multiple times.
Example of initialization: int x = 5; Example of assignment: x = 10;
Initialization can also be done using constructors in object-oriented programming.
In C++, uni...read more
Q129. How charging protocol works in electric vehicle and what is purpose of charging pin at charging inlet
Charging protocol in EVs and purpose of charging pin at inlet
Charging protocol determines how the battery is charged and how much power is delivered
Charging pin is used to connect the charging cable to the vehicle's charging inlet
Charging protocols include AC charging, DC charging, and wireless charging
Charging protocols also include different charging levels such as Level 1, Level 2, and Level 3
Purpose of charging pin is to ensure safe and reliable transfer of power from the...read more
Q130. Edit Distance Problem Statement
Given two strings S
and T
with lengths N
and M
respectively, your task is to find the "Edit Distance" between these strings.
The Edit Distance is defined as the minimum number of...read more
The task is to find the minimum number of operations required to convert one string into another using delete, replace, and insert operations.
Use dynamic programming to solve the problem efficiently.
Create a 2D array to store the minimum edit distance for substrings of the two input strings.
Iterate through the strings and update the array based on the operations needed for each character.
Return the value in the bottom right corner of the array as the minimum edit distance.
Q131. Sum of Infinite Array Problem Statement
Given an array A
of N
integers, construct an infinite array B
by repeating A
indefinitely. Your task is to process Q
queries, each defined by two integers L
and R
. For ea...read more
Calculate the sum of elements in a subarray of an infinite array constructed from a given array.
Construct the infinite array by repeating the given array indefinitely
For each query, calculate the sum of elements in the subarray from index L to R
Return the sum modulo 10^9 + 7
Q132. What are the advantages and disadvantages of using Java’s synchronized keyword for thread synchronization? The synchronized keyword ensures that only one thread can access a block of code at a time. It prevents...
read moreReentrantLock should be used instead of synchronized when more flexibility and control over locking mechanisms is needed.
Use ReentrantLock when you need to implement custom locking strategies or require advanced features like tryLock() and lockInterruptibly().
ReentrantLock supports fair locking mechanisms, ensuring that threads acquire the lock in the order they requested it.
Explicit unlocking in ReentrantLock reduces the risk of deadlocks and allows for more precise control ...read more
Q133. What is the difference between == and .equals() in Java? == checks for reference equality, meaning it compares memory addresses. equals() checks for value equality, which can be overridden in user-defined class...
read moreIn Java, == checks for reference equality while equals() checks for value equality. Misuse of == can lead to logical errors.
Override equals() when you want to compare the values of objects instead of their references
Override hashCode() alongside equals() to ensure proper functioning in collections like HashMap
Consider implementing Comparable interface for natural ordering in collections
Q134. What is the Java Memory Model, and how does it affect multithreading and synchronization? The Java Memory Model (JMM) defines how threads interact with shared memory. It ensures visibility and ordering of varia...
read moreThe Java Memory Model defines how threads interact with shared memory, ensuring visibility and ordering of variable updates in a concurrent environment.
Volatile keyword ensures changes to a variable are always visible to all threads.
Synchronized keyword provides mutual exclusion and visibility guarantees.
Reordering optimizations by the compiler or CPU can lead to unexpected behavior.
Happens-before relationship determines the order of execution for threads.
Atomic variables lik...read more
Q135. What is a Java Stream, and how does it differ from an Iterator? Streams enable functional-style operations on collections with lazy evaluation. Unlike Iterators, Streams support declarative operations like filt...
read moreJava Streams enable functional-style operations on collections with lazy evaluation, unlike Iterators.
Parallel streams can improve performance by utilizing multiple threads, but may introduce overhead due to thread management.
Care must be taken to ensure thread safety when using parallel streams in a multi-threaded environment.
Parallel streams are suitable for operations that can be easily parallelized, such as map and filter.
Example: Using parallel streams to process a large...read more
Q136. Question 1: What is memory leak? Question 2: What is static variable in C? with program Question 3: What are local variable and global variables? and their default values and program Question 4: What is method...
read moreTechnical interview questions for Executive Engineer position
Memory leak is a situation where a program fails to release memory that is no longer needed
Static variables in C are variables that retain their values between function calls
Local variables are declared inside a function and have a limited scope, while global variables can be accessed from any part of the program
Method overriding is a feature in object-oriented programming where a subclass provides a different imple...read more
Q137. How does the Java garbage collector work? Garbage collection in Java automatically reclaims memory occupied by unused objects. The JVM has different types of GC algorithms, including Serial, Parallel, CMS, and...
read moreGarbage collection in Java automatically reclaims memory occupied by unused objects using different algorithms and memory regions.
Java garbage collector automatically reclaims memory from unused objects
Different types of GC algorithms in JVM: Serial, Parallel, CMS, G1 GC
Objects managed in Young Generation, Old Generation, and PermGen/Metaspace
Minor GC cleans up short-lived objects in Young Generation
Major GC (Full GC) reclaims memory from Old Generation, causing pauses
CMS GC ...read more
Q138. What are the main features of Java 8? Java 8 introduced lambda expressions, enabling functional-style programming. The Stream API allows efficient data processing with map, filter, and reduce operations. Defaul...
read moreLambda expressions in Java 8 improve readability and maintainability by enabling concise and functional-style programming.
Lambda expressions allow writing more compact code by reducing boilerplate code.
They enable passing behavior as arguments to methods, making code more modular and flexible.
Example: (a, b) -> a + b is a lambda expression that adds two numbers.
Q139. Can you explain the difference between method overloading and method overriding in Java? Method overloading allows multiple methods with the same name but different parameters. It occurs within the same class a...
read moreMethod overloading allows multiple methods with the same name but different parameters, while method overriding allows a subclass to provide a different implementation of a parent method.
Use method overloading when you want to provide multiple ways to call a method with different parameters.
Use method overriding when you want to provide a specific implementation of a method in a subclass.
Example of method overloading: having multiple constructors in a class with different par...read more
Q140. What are functional interfaces in Java, and how do they work with lambda expressions? A functional interface is an interface with exactly one abstract method. Examples include Runnable, Callable, Predicate, and...
read moreFunctional interfaces in Java have exactly one abstract method and work with lambda expressions for concise implementation.
Functional interfaces have exactly one abstract method, such as Runnable, Callable, Predicate, and Function.
Lambda expressions provide a concise way to implement functional interfaces.
Default methods in interfaces help in evolving APIs without breaking backward compatibility.
Method references (::) can be used to reference existing methods as lambdas.
Strea...read more
Q141. What is the difference between final, finally, and finalize in Java? final is a keyword used to declare constants, prevent method overriding, or inheritance. finally is a block that executes after a try-catch,...
read morefinal, finally, and finalize have different meanings in Java. final is for constants, finally for cleanup, and finalize for garbage collection.
final is used for constants, preventing method overriding, and inheritance
finally is used for cleanup actions after a try-catch block
finalize() is called by the garbage collector before object deletion
Alternatives to finalize() for resource management include using try-with-resources, implementing AutoCloseable interface, or using exte...read more
Q142. What are Java annotations, and how are they used in frameworks like Spring? Annotations provide metadata to classes, methods, and fields. @Override, @Deprecated, and @SuppressWarnings are common built-in annota...
read moreJava annotations provide metadata to classes, methods, and fields, improving code readability and maintainability.
Annotations like @Component, @Service, and @Autowired in Spring help with dependency injection
Annotations reduce boilerplate code compared to XML configurations
Custom annotations can be created using @interface
Reflection APIs allow reading annotation metadata dynamically
Annotations like @Transactional simplify database transaction management
Q143. How do Java Streams handle parallel processing, and what are its pitfalls? Parallel streams divide data into multiple threads for faster processing. The ForkJoin framework handles parallel execution internally....
read moreJava Streams handle parallel processing by dividing data into multiple threads using the ForkJoin framework. Pitfalls include race conditions, performance issues with small datasets, and debugging challenges.
Parallel streams divide data into multiple threads for faster processing
ForkJoin framework handles parallel execution internally
Useful for CPU-intensive tasks but may not improve performance for small datasets
Shared mutable state can cause race conditions
Order-sensitive o...read more
Q144. What is list,tuple? What is shallow copy? Name some libraries in python. What is python current version and how do you find on Command prompt? OOPS in python. Abstraction vs Encapsulation
Questions related to Python programming language and concepts.
List and tuple are data structures in Python. List is mutable while tuple is immutable.
Shallow copy creates a new object but references the original object's elements.
Some libraries in Python are NumPy, Pandas, Matplotlib, and Scikit-learn.
Python's current version is 3.9. You can find it on Command prompt by typing 'python --version'.
OOPS in Python stands for Object-Oriented Programming. It allows for creating clas...read more
Types of inheritance in OOP include single, multiple, multilevel, hierarchical, hybrid, and multipath inheritance.
Single inheritance: A class inherits from only one base class.
Multiple inheritance: A class inherits from more than one base class.
Multilevel inheritance: A class inherits from a class which in turn inherits from another class.
Hierarchical inheritance: Multiple classes inherit from a single base class.
Hybrid inheritance: Combination of multiple and multilevel inhe...read more
Q146. Square Root with Decimal Precision Problem Statement
You are provided with two integers, 'N' and 'D'. Your objective is to determine the square root of the number 'N' with a precision up to 'D' decimal places. ...read more
Implement a function to find square root of a number with given decimal precision.
Implement a function that takes two integers N and D as input and returns the square root of N with precision up to D decimal places
Ensure the discrepancy between the computed result and the correct value is less than 10^(-D)
Handle multiple test cases efficiently within the given constraints
Use mathematical algorithms like Newton's method for square root calculation
Example: For N = 10 and D = 3,...read more
Q147. 1. Difference between tuple and a list? 2. What are decorators? 3. What is 'to' object? 4. Program to illustrate the difference between pass, break, continue? 5. Find the error in the given program? 6. Explain...
read moreAnswers to interview questions for a Python developer.
1. Tuples are immutable while lists are mutable.
2. Decorators are functions that modify the behavior of other functions.
3. 'to' object is not a standard term in Python, so it's unclear.
4. Pass does nothing, break exits the loop, and continue skips to the next iteration.
5. Need the given program to identify the error.
6. Explain your projects in detail, highlighting your role and achievements.
Q148. What is the recent news that you have heard about TCS?
TCS recently announced a partnership with Google Cloud to build industry-specific cloud solutions.
TCS and Google Cloud will jointly develop cloud solutions for industries such as healthcare, financial services, and retail.
The partnership aims to help organizations accelerate their digital transformation journey by leveraging the power of cloud technology.
TCS will also establish a Google Cloud Academy to train its employees on Google Cloud technologies.
This collaboration highl...read more
Q149. What is the difference between delete , truncate and drop?
Delete removes specific rows from a table, truncate removes all rows, and drop removes the entire table.
Delete is a DML operation, while truncate and drop are DDL operations.
Delete is slower as it logs individual row deletions, while truncate and drop are faster.
Delete can be rolled back, while truncate and drop cannot be rolled back.
Delete can have conditions to specify which rows to delete, while truncate and drop affect the entire table.
Example: DELETE FROM table_name WHER...read more
Q150. Write a code to describe the difference b/w normal function calling and stored procedure invocation?
A normal function is called directly in the code, while a stored procedure is invoked using a database query.
Normal function calling is done within the program code, while stored procedure invocation is done through a database query.
Normal functions are defined and called within the same programming language, while stored procedures are defined and invoked within a database management system.
Normal function calling is synchronous, while stored procedure invocation can be asyn...read more
Q151. What do you mean by experience certainty?
Experience certainty refers to the level of confidence and assurance gained through repeated exposure to a particular task or situation.
Experience certainty is achieved through repetition and familiarity.
It allows individuals to perform tasks with greater ease and efficiency.
For example, a pilot who has flown the same route multiple times will have a higher level of experience certainty compared to a pilot who is flying the route for the first time.
Experience certainty can al...read more
Q152. Reverse Array Elements
Given an array containing 'N' elements, the task is to reverse the order of all array elements and display the reversed array.
Explanation:
The elements of the given array need to be rear...read more
Reverse the order of elements in an array and display the reversed array.
Iterate through the array from both ends and swap the elements until the middle is reached.
Use a temporary variable to store the element being swapped.
Print the reversed array after all elements have been swapped.
Q153. 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.
Example: For input [0, 3, 1, 2, 3], output should be [3].
Q154. Minimum Operations Problem Statement
You are given an array 'ARR'
of size 'N'
consisting of positive integers. Your task is to determine the minimum number of operations required to make all elements in the arr...read more
Minimum number of operations to make all elements in the array equal by performing addition, subtraction, multiplication, or division.
Iterate through the array to find the maximum and minimum values.
Calculate the difference between the maximum and minimum values.
The minimum number of operations needed is the difference between the maximum and minimum values.
Q155. Convert BST to Min Heap
You are given a binary search tree (BST) that is also a complete binary tree. Your task is to convert this BST into a Min Heap. The resultant Min Heap should maintain the property that a...read more
Convert a given binary search tree (BST) that is also a complete binary tree into a Min Heap.
Traverse the BST in level order and store the values in an array.
Convert the array into a Min Heap by rearranging the elements.
Reconstruct the Min Heap as a binary tree and return the root node.
Q156. How do you find if two table having similer data
To find if two tables have similar data, compare the records in both tables using a join or a subquery.
Use a join operation to compare the records in both tables based on a common column.
If the tables have a primary key, you can join them on that key to check for similar data.
Alternatively, you can use a subquery to compare the data in both tables and check for matching records.
Consider using the MINUS operator to find the differences between the two tables.
You can also use t...read more
Q157. We use multiple inheritance in C++. Does java supports it? If not then what java used instead of multiple inheritance?
Java does not support multiple inheritance. It uses interfaces to achieve similar functionality.
Java supports single inheritance, where a class can only inherit from one superclass.
To achieve multiple inheritance-like behavior, Java uses interfaces.
Interfaces allow a class to implement multiple interfaces, providing access to multiple sets of methods and constants.
Unlike classes, interfaces cannot be instantiated and can only be implemented by classes.
Example: class A impleme...read more
Q158. 2. What is the get metadata activity and what are the parameters we have to pass?
Get metadata activity is used to retrieve metadata of a specified data store or dataset in Azure Data Factory.
Get metadata activity is used in Azure Data Factory to retrieve metadata of a specified data store or dataset.
Parameters to pass include dataset, linked service, and optional folder path.
The output of the activity includes information like schema, size, last modified timestamp, etc.
Example: Get metadata of a SQL Server table using a linked service to the database.
Q159. Does Java support multiple Inheritance? If not then how an interface inherits two interfaces? Explain
Java does not support multiple inheritance, but interfaces can inherit multiple interfaces.
Java does not allow a class to inherit from multiple classes, but it can implement multiple interfaces.
Interfaces can inherit from multiple interfaces using the 'extends' keyword.
For example, interface C can extend interfaces A and B: 'interface C extends A, B {}'
Q160. What is the smallest and the biggest real time project of Java according to you? What is Big Data? If you have to perform actions on 2 billion entry at a time. What would you do and which languages and technolo...
read moreThe smallest real-time project in Java could be a simple chat application, while the biggest could be a complex financial trading system.
Smallest real-time project in Java: Chat application
Biggest real-time project in Java: Financial trading system
Big Data refers to large and complex data sets that cannot be easily processed using traditional data processing applications.
For performing actions on 2 billion entries, technologies like Hadoop, Spark, and languages like Java or S...read more
Q161. What is inheritance , polymorphism ,different classes ?
Inheritance, polymorphism, and classes are fundamental concepts in object-oriented programming.
Inheritance allows a class to inherit properties and methods from another class.
Polymorphism allows objects of different classes to be treated as if they are of the same class.
Classes are blueprints for creating objects that have properties and methods.
For example, a Car class can inherit from a Vehicle class, and a SportsCar class can inherit from the Car class.
Polymorphism allows ...read more
Q162. You've just started a bike brand. What digital marketing channel will you use?
I would use social media as a digital marketing channel for the bike brand.
Create engaging content and share it on platforms like Facebook, Instagram, and Twitter.
Utilize targeted advertising to reach potential customers who are interested in bikes.
Collaborate with influencers and bike enthusiasts to promote the brand and generate buzz.
Encourage user-generated content by running contests or campaigns that involve customers sharing their biking experiences.
Monitor and respond ...read more
Q163. Valid Parentheses Problem Statement
Given a string 'STR' consisting solely of the characters “{”, “}”, “(”, “)”, “[” and “]”, determine if the parentheses are balanced.
Input:
The first line contains an integer...read more
Check if given strings containing parentheses are balanced or not.
Use a stack to keep track of opening parentheses
Iterate through the string and push opening parentheses onto the stack
When a closing parenthesis is encountered, pop from the stack and check if it matches the corresponding opening parenthesis
If stack is empty at the end and all parentheses are matched, the string is balanced
Q164. 1. What is the velocity trend? 2. Metrics used in scrum framework 3. Type of conflicts and how to resolve them 4. INVEST model used for the creation of user stories 5. Explain about 'DOD' and 'DOR'? 6. Explain...
read moreAnswers to various questions related to Scrum framework and Agile methodology.
Velocity trend is the rate at which the team is delivering the product increment.
Metrics used in Scrum framework include burndown chart, velocity, sprint goal, etc.
Types of conflicts in Scrum are personal, technical, and domain-related. They can be resolved through communication, negotiation, and compromise.
INVEST model is used for creating user stories that are Independent, Negotiable, Valuable, Es...read more
Q165. How to publish Odata service by consumption view
To publish Odata service by consumption view, create a consumption view and expose it as an Odata service.
Create a consumption view using SE11 transaction
Activate the view and generate the runtime object
Create an Odata service using SEGW transaction
Add the consumption view to the Odata service
Activate and publish the Odata service
Q166. You have done a lot of courses in coursera and NPTEL. What is the use of it?
Courses in Coursera and NPTEL provide knowledge and skills in various fields.
Courses in Coursera and NPTEL offer a wide range of topics to learn from.
They provide access to high-quality education from top universities and institutions.
The courses help in developing new skills and enhancing existing ones.
They can be useful for career advancement and personal growth.
For example, a course in data science can help in analyzing and interpreting data for business decisions.
Similarl...read more
Q167. 3.How could you educate the users regarding with cybersecurity attacks?
Educating users about cybersecurity attacks is crucial for their protection.
Conduct regular cybersecurity awareness training sessions
Provide clear and concise guidelines on safe online practices
Share real-life examples of cyber attacks and their consequences
Encourage the use of strong and unique passwords
Promote the use of multi-factor authentication
Teach users how to identify phishing emails and suspicious links
Advise against downloading files from unknown sources
Highlight t...read more
Q168. Yogesh And Primes Problem Statement
Yogesh, a bright student interested in Machine Learning research, must pass a test set by Professor Peter. To do so, Yogesh must correctly answer Q questions where each quest...read more
Yogesh needs to find the minimum possible P such that there are at least K prime numbers in the range [A, P].
Iterate from A to B and check if each number is prime
Keep track of the count of prime numbers found in the range [A, P]
Return the minimum P that satisfies the condition or -1 if no such P exists
Q169. Compute the nearest larger number by interchanging its digits updated.Given 2 numbers a and b find the smallest number greater than b by interchanging the digits of a and if not possible print -1.
Compute the nearest larger number by interchanging its digits.
Given two numbers a and b
Find the smallest number greater than b by interchanging the digits of a
If not possible, print -1
Q170. What is basic function of firewall.
Firewall is a network security system that monitors and controls incoming and outgoing network traffic based on predetermined security rules.
Firewall acts as a barrier between a trusted, secure internal network and another network, such as the Internet.
It examines each packet of data that passes through it and determines whether to allow or block the traffic based on the set of rules.
Firewalls can be hardware or software-based and can be configured to block specific types of ...read more
Q171. What is oops concept in java
Object-oriented programming (OOP) is a programming paradigm that uses objects to represent and manipulate data.
OOP is based on the concept of classes and objects.
It focuses on encapsulation, inheritance, and polymorphism.
Encapsulation hides the internal details of an object and provides a public interface.
Inheritance allows classes to inherit properties and behaviors from other classes.
Polymorphism allows objects of different classes to be treated as objects of a common super...read more
Q172. If we have excess reserve & surplus how you allocate it.How you recognise revenue on Ind as 115.How Are Balance Sheet of Company different from the Bank
Excess reserve & surplus can be allocated through various methods such as reinvestment, dividends, or debt repayment. Revenue recognition under Ind AS 115 follows a five-step model. Balance sheets of companies differ from banks in terms of assets, liabilities, and capital structure.
Excess reserve & surplus allocation methods: reinvestment, dividends, debt repayment
Revenue recognition under Ind AS 115: five-step model
Differences between company and bank balance sheets: assets,...read more
Q173. Where I implemented Executor service in my project?
Implemented Executor service in the backend for parallel processing.
Implemented ExecutorService in the backend to handle multiple requests concurrently.
Used ExecutorService to execute multiple tasks in parallel.
Implemented ExecutorService to improve the performance of the application.
Used ExecutorService to manage thread pools and execute tasks asynchronously.
Q174. As you have done B-tech, tell me the meaning of diode, rectifier, amplifier?
A diode is an electronic component that allows current to flow in one direction, while a rectifier converts alternating current to direct current, and an amplifier increases the amplitude of a signal.
A diode is a two-terminal device that conducts current in one direction and blocks it in the opposite direction.
A rectifier is a device that converts alternating current (AC) to direct current (DC) by using diodes.
An amplifier is an electronic device that increases the amplitude ...read more
Q175. When two or more computers or communicating devices are in a room, on a floor in a building or in a campus, if connected is said to be connected on a LAN.
LAN stands for Local Area Network, which connects two or more devices in a limited area.
LAN is a type of network that connects devices within a limited area such as a room, floor, or building.
It allows devices to communicate with each other and share resources such as printers and files.
LAN can be wired or wireless, and can be set up using Ethernet cables or Wi-Fi.
Examples of LAN include home networks, office networks, and school networks.
Q176. Number Pattern Problem Statement
Create a number pattern as specified by Ninja. The pattern should be constructed based on a given integer value 'N'.
Example:
Input:
N = 4
Output:
4444 3444 2344 1234
Explanatio...read more
Generate a number pattern based on a given integer value 'N' by incrementing digits from right to left in each line.
Start from the rightmost side and increment digits while moving towards the left in each line
Print 'N' lines for each test case
Handle multiple test cases by reading the number of test cases 'T' first
Q177. What is the difference between Software Development Life Cycle (SDLC) and Software Testing Life Cycle (STLC)?
SDLC focuses on the development of software, while STLC focuses on the testing of software.
SDLC involves planning, designing, coding, and deployment of software.
STLC involves test planning, test case development, test execution, and defect tracking.
SDLC is more focused on the overall software development process, while STLC is more focused on ensuring the quality of the software.
SDLC is a broader process that includes STLC as one of its phases.
Example: In SDLC, a software tea...read more
Q178. What are the advantages of Stored Procedures?
Stored procedures offer advantages such as improved performance, security, and code reusability.
Stored procedures can reduce network traffic by executing multiple SQL statements at once.
They can also improve performance by pre-compiling SQL statements.
Stored procedures can enhance security by allowing access to only specific procedures rather than entire tables.
They promote code reusability by allowing multiple applications to use the same stored procedure.
Examples include pr...read more
Q179. Why did you learn PHP, if JSP is more secure?
PHP was chosen for its versatility, large community support, and ease of use.
PHP is a widely used scripting language with a large community of developers and extensive documentation.
It is known for its versatility and ability to integrate with various databases and web servers.
PHP is also relatively easy to learn and has a low learning curve compared to other languages like JSP.
While JSP may be considered more secure, PHP can still be used to build secure applications with pr...read more
Q180. What do you know about File System in C++?
File System in C++ is used for managing files and directories, providing functions for file input/output operations.
C++ provides the
library for file input/output operations. File streams can be used to read from and write to files.
Common file operations include opening, closing, reading, and writing files.
File streams can handle different file types such as text files and binary files.
File system functions like file existence check, file deletion, and file renaming are avail...read more
Q181. What is the difference b/w thread and process?
A thread is a lightweight unit of execution within a process, while a process is an instance of a program in execution.
A process has its own memory space, while threads share the same memory space within a process.
Processes are independent and isolated from each other, while threads share resources and can communicate with each other more easily.
Creating a new process is more resource-intensive than creating a new thread.
Threads are scheduled by the operating system, while pr...read more
Q182. What is an Agile Model?
Agile Model is an iterative approach to software development that emphasizes flexibility and customer satisfaction.
Agile Model involves continuous collaboration between cross-functional teams and customers
It prioritizes working software over comprehensive documentation
It allows for changes and adjustments to be made throughout the development process
Examples of Agile methodologies include Scrum, Kanban, and Extreme Programming (XP)
Q183. who do you debug the error and which method do you choose
Debugging errors involves identifying the root cause and using appropriate methods to resolve it.
Start by reproducing the error and gathering relevant information
Use debugging tools like logs, stack traces, and breakpoints to identify the root cause
Once the root cause is identified, use appropriate methods like code changes or configuration updates to resolve the error
Test the solution thoroughly to ensure it does not cause any new errors
Q184. What is class and object tell the difference
Class is a blueprint for creating objects while object is an instance of a class.
Class defines the properties and behaviors of an object
Object is created from a class and has its own unique state and behavior
Multiple objects can be created from a single class
Class is a static entity while object is a dynamic entity
Example: Class - Car, Object - BMW X5
Q185. How to know which python object belongs to which class?
Python objects can be checked for their class using the type() function or the isinstance() function.
Use the type() function to check the class of an object. For example, type(5) will return
. Use the isinstance() function to check if an object belongs to a specific class. For example, isinstance(5, int) will return True.
In Python, everything is an object, so you can check the class of any object using type() or isinstance().
Q186. 1. what is static variables 2. what is a array 3. what is collections 4. Difference between c++ and java 5. what is java Architecture 6. what is java 7. what is Oops
Static variables are variables that are shared among all instances of a class. Arrays are a data structure that stores a collection of elements. Collections are classes in Java that store and manipulate groups of objects. C++ and Java differ in syntax, memory management, and platform independence. Java architecture consists of JVM, JRE, and JDK. Java is a high-level programming language known for its platform independence. Object-oriented programming (OOP) is a programming pa...read more
Q187. What is operating system? Difference between compiler and interpretor? One byte is how many bit? What is Machine language? What is the function of assembler ? What are the different types of operating system? W...
read moreOperating system is a software that manages computer hardware and software resources.
Compiler translates high-level language code to machine code while interpreter executes code line by line.
One byte is equal to 8 bits.
Machine language is a low-level programming language consisting of binary code.
Assembler converts assembly language code to machine code.
Types of operating system include Windows, macOS, Linux, and Unix.
Unix is a multi-user, multi-tasking operating system devel...read more
Q188. What protocols used by nmap Difference between public and private ip ( mention ip ranges) Command to check connected devices , open and filter port in nmap How firewall works, can we close firewall port ? How p...
read moreAnswering questions related to nmap, IP addresses, firewall, and ping scan.
Nmap uses various protocols such as TCP, UDP, ICMP, and ARP.
Public IP addresses are globally unique and routable on the internet, while private IP addresses are used within a private network and not routable on the internet. Private IP ranges include 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16.
To check connected devices and open ports, use the command 'nmap -sP
' and 'nmap -p ', respectively. To fil...read more
Types of constructors in C++ include default constructor, parameterized constructor, copy constructor, and destructor.
Default constructor: Constructor with no parameters.
Parameterized constructor: Constructor with parameters.
Copy constructor: Constructor that initializes an object using another object of the same class.
Destructor: Special member function called when an object goes out of scope.
Q190. Do you have any experience in programming ? If yes , explain?
Yes, I have experience in programming.
I have a Bachelor's degree in Computer Science.
I have worked as a software developer for 3 years.
I am proficient in programming languages like Java, C++, and Python.
I have developed web applications using frameworks like React and Angular.
I have experience in database management with SQL and NoSQL databases.
I have worked on projects involving data analysis and machine learning algorithms.
Q191. 1. What is interface how to use? 2. Tell me a small example for interface? 3. How to managing the Error Logging system at your application 4. How you implement Security at your application 5. What are the Joins...
read moreAnswering questions related to IT Analyst position
An interface is a contract between two objects that defines the communication between them
An example of an interface is the Java interface, which defines a set of methods that a class must implement
Error logging can be managed by setting up a system to capture and store error messages, and regularly reviewing and addressing them
Security can be implemented through measures such as authentication, authorization, encryption, and ...read more
Q192. Write a basic program for controlling the Temperature inside a car. Print turn on if the temperature is above a certain limit and print turn off when temperature is below a certain limit.
A basic program to control car temperature by turning on/off based on set limits.
Create a variable to store current temperature
Set a limit for turning on the temperature control
Set a limit for turning off the temperature control
Use conditional statements to check if temperature is above or below the limits
Print 'Turn on' if temperature is above the limit, 'Turn off' if below
Q193. 5) 100 people in a party hall and shake their hands with everyone else in the room. How many handshakes will take place?
The number of handshakes in a party hall with 100 people can be calculated using the formula n(n-1)/2.
The formula to calculate the number of handshakes is n(n-1)/2, where n is the number of people.
In this case, n = 100, so the number of handshakes = 100(100-1)/2 = 4950.
Each person shakes hands with every other person in the room, resulting in a total of 4950 handshakes.
Q194. So what is the need of 8085 to study now as in washing machines and computers we use advance processors?---SIr actually washing machine is an embedded system and it works on microcontroller yes computer works o...
read moreQ195. What is an infinite loop? write a program
An infinite loop is a loop that runs indefinitely without stopping.
It can cause a program to crash or freeze.
It is usually caused by a logical error in the loop condition.
Example: while(true) { //code }
Example: for(;;) { //code }
Q196. What is the difference between Hashmap and Hashtable?
Hashtable is synchronized and does not allow null keys or values, while HashMap is not synchronized and allows null keys and values.
Hashtable is thread-safe, while HashMap is not.
Hashtable does not allow null keys or values, while HashMap allows null keys and values.
Hashtable is slower than HashMap due to synchronization.
Hashtable is a legacy class, while HashMap is part of the Java Collections Framework.
Hashtable is recommended to be used in multi-threaded environments, whil...read more
Q197. How many annotations in TestNG and brief all the annotations.
TestNG has 8 annotations including @Test, @BeforeSuite, @AfterSuite, @BeforeTest, @AfterTest, @BeforeClass, @AfterClass, @BeforeMethod, @AfterMethod.
1. @Test - Marks a method as a test method.
2. @BeforeSuite - Executed before the Test Suite.
3. @AfterSuite - Executed after the Test Suite.
4. @BeforeTest - Executed before the Test.
5. @AfterTest - Executed after the Test.
6. @BeforeClass - Executed before the first test method in the current class.
7. @AfterClass - Executed after a...read more
Q198. HOW A IS IMPORTANT FOR AN BUSINESS TO GROW & WHAT IS THE IMPORTANT FACTORS IN AP
A is important for business growth as it helps in streamlining processes and improving efficiency.
AP (Accounts Payable) plays a crucial role in managing a company's cash flow and financial stability.
Efficient AP processes ensure timely payments to vendors and suppliers, which helps in maintaining good relationships.
AP automation can reduce errors and save time, allowing employees to focus on more strategic tasks.
Proper AP management can also help in identifying cost-saving op...read more
Q199. Current GDP of India in growth percentage and dollar value ?
As of 2021, India's GDP growth rate is approximately 9.2% and its dollar value is around $3.05 trillion.
India's GDP growth rate is one of the highest among major economies.
The GDP growth rate indicates the rate at which the country's economy is expanding.
The dollar value of India's GDP represents the total economic output in terms of US dollars.
The GDP growth rate and dollar value are subject to change as new data becomes available.
Q200. What is autonomous transaction?
Autonomous transaction is a separate transaction initiated by a parent transaction.
It allows a subtransaction to commit or rollback independently of the parent transaction.
It is useful for logging or auditing purposes.
It can be created using the PRAGMA AUTONOMOUS_TRANSACTION statement.
Example: A parent transaction updates a table, while an autonomous transaction logs the changes made.
Example: An autonomous transaction sends an email notification after a parent transaction com...read more
More about working at TCS
Top HR Questions asked in Amazon
Interview Process at Amazon
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month