Add office photos
TCS logo
Engaged Employer

TCS

Verified
3.7
based on 89.8k Reviews
Video summary
Filter interviews by
Software Engineer
Fresher
Experienced
Skills
Clear (1)

200+ TCS Software Engineer Interview Questions and Answers

Updated 27 Feb 2025

Q1. Find the Duplicate Number Problem Statement

Given an integer array 'ARR' of size 'N' containing numbers from 0 to (N - 2). Each number appears at least once, and there is one number that appears twice. Your tas...read more

Ans.

Given an array of size N containing numbers from 0 to (N-2), find and return the duplicate number.

  • Iterate through the array and keep track of the frequency of each number using a hashmap.

  • Return the number with a frequency of 2.

View 8 more answers
right arrow

Q2. Find the Second Largest Element

Given an array or list of integers 'ARR', identify the second largest element in 'ARR'.

If a second largest element does not exist, return -1.

Example:

Input:
ARR = [2, 4, 5, 6, ...read more
Ans.

The task is to find the second largest element in an array of integers.

  • Iterate through the array and keep track of the largest and second largest elements.

  • Initialize the largest and second largest variables with the first two elements of the array.

  • Compare each element with the largest and second largest variables and update them accordingly.

  • Return the second largest element at the end.

  • Handle the case where no second largest element exists.

View 2 more answers
right arrow
TCS Software Engineer Interview Questions and Answers for Freshers
illustration image

Q3. What is the reason that the Iterative Waterfall model was introduced?

Ans.

Iterative Waterfall model was introduced to address the limitations of the traditional Waterfall model.

  • Iterative Waterfall model allows for feedback and changes during the development process.

  • It breaks down the development process into smaller, more manageable stages.

  • It reduces the risk of project failure by identifying and addressing issues early on.

  • It allows for better collaboration between developers and stakeholders.

  • Examples include Rational Unified Process (RUP) and Agil...read more

View 8 more answers
right arrow

Q4. Can you describe a challenging technical problem you faced and how you solve it ?

Ans.

Developing a real-time chat application with high scalability and low latency.

  • Designing a distributed architecture to handle a large number of concurrent users.

  • Implementing efficient data synchronization between multiple servers.

  • Optimizing network communication to minimize latency.

  • Ensuring data consistency and reliability in a distributed environment.

View 19 more answers
right arrow
Discover TCS interview dos and don'ts from real experiences

Q5. Water Jug Problem Statement

You have two water jugs with capacities X and Y liters respectively, both initially empty. You also have an infinite water supply. The goal is to determine if it is possible to measu...read more

Ans.

The Water Jug Problem involves determining if a specific amount of water can be measured using two jugs of different capacities.

  • Start by considering the constraints and limitations of the problem.

  • Think about how the operations allowed can be used to reach the target measurement.

  • Consider different scenarios and test cases to come up with a solution.

  • Implement a function that takes the capacities of the jugs and the target measurement as input and returns True or False based on ...read more

Add your answer
right arrow

Q6. Write a program for Fibonacci series for n terms where n is the user input.

Ans.

Program for Fibonacci series for n terms with user input.

  • Take user input for n

  • Initialize variables for first two terms of Fibonacci series

  • Use a loop to generate the series up to n terms

  • Print the series

View 5 more answers
right arrow
Are these interview questions helpful?

Q7. How do you stay up to date with emerging technologies and programming language ?

Ans.

I stay up to date with emerging technologies and programming languages through various methods.

  • I regularly read tech blogs and news websites to stay informed about the latest trends and advancements.

  • I participate in online forums and communities where developers discuss new technologies and share their experiences.

  • I attend conferences, workshops, and webinars to learn from industry experts and network with other professionals.

  • I take online courses and tutorials to enhance my ...read more

View 8 more answers
right arrow

Q8. Matrix Multiplication Task

Given two sparse matrices MAT1 and MAT2 of integers with dimensions 'N' x 'M' and 'M' x 'P' respectively, the goal is to determine the resulting matrix produced by their multiplicatio...read more

Ans.

Implement a function to multiply two sparse matrices and return the resulting matrix.

  • Create a function that takes two sparse matrices as input and returns the resulting matrix after multiplication.

  • Iterate through the non-zero elements of the matrices to perform the multiplication efficiently.

  • Ensure to handle the sparse nature of the matrices to optimize the multiplication process.

  • Consider the constraints provided to ensure the function works within the specified limits.

  • Test t...read more

Add your answer
right arrow
Share interview questions and help millions of jobseekers 🌟
man with laptop
Q9. ...read more

Chocolate Distribution Problem

Given an array or list of integers called 'CHOCOLATES', representing the number of chocolates in each packet, your task is to distribute these packets among 'M' students so that:

Ans.

Distribute chocolates among students to minimize the difference between the maximum and minimum chocolates.

  • Sort the array of chocolates packets.

  • Use sliding window technique to find the minimum difference between the maximum and minimum chocolates distributed to students.

  • Consider edge cases like when the number of students is equal to the number of packets.

View 1 answer
right arrow

Q10. Leap Year Checker

Determine if a given year, represented as an integer 'N', is a leap year.

A leap year is defined as a year with 366 days, unlike a normal year which has 365 days.

Input:

The initial input line...read more
Ans.

The task is to determine if a given year is a leap year or not.

  • Check if the year is divisible by 4, if yes then proceed to the next step.

  • If the year is divisible by 100, then it should also be divisible by 400 to be a leap year.

  • If the year satisfies the above conditions, output 'Yes', else output 'No'.

View 1 answer
right arrow

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

ArrayList 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

Add your answer
right arrow

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

Checked 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

Add your answer
right arrow

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

Immutability 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

Add your answer
right arrow

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

Singleton 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.

Add your answer
right arrow

Q15. What are the uses of OOPS?

Ans.

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.

View 6 more answers
right arrow

Q16. What is digital communication and analogue communication. What's the difference between both of them?

Ans.

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

View 1 answer
right arrow

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

ReentrantLock 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

Add your answer
right arrow

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

In 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

Add your answer
right arrow

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

The 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

Add your answer
right arrow

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

Java 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

Add your answer
right arrow

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

Garbage 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

Add your answer
right arrow

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

Lambda 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.

Add your answer
right arrow

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

Method 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

Add your answer
right arrow

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

Functional 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

Add your answer
right arrow

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

final, 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

Add your answer
right arrow

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

Java 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

Add your answer
right arrow

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

Java 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

Add your answer
right arrow

Q28. What is an Agile Model?

Ans.

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)

View 5 more answers
right arrow

Q29. What is class and object tell the difference

Ans.

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

View 3 more answers
right arrow

Q30. What is the difference between runtime and compile time error.

Ans.

Runtime errors occur during program execution, while compile-time errors occur during compilation.

  • Compile-time errors are detected by the compiler and prevent the program from running.

  • Runtime errors occur when the program is running and can cause it to crash or behave unexpectedly.

  • Examples of compile-time errors include syntax errors and type errors.

  • Examples of runtime errors include null pointer exceptions and division by zero errors.

View 2 more answers
right arrow

Q31. What set in java and what is difference between hash set and map

Ans.

Set is a collection interface in Java. HashSet and HashMap are two different implementations of Set.

  • Set is an interface that extends Collection interface.

  • HashSet is an implementation of Set that uses a hash table to store elements.

  • HashMap is an implementation of Map that uses a hash table to store key-value pairs.

  • HashSet does not allow duplicate elements while HashMap allows duplicate values but not duplicate keys.

  • HashSet uses only one object to store elements while HashMap u...read more

Add your answer
right arrow

Q32. Write a program to swap two numbers without using third variable

Ans.

Program to swap two numbers without using third variable

  • Use the XOR operation to swap the numbers

  • Assign the first number to the second number using XOR

  • Assign the second number to the first number using XOR

View 4 more answers
right arrow

Q33. What is a Waterfall Model?

Ans.

Waterfall Model is a linear sequential approach to software development.

  • It follows a sequential process where each phase must be completed before moving to the next.

  • It is a rigid model and changes cannot be made once a phase is completed.

  • It is suitable for projects with well-defined requirements and a stable scope.

  • Examples of industries that use this model are construction and manufacturing.

  • Phases include requirements gathering, design, implementation, testing, deployment, an...read more

View 2 more answers
right arrow

Q34. What is rest API and how we achieve it? When we are using spring boot then which annotation first we use during create controller? What is flow of create spring MVC projecf

Ans.

Explanation of REST API, Spring Boot controller annotation, and Spring MVC project flow.

  • REST API is a web service that uses HTTP requests to GET, POST, PUT, and DELETE data.

  • To achieve it, we need to define endpoints, HTTP methods, and data formats.

  • In Spring Boot, we use the @RestController annotation to create a controller.

  • The @RequestMapping annotation is used to map HTTP requests to methods.

  • The flow of creating a Spring MVC project involves defining a model, view, and contr...read more

Add your answer
right arrow

Q35. How C++ makes coding easy in comparison to C programming ?

Ans.

C++ provides object-oriented programming and better memory management than C.

  • C++ supports classes and objects which makes code modular and reusable.

  • C++ has better memory management with features like constructors and destructors.

  • C++ supports function overloading and operator overloading which makes code more readable.

  • C++ has a rich library of built-in functions and data types.

  • C++ supports exception handling which makes code more robust.

  • Example: In C, memory allocation and dea...read more

Add your answer
right arrow

Q36. What is difference between micro-processor and micro controller ? What is 555 IC ? (Because, I am form E&C field)

Ans.

Micro-processor and micro-controller differ in their architecture and usage. 555 IC is a timer IC used in electronic circuits.

  • Micro-processor is a CPU with minimal peripherals while micro-controller has CPU, memory, and peripherals on a single chip.

  • Micro-processor is used in applications that require high processing power while micro-controller is used in embedded systems.

  • 555 IC is a timer IC that can be used in various electronic circuits like oscillators, pulse generators, ...read more

Add your answer
right arrow

Q37. What is difference between C and C++ programming ?

Ans.

C++ is an extension of C programming language with added features like object-oriented programming.

  • C++ supports object-oriented programming while C does not.

  • C++ has classes and objects while C does not.

  • C++ has function overloading and operator overloading while C does not.

  • C++ has exception handling while C does not.

  • C++ supports namespaces while C does not.

View 1 answer
right arrow

Q38. what is flat map? and what is intermediate operations

Ans.

Flat map is a method in Java 8 streams that maps each element to a stream and flattens the result into a single stream.

  • Flat map is used to transform a stream of collections or arrays into a single stream of elements.

  • It is an intermediate operation that can be used with other intermediate operations like filter and map.

  • Example: Stream> stream = Stream.of(Arrays.asList(1, 2), Arrays.asList(3, 4)); stream.flatMap(Collection::stream).forEach(System.out::println);

  • Intermediate oper...read more

View 1 answer
right arrow

Q39. 1 cake has to cut in 8 pieces by three cuts

Ans.

Cut a cake into 8 pieces with 3 cuts.

  • Make two perpendicular cuts through the center of the cake, dividing it into quarters.

  • Make a third cut horizontally through the middle of the cake, dividing each quarter into two pieces.

  • Each quarter will now be divided into two pieces, resulting in 8 total pieces.

View 2 more answers
right arrow

Q40. Write a program for palindromes of a number.

Ans.

Program to check if a number is a palindrome or not.

  • Convert the number to a string

  • Reverse the string

  • Compare the original string with the reversed string

  • If they are equal, the number is a palindrome

View 2 more answers
right arrow

Q41. what is difference between method overloading and method overriding?

Ans.

Method overloading is having multiple methods with the same name but different parameters. Method overriding is having a subclass method with the same name and parameters as a superclass method.

  • Method overloading is used to provide different ways of calling the same method with different parameters.

  • Method overriding is used to provide a specific implementation of a method in a subclass that is already defined in a superclass.

  • Method overloading is resolved at compile-time base...read more

View 1 answer
right arrow

Q42. Use 3l contaner 2 times and pour the milk in 5l container now you have 1l milk afyer that empty 5l container and put 1l milk in 5l container and add 3l milk by using 3l container and gove him 4 l milk

Ans.

Transfer milk between containers to get 4l in 5l container using 3l container twice.

  • Use 3l container to fill 5l container with 1l milk

  • Empty 5l container and put 1l milk in it

  • Use 3l container to fill 5l container with 3l milk

  • Total milk in 5l container is now 4l

Add your answer
right arrow

Q43. Hashmap duplicate values allowed or not how to store value

Ans.

Hashmap allows duplicate values and stores them using separate chaining or open addressing.

  • Duplicate values are allowed in Hashmap as long as they have different keys.

  • Hashmap stores values using separate chaining or open addressing.

  • In separate chaining, values with the same hash code are stored in a linked list.

  • In open addressing, values are stored in the next available slot in the array.

  • To retrieve a value, the key is hashed and the corresponding slot is checked for the valu...read more

Add your answer
right arrow

Q44. Why joins needed what is criteria to join two tables

Ans.

Joins are used to combine data from two or more tables based on a common column.

  • Joins are used to retrieve data from multiple tables in a single query.

  • The criteria to join two tables is a common column or key between them.

  • Types of joins include inner join, left join, right join, and full outer join.

  • Inner join returns only the matching rows from both tables.

  • Left join returns all the rows from the left table and matching rows from the right table.

  • Right join returns all the rows...read more

Add your answer
right arrow

Q45. Differentiate between Cl & SI Engine? Which one of them is More efficient?

Ans.

Cl engine uses spark plugs while SI engine uses compression to ignite fuel. SI engine is more efficient.

  • Cl engine uses spark plugs to ignite fuel while SI engine uses compression

  • SI engine is more efficient due to higher compression ratio

  • Examples of Cl engines include diesel engines while SI engines include gasoline engines

Add your answer
right arrow

Q46. How would you rate your C programming skill on a level of 0-5?

Ans.

4

  • Extensive experience in C programming

  • Proficient in writing efficient and optimized code

  • Familiar with memory management and pointers

  • Comfortable with low-level programming and system-level development

Add your answer
right arrow

Q47. if length of rectangle increases by 20% then increased in area?

Ans.

If length of rectangle increases by 20%, the area increases by 44%.

  • Calculate the new length and width using the percentage increase formula

  • Calculate the new area using the formula: new area = (new length) * (new width)

  • Example: If length = 10 and width = 5, new length = 12 and new width = 5, new area = 60 * 1.2 = 72

Add your answer
right arrow

Q48. fibonaci series, how to find the even and odd numbers from given numbers?

Ans.

To find even and odd numbers from a given series, iterate through the series and check if each number is divisible by 2.

  • Iterate through the given series of numbers

  • For each number, check if it is divisible by 2

  • If the number is divisible by 2, it is even; otherwise, it is odd

Add your answer
right arrow

Q49. Write the program how you can implement basic concepts of oops

Ans.

Program implementing basic OOP concepts

  • Create classes with properties and methods

  • Encapsulate data to restrict access

  • Inherit properties and methods from parent classes

  • Polymorphism to allow objects to take on multiple forms

Add your answer
right arrow

Q50. Explain the difference between ArrayList and LinkedList in Java. When would you choose one over the other?

Ans.

ArrayList and LinkedList are both classes in Java used to store and manipulate collections of data. ArrayList uses an array to store elements, while LinkedList uses a doubly linked list.

  • ArrayList is faster for accessing elements by index, while LinkedList is faster for adding or removing elements in the middle of the list.

  • ArrayList uses more memory as it needs to allocate space for the entire list upfront, while LinkedList only needs memory for each element and the pointers t...read more

Add your answer
right arrow

Q51. What is a Java Stream, and how does it differ from an Iterator? Explain how Streams can be used to process collections efficiently.

Ans.

Java Stream is a sequence of elements that supports functional-style operations. It differs from Iterator by allowing for more concise and declarative code.

  • Streams are designed to allow for functional-style operations on collections, such as map, filter, and reduce.

  • Streams do not store elements, they operate on the source data structure (e.g., List) directly.

  • Iterators are used to sequentially access elements in a collection, while Streams allow for parallel processing.

  • Streams...read more

Add your answer
right arrow

Q52. Explain the concept of immutability in Java. How does the String class achieve immutability, and what are the advantages of immutable objects?

Ans.

Immutability in Java means objects cannot be modified after creation. String class achieves immutability by not allowing changes to its value.

  • String class in Java is immutable because once a String object is created, its value cannot be changed.

  • Any operation that appears to modify a String actually creates a new String object with the modified value.

  • Advantages of immutable objects include thread safety, caching, and easier debugging.

Add your answer
right arrow

Q53. What is the difference between final, finally, and finalize in Java? Provide examples to illustrate their usage.

Ans.

final, finally, and finalize have different meanings in Java.

  • final is a keyword used to declare constants, prevent method overriding, and prevent inheritance.

  • finally is a block used in exception handling to execute code after try-catch block.

  • finalize is a method used for cleanup operations before an object is garbage collected.

Add your answer
right arrow

Q54. Explain the Singleton design pattern in Java. How can you implement it safely to ensure thread safety?

Ans.

Singleton design pattern ensures a class has only one instance and provides a global point of access to it.

  • Create a private static instance of the class.

  • Make the constructor private to prevent instantiation from outside the class.

  • Provide a public static method to access the instance, creating it if necessary.

  • Use synchronized keyword or double-checked locking to ensure thread safety.

Add your answer
right arrow

Q55. Can you explain the difference between method overloading and method overriding in Java? Provide examples where each should be used.

Ans.

Method overloading involves creating multiple methods in the same class with the same name but different parameters. Method overriding involves creating a new implementation of a method in a subclass.

  • Method overloading is used to provide different implementations of a method based on the number or type of parameters. Example: public void print(int num) and public void print(String str)

  • Method overriding is used to provide a specific implementation of a method in a subclass tha...read more

Add your answer
right arrow

Q56. What are Java annotations, and how are they used in frameworks like Spring? Explain the difference between built-in and custom annotations.

Ans.

Java annotations are metadata that provide data about a program but do not affect the program itself. They are used in frameworks like Spring to configure and customize behavior.

  • Java annotations are used to provide metadata about a program, such as information about classes, methods, or fields.

  • In frameworks like Spring, annotations are used to configure various aspects of the application, such as dependency injection, transaction management, and request mapping.

  • Built-in annot...read more

Add your answer
right arrow

Q57. You have 2 containers one is 5l capacity and second one is 3l capacity by using this you have to give 4 liter milk

Ans.

Use the 5l container to fill the 3l container, then pour it out and fill it again. Pour the excess into the 3l container and repeat.

  • Fill 5l container and pour into 3l container

  • Empty 3l container and pour remaining 2l from 5l container

  • Fill 5l container again and pour 1l into 3l container to get 4l

  • Final state: 5l container has 4l, 3l container has 0l

Add your answer
right arrow

Q58. What is java and database management system?

Ans.

Java is a programming language and DBMS is a software for managing databases.

  • Java is an object-oriented language used for developing applications and software.

  • DBMS is a software system used for creating, managing, and maintaining databases.

  • Java can be used to interact with DBMS to perform database operations.

  • Popular DBMS include MySQL, Oracle, and Microsoft SQL Server.

Add your answer
right arrow

Q59. what is javascript?why we need it ?whats the functionality u used in that

Ans.

JavaScript is a programming language commonly used for web development to add interactivity and dynamic content to websites.

  • JavaScript is a client-side scripting language used to create interactive web pages.

  • It can be used to validate form data, create animations, and dynamically update content without reloading the page.

  • Common functionalities include event handling, DOM manipulation, and AJAX requests.

  • Example: document.getElementById('demo').innerHTML = 'Hello World';

View 1 answer
right arrow

Q60. What are the advantages and disadvantages of using Java’s synchronized keyword for thread synchronization? Can you explain how the ReentrantLock compares to synchronized?

Ans.

Using Java's synchronized keyword for thread synchronization has advantages like simplicity and disadvantages like potential for deadlock. ReentrantLock offers more flexibility and control.

  • Advantages of synchronized keyword: simplicity, built-in support in Java

  • Disadvantages of synchronized keyword: potential for deadlock, lack of flexibility

  • ReentrantLock advantages: more flexibility, ability to try and lock with timeout

  • ReentrantLock disadvantages: more verbose syntax, need to...read more

Add your answer
right arrow

Q61. How does the Java garbage collector work? Can you describe the different types of garbage collection algorithms available in Java?

Ans.

The Java garbage collector automatically manages memory by reclaiming unused objects.

  • The garbage collector in Java runs in the background, periodically checking for objects that are no longer needed.

  • There are different types of garbage collection algorithms in Java, such as Serial, Parallel, CMS, G1, and ZGC.

  • Each algorithm has its own strengths and weaknesses, and is suited for different types of applications and workloads.

Add your answer
right arrow

Q62. What is the Java Memory Model, and how does it affect multithreading and synchronization? How does volatile help ensure memory visibility?

Ans.

The Java Memory Model defines how threads interact through memory and how changes made by one thread are visible to others.

  • Java Memory Model ensures that changes made by one thread are visible to other threads.

  • It defines the behavior of threads in terms of reading and writing to memory.

  • Synchronization in Java ensures that only one thread can access a shared resource at a time.

  • Volatile keyword in Java ensures visibility of changes made by one thread to other threads.

  • Volatile k...read more

Add your answer
right arrow

Q63. How do Java Streams handle parallel processing? What are the potential pitfalls of using parallel streams, and how can they be mitigated?

Ans.

Java Streams can handle parallel processing using parallel streams. Pitfalls include increased complexity and potential for race conditions.

  • Java Streams can be processed in parallel by calling the parallel() method on a stream.

  • Potential pitfalls of using parallel streams include increased complexity, potential for race conditions, and performance overhead.

  • To mitigate these pitfalls, ensure that the operations performed on the stream are stateless and do not have side effects....read more

Add your answer
right arrow

Q64. What is the difference between == and .equals() in Java? When should each be used, and what issues can arise from improper usage?

Ans.

In Java, == compares memory addresses while .equals() compares object contents.

  • Use == to compare primitive data types and object references.

  • Use .equals() to compare object contents, such as strings or custom objects.

  • Improper usage can lead to unexpected results, as == may not always work as expected with objects.

Add your answer
right arrow

Q65. What are the main features of Java 8? Can you explain how lambdas and the Stream API have changed the way Java applications are written?

Ans.

Java 8 introduced features like lambdas and Stream API which have revolutionized the way Java applications are written.

  • Lambdas allow for more concise and readable code by enabling functional programming paradigms.

  • Stream API provides a way to process collections of objects in a functional style, allowing for easier parallel processing and improved performance.

  • Java 8 also introduced default methods in interfaces, allowing for backward compatibility with existing code while stil...read more

Add your answer
right arrow

Q66. What are functional interfaces in Java? How do they work with lambda expressions? Provide an example of a custom functional interface.

Ans.

Functional interfaces in Java are interfaces with a single abstract method. They can be used with lambda expressions for functional programming.

  • Functional interfaces have only one abstract method, but can have multiple default or static methods.

  • Lambda expressions can be used to implement the single abstract method of a functional interface concisely.

  • An example of a custom functional interface is 'Calculator' with a single abstract method 'calculate'.

Add your answer
right arrow

Q67. What is angular . What is the use?

Ans.

Angular is a JavaScript framework for building web applications.

  • Angular is used for creating dynamic, single-page web applications.

  • It provides a structure for organizing code and a set of tools for building complex UIs.

  • Angular uses declarative templates, dependency injection, and two-way data binding to simplify development.

  • Examples of popular websites built with Angular include Gmail, PayPal, and Upwork.

Add your answer
right arrow

Q68. What is a circular queue?

Ans.

A circular queue is a data structure that follows the FIFO (First In First Out) principle, but the last element is connected to the first element.

  • It is also known as a ring buffer.

  • It is useful in situations where the data needs to be accessed in a circular manner.

  • It has a fixed size and can be implemented using an array or a linked list.

  • Insertion and deletion operations are performed at the rear and front ends respectively.

  • Example: CPU scheduling, traffic management, and audi...read more

View 2 more answers
right arrow

Q69. What is it field? It field is nothing but industrial field What is testing Testing is nothing but testing the software

Ans.

IT field refers to the industrial field of technology and software development.

  • IT field encompasses a wide range of industries including software development, hardware engineering, and network administration.

  • IT professionals work to design, develop, and maintain technology systems and software applications.

  • IT is a rapidly growing field with high demand for skilled professionals.

  • Examples of IT jobs include software engineer, network administrator, and cybersecurity analyst.

View 1 answer
right arrow

Q70. What is the difference between SQL drop and truncate?

Ans.

SQL drop is used to delete a table or a database, while truncate is used to delete all the data in a table.

  • DROP command removes the table structure and its data, while TRUNCATE command only removes the data

  • DROP command cannot be rolled back, while TRUNCATE command can be rolled back

  • DROP command is DDL (Data Definition Language), while TRUNCATE command is DML (Data Manipulation Language)

  • DROP command is slower than TRUNCATE command as it involves more operations

Add your answer
right arrow

Q71. What are hooks? name some. Explain useState vs useReducer

Ans.

Hooks are functions that allow you to use state and other React features in functional components. useState and useReducer are two popular hooks.

  • useState is a hook that allows you to add state to a functional component. It returns an array with two values: the current state and a function to update the state.

  • useReducer is a hook that allows you to manage more complex state in a functional component. It returns an array with two values: the current state and a dispatch functio...read more

Add your answer
right arrow

Q72. Describe the differences between checked and unchecked exceptions in Java. Provide examples and explain how to handle them properly.

Ans.

Checked exceptions are checked at compile time, while unchecked exceptions are not. Proper handling involves either catching or declaring the exception.

  • Checked exceptions must be either caught or declared in the method signature using the 'throws' keyword.

  • Unchecked exceptions do not need to be caught or declared, but can still be handled using try-catch blocks.

  • Examples of checked exceptions include IOException and SQLException, while examples of unchecked exceptions include N...read more

Add your answer
right arrow

Q73. What is the difference between an interface and an abstract class in Java?

Ans.

Interface is a contract specifying methods that a class must implement, while abstract class can have both implemented and abstract methods.

  • Interface cannot have method implementations, while abstract class can have both implemented and abstract methods.

  • A class can implement multiple interfaces but can only extend one abstract class.

  • Interfaces are used to achieve multiple inheritance in Java.

  • Abstract classes can have constructors, while interfaces cannot.

  • Example: interface An...read more

Add your answer
right arrow

Q74. How do you implement a stack in Java using an array?

Ans.

Implement a stack in Java using an array

  • Create an array to store the elements of the stack

  • Keep track of the top of the stack using an index variable

  • Implement push() to add elements to the stack

  • Implement pop() to remove elements from the stack

  • Example: String[] stackArray = new String[10];

Add your answer
right arrow

Q75. What is the difference between a HashMap and a TreeMap in Java?

Ans.

HashMap is unordered and uses hashing to store key-value pairs, while TreeMap is ordered and uses a red-black tree to store key-value pairs.

  • HashMap uses hashing to store key-value pairs, allowing for O(1) time complexity for get and put operations.

  • TreeMap uses a red-black tree to store key-value pairs, maintaining order based on the keys.

  • HashMap does not guarantee any specific order of elements, while TreeMap maintains elements in sorted order based on keys.

  • Example: HashMap<S...read more

Add your answer
right arrow

Q76. What is group discussion

Ans.

Group discussion is a collaborative conversation among a group of individuals to exchange ideas, opinions, and perspectives on a specific topic.

  • Group discussion involves multiple participants who actively contribute to the conversation.

  • It encourages open communication, active listening, and respectful debate.

  • The goal is to explore different viewpoints, reach consensus, or gain deeper insights.

  • Group discussions can be structured or unstructured, moderated or unmoderated.

  • Exampl...read more

View 2 more answers
right arrow

Q77. Explain constraints , index ,triggers , standalone procedure and stored procedure

Ans.

Explanation of constraints, indexes, triggers, standalone and stored procedures.

  • Constraints are rules that limit the type of data that can be inserted into a table.

  • Indexes are used to speed up data retrieval by creating a pointer to the data.

  • Triggers are used to automatically execute a set of instructions when a specific event occurs.

  • Standalone procedures are independent procedures that can be executed on their own.

  • Stored procedures are precompiled procedures that can be call...read more

Add your answer
right arrow

Q78. Using MAT Lab , write a program for signal transmission

Ans.

A MATLAB program for signal transmission.

  • Use the 'transmit' function in MATLAB to send signals.

  • Specify the signal to be transmitted and the transmission parameters.

  • Handle any errors or exceptions that may occur during transmission.

  • Test the program with different signals and transmission scenarios.

Add your answer
right arrow

Q79. Self intro Certifications Features of python Why python is dynamic. Pass keyword in python . List and tuple difference.

Ans.

Answering questions related to Python and its features.

  • Python is a high-level programming language known for its simplicity and readability.

  • It supports multiple programming paradigms like object-oriented, functional, and procedural.

  • Python is dynamically typed, which means the data type of a variable is determined at runtime.

  • The 'pass' keyword in Python is used as a placeholder for empty code blocks.

  • Lists and tuples are both used to store collections of data, but lists are mut...read more

Add your answer
right arrow

Q80. How would you explain Database to a child

Ans.

A database is like a big organized collection of information that can be easily accessed and managed.

  • A database is like a digital filing cabinet where information is stored and organized.

  • It helps store and retrieve data quickly and efficiently.

  • Imagine a library where books are organized by categories and you can easily find the book you need.

  • Examples of databases are online shopping websites, social media platforms, and banking systems.

Add your answer
right arrow

Q81. **Explain the difference between a stack and a queue. Can you write code to implement both using an array?**

Ans.

A stack is a Last In First Out (LIFO) data structure, while a queue is a First In First Out (FIFO) data structure.

  • Stack: elements are added and removed from the top of the stack. Example: function call stack.

  • Queue: elements are added at the rear and removed from the front of the queue. Example: waiting line at a store.

  • Code to implement stack using array: push elements to end, pop elements from end.

  • Code to implement queue using array: enqueue elements to end, dequeue elements ...read more

Add your answer
right arrow

Q82. What is inheritance in java

Ans.

Inheritance is a mechanism in Java where a class acquires the properties and methods of another class.

  • Allows code reusability and saves time

  • Parent class is called super class and child class is called sub class

  • Sub class can access all public and protected methods and fields of super class

  • Keyword used for inheritance is 'extends'

  • Example: class B extends A {}

View 4 more answers
right arrow

Q83. Can You manage IT field as you are from Mechanical Engineering? Explain about Cloud Computing. Latest Trend in Mechanical Engineering

Ans.

Yes, I can manage IT field as I have relevant skills. Cloud computing is a technology that allows users to access data and applications over the internet.

  • I have experience in programming languages like Java and Python which are used in IT field

  • I have knowledge of database management systems which are used in cloud computing

  • Cloud computing provides on-demand access to shared computing resources like servers, storage, applications, and services

  • Examples of cloud computing servic...read more

Add your answer
right arrow

Q84. What are the steps to add a number at the end of a linked list?

Ans.

To add a number at the end of a linked list, you need to traverse the list to the last node and then create a new node with the number and link it to the last node.

  • Traverse the linked list to the last node

  • Create a new node with the number

  • Link the new node to the last node's next pointer

Add your answer
right arrow

Q85. What is the round robin algorithim and define the time for it ?

Ans.

Round robin algorithm is a CPU scheduling technique that assigns equal time slices to each process in a circular order.

  • Each process is given a fixed time slice called quantum.

  • After the quantum expires, the process is preempted and added to the end of the ready queue.

  • The next process in the queue is then given a quantum to execute.

  • This continues until all processes have executed.

  • Time complexity is O(n^2) in worst case.

  • Used in multitasking operating systems.

  • Example: A CPU with ...read more

Add your answer
right arrow

Q86. Would you like to explore in other technologies except coding like cloud?

Ans.

Yes, I am open to exploring other technologies like cloud.

  • I have some experience with cloud technologies like AWS and Azure.

  • I am interested in learning more about cloud computing and its applications.

  • I believe that having knowledge of different technologies can make me a more well-rounded engineer.

Add your answer
right arrow

Q87. What is scope? What is decorator? Difference between List and Array Difference between List and Tuple How will you manage Memory in python? Explain Namespace. Latest Technology you know.

Ans.

A set of technical questions related to software engineering.

  • Scope refers to the visibility of a variable in a program.

  • A decorator is a function that takes another function and extends its behavior without modifying it.

  • List is mutable and dynamic, while an array is fixed in size and homogeneous.

  • List and tuple are both ordered collections, but list is mutable while tuple is immutable.

  • Memory management in Python is handled automatically by the interpreter's garbage collector.

  • Na...read more

Add your answer
right arrow

Q88. What is polymorphism in java

Ans.

Polymorphism is the ability of an object to take on many forms.

  • Polymorphism allows objects of different classes to be treated as if they are of the same class.

  • It is achieved through method overriding and method overloading.

  • Example: A parent class Animal can have child classes like Dog, Cat, etc. and all of them can have a method called 'makeSound', but each child class can have a different implementation of the method.

  • Polymorphism helps in achieving code reusability and flexi...read more

View 2 more answers
right arrow

Q89. Why React Native and not Flutter?

Ans.

React Native has a larger community and better support for native modules.

  • React Native has a larger community and better support for native modules.

  • React Native is more mature and stable compared to Flutter.

  • React Native has better performance and faster development time.

  • React Native is easier to learn for developers who are already familiar with React.

  • React Native has better integration with third-party libraries and tools.

Add your answer
right arrow

Q90. how good are you at maths? Reverse your pincode

Ans.

The question is irrelevant to the job and does not reflect my mathematical abilities.

  • The question is not related to the job requirements

  • Reverse pincode can be done by anyone regardless of their math skills

  • Math skills required for software engineering are different from basic arithmetic

  • Examples of relevant math skills include algorithms, data structures, and logic

Add your answer
right arrow

Q91. What is arraylist and linkedlist in java

Ans.

ArrayList and LinkedList are two types of collections in Java used to store and manipulate data.

  • ArrayList is a resizable array implementation that allows fast random access and iteration.

  • LinkedList is a doubly linked list implementation that allows fast insertion and deletion at any position.

  • ArrayList is better for accessing elements frequently, while LinkedList is better for frequent insertion and deletion.

  • Both implement the List interface and allow duplicates and null value...read more

Add your answer
right arrow

Q92. What is prpc . And how many years you worked as pega developer

Ans.

PRPC stands for Pega Rules Process Commander, a software platform for building and managing business applications.

  • PRPC is a platform used for developing and managing business applications.

  • It is commonly used in the field of BPM (Business Process Management) and CRM (Customer Relationship Management).

  • I have worked as a Pega developer for 3 years, specializing in PRPC development.

Add your answer
right arrow

Q93. what is interface and how it is implemented with selenium java

Ans.

An interface in Java is a reference type, similar to a class, that can contain only constants, method signatures, default methods, static methods, and nested types.

  • Interfaces in Java are used to achieve abstraction and multiple inheritance.

  • In Selenium Java, interfaces can be implemented using the 'implements' keyword.

  • For example, the WebDriver interface in Selenium Java is implemented by classes like ChromeDriver, FirefoxDriver, etc.

Add your answer
right arrow

Q94. What is JIT in java and it's importance?

Ans.

JIT stands for Just-In-Time compiler in Java. It is important for improving the performance of Java applications.

  • JIT compiles Java bytecode into native machine code at runtime

  • It optimizes frequently executed code segments for faster execution

  • JIT reduces the startup time of Java applications

  • Examples of JIT compilers in Java include HotSpot and JRockit

Add your answer
right arrow

Q95. What specific topics related to Python were you asked about?

Ans.

Topics related to Python discussed in the interview

  • Data structures in Python (lists, dictionaries, tuples)

  • Object-oriented programming concepts in Python (classes, inheritance, polymorphism)

  • Exception handling in Python

  • Python libraries and frameworks (e.g. NumPy, Pandas, Django)

  • Pythonic coding practices and best practices

Add your answer
right arrow

Q96. what are the datatypes in java

Ans.

Java has eight primitive datatypes and reference types.

  • Java has eight primitive datatypes: byte, short, int, long, float, double, char, and boolean.

  • Reference types include classes, interfaces, arrays, and enums.

  • Primitive datatypes are passed by value, while reference types are passed by reference.

  • Autoboxing and unboxing allow primitive datatypes to be used as reference types and vice versa.

Add your answer
right arrow

Q97. what are the datatypes in python

Ans.

Python has several built-in datatypes including integers, floats, strings, booleans, lists, tuples, and dictionaries.

  • Integers are whole numbers without decimals

  • Floats are numbers with decimals

  • Strings are sequences of characters

  • Booleans are either True or False

  • Lists are ordered collections of items

  • Tuples are ordered, immutable collections of items

  • Dictionaries are unordered collections of key-value pairs

View 2 more answers
right arrow

Q98. Different between having clause and where clause

Ans.

Having clause is used with aggregate functions while where clause is used with non-aggregate functions.

  • Having clause filters the results of aggregate functions based on a condition

  • Where clause filters the results of non-aggregate functions based on a condition

  • Having clause is used after the group by clause

  • Where clause is used before the group by clause

  • Example: SELECT department, AVG(salary) FROM employees GROUP BY department HAVING AVG(salary) > 50000;

  • Example: SELECT * FROM e...read more

Add your answer
right arrow

Q99. What is Greedy algorithms and what are its types?

Ans.

Greedy algorithms are algorithms that make the most optimal choice at each step with the hope of finding a global optimum.

  • Greedy algorithms are used for optimization problems where we need to make a sequence of choices to reach a solution.

  • Types of greedy algorithms include Prim's algorithm for minimum spanning tree, Dijkstra's algorithm for shortest path, and Huffman coding for data compression.

  • Greedy algorithms do not always guarantee an optimal solution, but they are often ...read more

Add your answer
right arrow

Q100. What is the difference between list and tuple?

Ans.

List is mutable while tuple is immutable.

  • List can be modified while tuple cannot be modified once created.

  • List uses square brackets [] while tuple uses parentheses ().

  • List is slower than tuple in terms of iteration and indexing.

  • List is used for collections of homogeneous items while tuple is used for heterogeneous items.

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

Interview Process at TCS Software Engineer

based on 276 interviews
5 Interview rounds
Technical Round - 1
Technical Round - 2
HR Round - 1
HR Round - 2
Personal Interview1 Round
View more
interview tips and stories logo
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Software Engineer Interview Questions from Similar Companies

HCLTech Logo
3.5
 • 164 Interview Questions
Walmart Logo
3.8
 • 15 Interview Questions
Yodlee Logo
3.8
 • 13 Interview Questions
Jio Logo
3.9
 • 10 Interview Questions
View all
Recently Viewed
JOBS
Browse jobs
Discover jobs you love
JOBS
Browse jobs
Discover jobs you love
DESIGNATION
INTERVIEWS
Infosys
No Interviews
SALARIES
Genpact
SALARIES
Sutherland Global Services
DESIGNATION
INTERVIEWS
Infosys
No Interviews
SALARIES
Hewlett Packard Enterprise
INTERVIEWS
Infosys
No Interviews
Share an Interview
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
70 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions

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

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