Tech Mahindra Interview Preparation and Recruitment Process


About Tech Mahindra


Tech Mahindra is a leading Indian multinational IT services and consulting company, headquartered in Pune, Maharashtra. Established in 1986 as a joint venture between Mahindra & Mahindra and British Telecom, it has evolved into a global technology powerhouse.

Tech Mahindra Interview Preparation


Company Overview

  • Founded: October 24, 1986

  • Headquarters: Pune, India

  • Chairman: Anand Mahindra

  • CEO & MD: Mohit Joshi (since December 2023)

  • Employees: Approximately 154,000 (as of March 2025)

  • Global Presence: Operations in over 90 countries, serving more than 1,100 clients

  • Parent Company: Mahindra Group

Tech Mahindra offers a wide range of services, including IT consulting, enterprise applications, business process services, engineering services, network services, customer experience & design, AI & analytics, and cloud & infrastructure services.


Financial Highlights

  • Revenue (2023): Approximately USD 6.3 billion

  • Market Capitalization: Around USD 16.1 billion

  • Stock Listings: Listed on NSE (TECHM) and BSE

Tech Mahindra is recognized as one of India's top five IT firms and is a constituent of major stock indices like BSE SENSEX and NSE NIFTY 50.


Global Presence and Clients

With operations spanning over 90 countries, Tech Mahindra has established a significant presence across North America, Europe, Asia-Pacific, and the Middle East. Its client portfolio includes industry giants like AT&T, BMW, and HSBC. The company also partners with leading technology providers such as Microsoft, AWS, and Google Cloud to enhance its service delivery capabilities.


Strategic Acquisitions

Tech Mahindra has expanded its capabilities and market reach through several strategic acquisitions:

  • Satyam Computer Services (2009): This acquisition significantly bolstered Tech Mahindra's IT services portfolio and global presence.

  • Lightbridge Communications Corporation (2014): Enhanced network services capabilities, providing end-to-end services for mobile and fixed-line telecom networks globally.

  • DigitalOnUs (2021): Strengthened hybrid-cloud offerings and cloud-native development capabilities.


Corporate Social Responsibility


The Tech Mahindra Foundation, established in 2006, focuses on education, employability, and inclusion. It has trained over 156,000 youth, supported 48,000 teachers, and benefited 166,000 children. The foundation aligns its initiatives with the United Nations Sustainable Development Goals (SDGs).

Additionally, the company's 3-4-3 Initiative encourages employees to plant 3 trees, take 4 carpools, and dedicate 3 hours to volunteering, promoting sustainability and community engagement.


Future Outlook

Under the leadership of CEO Mohit Joshi, Tech Mahindra aims to increase its focus on the banking, financial services, and insurance (BFSI) sector. The company plans to boost its revenue share in this segment to up to 25% by March 2027 from the current 16%. Joshi emphasizes the importance of aggressively participating in the BFSI sector, where large banks spend substantially on technology. 



Tech Mahindra Recruitment Process


Tech Mahindra's recruitment process for freshers in 2025 is structured to evaluate candidates across multiple competencies, ensuring a comprehensive assessment of both technical and interpersonal skills. Here's a detailed breakdown:​


Eligibility Criteria

  • Education: B.E./B.Tech (any discipline), M.Sc (CS/IT), or MCA.

  • Academic Performance: Minimum 60% in 10th, 12th, and graduation.

  • Backlogs: No active backlogs at the time of application.

  • Gap Years: Maximum of one year allowed between academic milestones.

  • Graduation Year: 2023 or 2024.



Recruitment Process Overview

The selection process typically comprises the following stages:

  1. Online Assessment Test:

    • Aptitude Section: Evaluates quantitative, logical, and verbal reasoning skills.

    • English Essay Writing: Assesses written communication and coherence.

    • Technical Test: Covers programming concepts, data structures, and algorithms.

  2. Psychometric Test (Optional):

    • A non-elimination round with approximately 80 questions to be completed in 20–30 minutes, focusing on work behavior and personality traits.

  3. Technical Written Test:

    • Involves code optimization tasks and questions on data structures, algorithms, SQL, and puzzles.

  4. Technical Interview:

    • Assesses understanding of computer science fundamentals, including operating systems, networking, object-oriented programming, and preferred programming languages like Java or Python.

  5. HR Interview:

    • Evaluates communication skills, cultural fit, and situational responses.

  6. Offer and Onboarding:

    • Successful candidates receive offer letters and onboarding details via email.


Compensation and Opportunities

  • Associate Software Engineer: CTC of ₹3.25 LPA.

  • Supercoder Role: Candidates excelling in the Supercoder challenge may receive a CTC of ₹5.5 LPA.


Application Process

  1. Visit the Tech Mahindra Careers Portal.

  2. Explore job listings and select roles aligning with your skills.

  3. Apply online by submitting your updated resume and necessary details.

  4. Monitor your application status through the portal.



Tech Mahindra Interview Questions :

1 .
Explain the difference between call by reference and call by value?
Before moving forward to look at the differences between call by reference and call by value, let us know the definitions of them:

Call by Reference: Here, both the formal and actual parameters relate to the same place; thus, any modifications made within the function are mirrored in the actual parameters of the caller.

Call by Value: The principles of actual parameters are transferred to the formal parameters in this parameter passing method, and two kinds of parameters are kept in distinct memory locations. Consequently, any modifications performed within functions are not mirrored in the actual parameters passed to the caller.

Let's now examine the difference between Call by Reference and Call by Value.

Call by Reference

Call by Value

The addresses of the real variables of the calling function are transferred into the fake variables of the caller function.

The value of every variable in the calling function is moved into the corresponding dummy variables of the called function.

Because the addresses of the real variables of the calling function are supplied to the called function, any modifications done to the variables in the call function are mirrored in the calling function's variables.

Modifications to the called function's dummy variables have no effect on the actual variables' values in the calling function when using Call by Value. 

We may modify the real values of variables by using function calls.

We cannot modify the values of real variables using function calls.

2 .
Please list a few OOP (Object-Oriented Programming) languages.
The following are some Object-Oriented Programming languages:

* Java
* C++
* Python
* JavaScript
* PHP
3 .
Explain inline functions in C++ and C. Give an example of an inline function in C as well.
Inline Functions in C++ and C
What is an inline function?
  • An inline function is a function where the function call is replaced with the function code itself during compile time.

  • Instead of performing a regular function call (which involves overhead like pushing arguments onto the stack), the compiler inserts the actual code at the place where the function is called.

  • Purpose: To reduce the overhead of function calls, making execution faster, especially for small, frequently called functions.


Inline Function in C++

In C++, you explicitly use the inline keyword when defining a function:

#include <iostream>
using namespace std;

// Inline function
inline int add(int a, int b) {
    return a + b;
}

int main() {
    cout << "Sum = " << add(5, 10) << endl;
    return 0;
}

* Explanation:

  • When you call add(5, 10), the compiler replaces it directly with 5 + 10 during compilation.


Inline Function in C

In C, inline functions were introduced in C99 standard.
Before C99, C didn't officially support inline, but now you can use it like this:

#include <stdio.h>

// Inline function
inline int multiply(int a, int b) {
    return a * b;
}

int main() {
    int result = multiply(4, 5);
    printf("Product = %d\n", result);
    return 0;
}

* Explanation:

  • Here, multiply(4, 5) will be replaced at compile time with the multiplication logic 4 * 5, avoiding a real function call.


Important Points
Feature C++ C
Introduced Always available Introduced in C99
Syntax inline keyword inline keyword
Function Definition Typically in header files Sometimes needs static inline for cross-file usage
Objective Reduce function call overhead Same

Note:
  • Inline is just a request to the compiler; the compiler may ignore it if it thinks it's not efficient to inline.

  • Large functions are usually not inlined because it would increase the size of the binary (code bloat).

4 .
What are C++ Destructors? Also, pen down the C++ syntax for a destructor.

The world of object lifecycle in C++! Destructors are special member functions in C++ classes that play a crucial role in cleaning up resources when an object is no longer needed. Think of constructors as the "birth" of an object, and destructors as its "farewell."

Here's a breakdown of what makes destructors important:

Purpose of C++ Destructors:

  • Resource Deallocation: The primary job of a destructor is to release any resources that the object acquired during its lifetime. This can include:
    • Dynamically allocated memory (using new).
    • Open files.
    • Network connections.
    • Acquired locks or handles to system resources.
  • Performing Cleanup Operations: Beyond deallocation, destructors can execute any other necessary cleanup tasks before an object is destroyed. This might involve saving state, logging information, or notifying other objects.
  • Automatic Invocation: Unlike regular member functions that you need to call explicitly, destructors are automatically called by the compiler in the following situations:
    • When a local object goes out of scope.
    • When a dynamically allocated object is deleted using the delete operator.
    • When a temporary object's lifetime ends.
    • During stack unwinding in exception handling.

Key Characteristics of Destructors:

  • Name: A destructor has the same name as the class, but it is preceded by a tilde (~). For a class named MyClass, the destructor would be named ~MyClass().
  • No Arguments: Destructors cannot take any arguments (parameters).
  • No Return Type: Destructors do not have a return type, not even void.
  • Uniqueness: A class can have only one destructor.
  • Virtual Destructors (Important for Inheritance): In inheritance hierarchies, especially when you delete a derived class object through a base class pointer, it's crucial to declare the base class's destructor as virtual. This ensures that the correct destructor (the derived class's destructor) is called, preventing potential resource leaks and undefined behavior.

C++ Syntax for a Destructor:

class MyClass {
public:
    // Constructor (optional)
    MyClass() {
        // Initialization code
    }

    // ... other member variables and functions ...

    // Destructor
    ~MyClass() {
        // Cleanup code goes here
        // For example:
        // delete somePointer;
        // close(fileDescriptor);
        // ...
    }
};


Example Illustrating Destructor Usage:

#include <iostream>

class MyResource {
private:
    int* data;

public:
    MyResource() {
        std::cout << "Constructor called for MyResource." << std::endl;
        data = new int[10]; // Allocate some dynamic memory
    }

    ~MyResource() {
        std::cout << "Destructor called for MyResource." << std::endl;
        delete[] data;      // Release the dynamically allocated memory
        data = nullptr;
    }

    void setValue(int index, int value) {
        if (index >= 0 && index < 10) {
            data[index] = value;
        }
    }

    int getValue(int index) const {
        if (index >= 0 && index < 10) {
            return data[index];
        }
        return -1; // Indicate an error
    }
};

int main() {
    {
        std::cout << "Entering inner scope." << std::endl;
        MyResource obj1; // Constructor is called when obj1 is created
        obj1.setValue(0, 100);
        std::cout << "Value in obj1: " << obj1.getValue(0) << std::endl;
    } // Destructor for obj1 is automatically called when it goes out of scope
    std::cout << "Exiting inner scope." << std::endl;

    MyResource* obj2 = new MyResource(); // Constructor is called
    obj2->setValue(1, 200);
    std::cout << "Value in obj2: " << obj2->getValue(1) << std::endl;
    delete obj2; // Destructor for obj2 is explicitly called using delete
    obj2 = nullptr;

    return 0;
}

Output of the Example:

Entering inner scope.
Constructor called for MyResource.
Value in obj1: 100
Destructor called for MyResource.
Exiting inner scope.
Constructor called for MyResource.
Value in obj2: 200
Destructor called for MyResource.

As you can see from the output, the destructors are automatically invoked when the MyResource objects go out of scope or are explicitly deleted using delete. This ensures that the dynamically allocated memory is properly released, preventing memory leaks.

 

 

5 .
Explain the core OOP concepts in Java.
Java follows the object-oriented programming (OOP) paradigm, which includes four key concepts. Encapsulation ensures data hiding by restricting direct access to variables through private access modifiers and getters/setters. Inheritance allows a child class to acquire properties and behaviors from a parent class, promoting code reuse. Polymorphism enables the same method to behave differently based on the object that invokes it, implemented through method overloading and method overriding. Abstraction hides the implementation details of a class and exposes only necessary functionalities using abstract classes or interfaces.
6 .
What is the difference between an abstract class and an interface in Java?
An abstract class in Java can have both abstract (methods without a body) and concrete methods (methods with implementation). It allows partial implementation of functionalities that subclasses can extend. An interface, on the other hand, defines only method signatures (before Java 8) and does not contain implementation. It is used to achieve complete abstraction and multiple inheritance. Java 8 introduced default and static methods in interfaces, allowing some level of implementation. Unlike abstract classes, interfaces support multiple inheritance, making them a preferred choice in large-scale applications.
7 .
What is a deadlock in operating systems?
A deadlock is a situation in operating systems where two or more processes are stuck in a state of indefinite waiting because each is holding a resource that the other needs. Deadlocks occur due to four conditions: mutual exclusion (only one process can use a resource at a time), hold and wait (processes holding resources can request additional resources), no preemption (resources cannot be forcibly taken away), and circular wait (a set of processes form a cycle where each process waits for a resource held by another process in the cycle). Deadlocks can be avoided by using resource allocation strategies like deadlock prevention, avoidance (Banker’s algorithm), or detection and recovery.
8 .
What is a memory leak in C++?
A memory leak occurs in C++ when dynamically allocated memory is not deallocated, leading to increased memory usage and potential system crashes. This usually happens when a program allocates memory using the new keyword but fails to release it using delete. For example:
void memoryLeak() {
int* ptr = new int(10); // Allocating memory
// No delete statement, leading to a memory leak
}​

To prevent memory leaks, it is essential to explicitly deallocate memory using delete ptr; or use smart pointers like std::unique_ptr and std::shared_ptr in modern C++.
9 .
What is Agile methodology?
Agile is a software development methodology that emphasizes iterative progress, collaboration, and customer feedback. It follows principles from the Agile Manifesto, focusing on flexibility and incremental delivery. One of the most popular Agile frameworks is Scrum, which divides development into time-boxed iterations called sprints (usually 1-4 weeks long). Agile promotes daily stand-up meetings for team coordination and continuous integration to ensure faster software development. Agile methodologies like Scrum and Kanban improve project adaptability and team collaboration, making them widely used in IT industries.
10 .
What is the difference between a stack and a queue?
A stack is a data structure that follows the Last In, First Out (LIFO) principle, meaning the last element added is the first one to be removed. It is used in applications like function calls (call stack) and expression evaluation. A queue, on the other hand, follows the First In, First Out (FIFO) principle, meaning the first element added is the first one to be removed. It is used in scenarios like task scheduling and handling requests in a system. While stacks are implemented using arrays or linked lists with push() and pop() operations, queues support enqueue() (adding elements) and dequeue() (removing elements).
11 .
State a few advantages of a Database Management System.
The following are some of the advantages of a Database Management System:

* It aids in the management of database redundancy.
* It restricts unauthorized access.
* There are several user interfaces available.
* Services for recovery and backup are available.
* Limits on integrity are imposed.
* Make certain that the data is consistent.
* Simple to reach.
* Data processing and extraction are simplified due to the use of queries.
12 .
What are the ACID characteristics of database management systems?
ACID stands for Atomicity(A), Consistency(C), Isolation(I), and Durability(D). A transaction is basically a work's logical unit that reads and, in some situations, writes to a database. Transactions make use of read and write operations in order to access data. Some attributes must be followed after and before a transaction to maintain database consistency. They are known as ACID properties.

* Atomicity consists of Abort and Commit.

* Consistency relates to the accuracy of a database. The total sum after and before the transaction must be kept track of.

* Isolation property ensures that numerous transactions can occur at the same time without producing database state discrepancies.

* Durability property guarantees that when the transaction is successful, the database changes and alterations are recorded and written to disk. They are preserved even in the occurrence of a system failure.
13 .
What do you mean by a checkpoint in relation to database management systems?
In DBMS (Database Management Systems), a checkpoint is a procedure that deletes every previous log from the system and saves them permanently on the storage device. Two ways that can help the Database Management Systems recover and preserve the ACID features include log preservation on every transaction and storing shadow pages. Checkpoints are required when using a log-based recovery method. They are the smallest points from which the database engine is able to recover soon after a crash, as a predetermined smallest point from where the transaction log record may be used to recover every dedicated data up to the crash point.
14 .
What exactly are Transparent Database Management Systems?
It's a database management system in which the physical structure is hidden from users. It's also called Physical Storage Structure, and it refers to the memory manager of a database management system and describes how data is kept on a disc. As a result, there is minor abstraction. Transparencies in the DDBMS (Distributed Database Management Systems) are classified into four types:

* Performance transparency

* Transaction transparency

* Distribution transparency

* DBMS transparency
15 .
What is the difference between SQL and NoSQL databases?
SQL databases are structured and follow a relational model where data is stored in tables with predefined schemas. They use Structured Query Language (SQL) for querying and are suitable for applications requiring strong consistency, such as banking systems (e.g., MySQL, PostgreSQL).

NoSQL databases, in contrast, are non-relational and store data in formats like key-value pairs, documents, graphs, or wide-column stores. They offer flexibility, scalability, and faster performance for handling large amounts of unstructured data, making them ideal for big data applications (e.g., MongoDB, Cassandra).
16 .
What is normalization in databases?
Normalization is a database design process that eliminates redundancy and ensures efficient data organization. It involves multiple normal forms (NFs).

* First Normal Form (1NF) removes duplicate columns and ensures each column contains atomic values.

* Second Normal Form (2NF) eliminates partial dependencies, ensuring that all attributes depend on the primary key.

* Third Normal Form (3NF) removes transitive dependencies, ensuring that non-key attributes depend only on the primary key.

Higher forms like Boyce-Codd Normal Form (BCNF) further refine database integrity. Normalization improves data consistency and minimizes anomalies in database operations.
17 .
Given an array of positive integers, write code to return the differences between the sums of even and odd values in the given array.
In this scenario, we would have to write a function "evenOddDiff" which takes two inputs as parameters: the number of positive integers in the array and the array of positive integers. For example, if the initial input is 3 numbers and the numbers are 5, 2 and 4, the difference between the sums of even and odd numbers is = (4+2) – (5) = 6 – 1 = 5

The C++ code for the above-mentioned problem is given below:
#include<bits/stdc++.h>
using namespace std;
int evenOddDiff(int n, vector<int> &a)
{
   int oddSum = 0,evenSum = 0;
   for(int i: a)
   {
       if(i & 1)
           oddSum += i;
       else
           evenSum += i;
   }
   return evenSum - oddSum;
}
int main()
{
   int n;
   cin>>n;
   vector<int> a(n);
   for(int j = 0; j < n; j ++)cin >> a[j];
   cout << evenOddDiff(n, a) << endl;
   return 0;
}​

In the above-given code, we simply iterate over the elements of the list (given to us in the form of a C++ vector) and check whether each element of the list is an odd number or an even number using the condition "if(i && 1)". We also maintain two variables "oddSum" and "evenSum" which store the sum of odd numbers in the list and the sum of the even numbers in the list respectively. In the end, we simply return the difference between the values of the variables evenSum and oddSum as expected in the question.
18 .
Differentiate between Swapping and Paging.
SWAPPING PAGING
When the entire process is shifted to secondary memory, it is referred to as swapping. Paging takes place in the event of some part of a process being transferred to secondary memory.
Swapping involves the temporary transfer of a process from the main memory to secondary memory. In Paging, the contiguous block of memory is made non-contiguous but of fixed size called frame or pages.
No memory management is required for swapping. Paging requires non-contiguous Memory Management.
Swapping provides the direction regarding the solution in it. Paging does not give any direction regarding the solution in it.
19 .
What is a Request Processor and a Request Dispatcher in context with Java?
Request Processor: Request processor is a class given by the struts framework that is responsible for handling requests and responses. If we want to change our controller, we can do so in this class. Since version 7.16, the Request processor has been able to perform asynchronous requests in a dedicated thread pool. The majority of RequestProcessor use cases begin with building your own RequestProcessor instance (which by itself is quite lightweight).

Request Dispatcher: Request Dispatcher is an interface that allows requests to be dispatched from one page to another within an application (page may be a servlet file, JSP, etc.). The RequestDispatcher interface  offers the following two approaches:

* public void forward(ServletRequest request, ServletResponse response) throws ServletException, java.io.IOException: The forward() method is used to redirect a client's request to a different resource (HTML file, servlet, jsp etc). The control is passed to the next resource called when this method is invoked. The include() method, on the other hand, inserts the content of the calling file into the called file. The control remains with the calling resource after calling this method, but the processed output is included in the called resource.

* public void include(ServletRequest request, ServletResponse response) throws ServletException, java.io.IOException: The include() method is used to pass the contents of the caller resource to the called resource. Control remains with the caller resource when this method is called. It merely incorporates the calling resource's processed output into the called one.
20 .
What do you understand about Servlet Collaboration?
Servlet Collaboration is the process of exchanging information among the servlets of a Java web application. This allows information to be passed from one servlet to another via method invocations.

The Servlet API (Application Programming Interface) of Java, which exposes two interfaces, is the primary technique offered by Java to achieve Servlet Collaboration.

* javax.servlet.RequestDispatcher

* javax.servlet.http.HttpServletResponse

These two interfaces contain the techniques for fulfilling the goal of information sharing amongst servlets.
21 .
Define spooling in Operating Systems.
Spooling is the process of temporarily storing data so that it can be used and processed by a device, program, or system. Data is delivered to and held in memory or other volatile storage until it is requested for execution by a program or computer. SPOOL is an acronym that stands for "Simultaneous Peripheral Operations Online." The spool is usually kept in the computer's physical memory, buffers, or interrupts for Input / Output devices. The FIFO (first-in, first out) method is used to process the spool in ascending order. Spooling is the process of collecting data from many Input / Output tasks and storing it in a buffer. This buffer is a section of memory or hard disc that Input / Output devices can access. An operating system performs the following tasks in a distributed environment:

* Handles data spooling for Input / Output devices, which have various data access rates.

* Maintains the spooling buffer, which serves as a holding area for data while the slower device catches up.

* Because a computer can do Input / Output in parallel order, the spooling process maintains parallel computing. It is now feasible for the computer to read data from a tape, write data to disc, and print data to a tape printer all at the same time.

Printing is the most obvious example of spooling. The papers to be printed are stored in the SPOOL before being added to the printing queue. During this time, several programs can run and utilise the CPU without having to wait for the printer to complete the printing process on each paper individually. Many additional features can be added to the Spooling printing process, such as establishing priorities, receiving notifications when the printing process is complete, and choosing different types of paper to print on based on the user's preferences.
22 .
What do you understand about tokens in C or C++?
A token in C or C ++ is the smallest element of a program that the compiler can understand. Tokens can be of the following types (given along with examples):

* Keywords - "new", "int", "class", etc.

* Strings - "Ritik", "Vaibhav", "Muskan", etc.

* Identifiers - "i", "j", "abc", "temp", etc.

* Special Symbols - "\n", "\r", "\t", etc.

* Constants - 5, 10, 403, etc.

* Operators - +, - , *, etc.
23 .
What do you understand by Function Overloading?
Object-Oriented programming has a feature called function overloading, which allows two or more functions to have the same name but distinct parameters.  Function Overloading occurs when a function name is overloaded with several jobs.

The "Function" name should be the same in Function Overloading, but the arguments should be different. Polymorphism is a feature of C++ that can be used to overload functions. An example of Function Overloading in C++ is given below:

#include <bits/stdc++.h>
using namespace std;
void foo(int n) {
   cout << " Integer Value:  " << n << endl;
}
void foo(double n) {
   cout << " Decimal Value " << n << endl;
}
void foo(char n) {
   cout << " Character Value" << nc << endl;
}
int main() {
   foo(40);
   foo(452.144);
   foo("A");
   return 0;
}​
24 .
What is the 'finalize' method used for in Java? Give an example illustrating the use of the 'finalize' method.
Before an object is destroyed, the "finalize" method or function is used to conduct cleanup operations on unmanaged resources owned by the current object. Because this method is protected, it can only be accessed through this class or a derived class.

The syntax of the finalize method is given below:
protected void finalize throws Throwable{}​

An example illustrating the use of the finalize method is given below:
public class FinalizeMethodExample {  
    public static void main(String[] args)   
   {   
       FinalizeMethodExample o = new FinalizeMethodExample ();   
       System.out.println(o.hashCode());   
       o = null;   
       // a call to the garbage collector of Java   
       System.gc();   
       System.out.println("The end of garbage collection!");   
 
   }  
   @Override  
   protected void finalize()   
   {   
       System.out.println("The finalize method is being called now!");   
   }   
}​
 
The output of the above program will be as follows:

3202429534
The end of garbage collection!
The finalize method is being called now!​
25 .
What are ACID properties in Database Management Systems?
The term "ACID" is an acronym for Atomicity, Consistency, Isolation and Durability. A transaction is a logical unit of work that accesses and, in certain cases, updates the contents of a database. Read and write operations are used by transactions to access data. Certain properties are followed before and after a transaction in order to preserve consistency in a database. ACID characteristics are what they are called. Let us take a look at each of these characteristics in detail:

Atomicity: Atomicity means that either the complete transaction occurs at once or it does not occur at all. There is no middle ground, which means that transactions do not take place in stages. Each transaction is treated as a single entity that is either completed or not conducted at all. It entails the following two procedures.

* Abort: If a transaction aborts, any database modifications are lost.

* Commit: When a transaction commits, the changes it contains become visible.

The 'All or nothing rule' is another name for atomicity.

Consider the following transaction T, which consists of two transactions: T1 and T2. 100 dollars transferred from account X to account Y.

If a transaction fails after T1 but before T2 (for example, after write(X) but before write(Y)), the amount deducted from X but not added to Y is deducted. As a result, the database is in an inconsistent condition. As a result, the transaction must be completed in its entirety to guarantee that the database state is valid.

Consistency: This means that integrity constraints must be maintained before and after the transaction to ensure that the database is consistent. It refers to a database's correctness. The entire amount before and after the transaction must be maintained, as shown in the example above.

* Before T, the total is 500 + 200 = 700.

* After T, the total is 400 + 300 = 700.

As a result, the database is consistent. When T1 succeeds but T2 fails, there is inconsistency. As a result, T is not complete.

Isolation: This attribute assures that several transactions can take place at the same time without causing database state inconsistencies. Transactions take place in a non-interfering manner. Changes made in one transaction are not visible to other transactions until that transaction's update is written to memory or committed. This feature assures that concurrently executing transactions results in a state that is identical to the one attained if they were executed sequentially in some order.

Let us take an example to understand Isolation. Let X = 500 and Y = 500 and let there be two transactions T and T".

Assume T has been running until Read (Y), at which point T" begins. As a result of this interleaving, T" reads the right value of X but the wrong value of Y, and the sum computed by T": (X+Y = 50, 000+500=50, 500) is inconsistent with the sum at the end of the transaction:

T = 50, 000 + 450 = 50, 450 (X+Y = 50, 000 + 450 = 50, 450).

Due to the loss of 50 units, this causes database discrepancy. As a result, transactions must be performed in isolation, and changes should only be seen after they have been written to the main memory.

Durability: This attribute ensures that after the transaction has been completed, the database updates and modifications are saved and written to disc and that they survive even if the system fails. These changes are now saved in non-volatile memory and are permanent. The transaction's effects are never lost as a result of this.

The ACID properties, taken together, provide a mechanism for ensuring the correctness and consistency of a database in such a way that each transaction is a group of operations that acts as a single unit, produces consistent results, is isolated from other operations, and the updates it makes are durably stored.
26 .
What are the different types of memory areas allocated by the Java Virtual Machine in Java?
The different types of memory areas allocated by the Java Virtual Machine are as follows:

* Class(Method) Area: The Class(Method) Area maintains per-class structures such the runtime constant pool, fields, method data, and method code.

* Stack: The Java Stack is where frames are stored. It manages local variables and partial results, as well as invoking and returning methods. Each thread has its own JVM stack, which is built concurrently with the thread. Each time a method is called, a new frame is created. When a frame's method invocation is finished, it is destroyed.

* Program Counter (PC) Register: The address of the Java virtual machine instruction presently being executed is stored in the PC (programme counter) register.

* Heap: This is the runtime data location where the objects' memory is allocated.

* Native Method Stack: Each and every native method used in the application is present in it.
27 .
In the context of SQL, explain unary operations in Relational Algebra.
In Relational Algebra, single operand operations are referred to as unary operations. SELECTION, PROJECTION, and RENAME are said to be unary operations in relational algebra.

SELECTION: This action selects a subset of tuples from a relation that fulfills the criteria set. The SELECT procedure is analogous to a filter that maintains only tuples that fulfill a criteria set. Alternatively, this operation may be used to restrict the tuples to those that satisfy the requirement. This operation may alternatively be seen as a horizontal partition of the relation into two groups of tuples: those that satisfy the criteria and are chosen and one that don't and are refused.

PROJECTION: If we think of a relation as a table, the SELECTION operation picks certain rows while rejecting others. In contrast, the PROJECTION procedure selects a subset of the columns of a table while rejecting the remainder. If we just want to look at a handful of relation's qualities, we can use the PROJECTION operation in order to project the relation over those. Consequently, the PROJECTION operation result may be viewed as a vertical partition of the relation.

RENAME: It's occasionally simple and acceptable to break a complicated chain of actions and rename it as a relation with fresh names. There exist a variety of reasons to rename a relationship, including:
We'll probably want to preserve the result of a relational algebra expression like a relation to use in the future.
We could desire to bridge connection to itself.
28 .
Write code that returns the dissimilarities between the sums of odd and even values in an array of positive integers.
In such a case, we'd need to create a function called "evenOddDiff" that accepts two parameters: the array of positive integers and the total number of positive integers. For instance, if the first three numbers are 7, 4, and 8, the distinction between the sums of odd and even numbers is = (4+8) - (7) = 12 - 7 = 5.
#include<bits/stdc++.h>
using namespace std;
int evenOddDiff(int n, vector<int> &a)
{
   int oddSum = 0,evenSum = 0;
   for(int i: a)
   {
       if(i & 1)
           oddSum += i;
       else
           evenSum += i;
   }
   return evenSum - oddSum;
}
int main()
{
   int n;
   cin>>n;
   vector<int> a(n);
   for(int j = 0; j < n; j ++)cin >> a[j];
   cout << evenOddDiff(n, a) << endl;
   return 0;
}​