Autocoder

Mastercard interview questions with answers (software engineer)

Last updated 2026-11-19

Mastercard hires software engineers in India for its payments technology teams. Candidates commonly describe interviews that cover Java or Python fundamentals, Spring and microservices, SQL, and application security, plus a walk-through of a project and a behavioural conversation.

The thirteen questions below are practice in that style, with worked answers. They are not past questions. For the online assessment, see Mastercard coding round questions.

Typical rolesSoftware Engineer, Associate Software Engineer (India)
Rounds, as commonly reportedOnline assessment, technical interviews, managerial or HR round
Heavy topicsJava, Spring, microservices, SQL, security, DevOps basics
Hiring newsSee Hiring status below

Rounds as commonly reported

Candidates commonly report an online assessment with coding and technical questions, followed by one or more technical interviews and a managerial or HR discussion. The count and order of rounds change with role and level.

In technical interviews, questions tend to follow your resume closely: a Spring Boot project invites questions on REST, security and testing, and a data project invites SQL and design questions. Security awareness is worth extra preparation for any payments company.

What to prepare

Hiring status

There is no Mastercard hiring-news page on this site, and this page quotes no hiring numbers, dates or packages because none are sourced here. Check Mastercard's own careers site for current India roles, eligibility and dates, and apply only there.

Mastercard interview questions with answers (software engineer): questions with worked answers

  1. 1

    Explain what Spring Boot auto-configuration does and how a request flows through a typical Spring Boot service.

    medium

    Auto-configuration inspects the classpath and your properties and creates beans automatically: a starter for web pulls in an embedded server and configures a DispatcherServlet, a JDBC starter configures a DataSource. Conditional annotations such as @ConditionalOnClass decide when a configuration applies, and your own beans take precedence. A request reaches the embedded server, passes through filters, the DispatcherServlet maps it to a controller method, the controller calls a service which calls a repository, and the response is converted to JSON by a message converter. Knowing this flow lets you place validation, security and exception handling correctly.

  2. 2

    In a microservice system, what do an API gateway and service discovery do?

    medium

    An API gateway is the single entry point for clients: it routes requests to services and can handle authentication, rate limiting, TLS termination and request aggregation, so each service does not repeat that. Service discovery lets services find each other's current addresses when instances scale up and down, either through a registry such as Eureka or Consul, or through the platform's DNS in Kubernetes. Together they remove hard-coded addresses. The trade-off is another component that must be highly available.

  3. 3

    HashSet, LinkedHashSet and TreeSet: how do they differ?

    easy

    HashSet is backed by a hash table: O(1) average add, remove and contains, no ordering. LinkedHashSet keeps insertion order with a linked list through the entries at a small memory cost. TreeSet is a red-black tree: O(log n) operations, elements kept sorted by natural order or a Comparator, and it supports range queries such as floor, ceiling and subSet. All three reject duplicates using equals (and hashCode for the hash-based ones); TreeSet uses compareTo, so inconsistent ordering can make elements vanish.

  4. 4

    How do you avoid NullPointerException in Java, and what is Optional for?

    easy

    Prefer designs that never return null for collections (return empty lists), validate arguments early with Objects.requireNonNull, and use Optional as a return type to make 'may be absent' explicit. Use map, filter and orElse instead of isPresent followed by get. Do not use Optional for fields, method parameters or collections, because it adds overhead and clutter. Optional.orElseGet is lazy, while orElse always evaluates its argument.

    java
    import java.util.*;
    class UserRepo {
        Map<String, String> emails = new HashMap<>();
        Optional<String> findEmail(String id) { return Optional.ofNullable(emails.get(id)); }
        String domain(String id) {
            return findEmail(id).map(e -> e.substring(e.indexOf('@') + 1)).orElse("unknown");
        }
    }
  5. 5

    SQL: for each day, show the number of transactions and the change from the previous day.

    medium

    Aggregate to one row per day, then use LAG to read the previous row's count and subtract it. The first day has no previous value, so LAG returns NULL; use COALESCE if you want zero. Order by date inside the window. Days with no transactions will be missing unless you join to a calendar table, which is a good point to raise.

    sql
    SELECT txn_date, cnt, cnt - LAG(cnt) OVER (ORDER BY txn_date) AS change_from_prev
    FROM (
      SELECT txn_date, COUNT(*) AS cnt
      FROM Transactions
      GROUP BY txn_date
    ) d
    ORDER BY txn_date;
  6. 6

    Distinguish XSS, CSRF and SQL injection, and name a defence for each.

    medium

    SQL injection runs attacker-supplied SQL on your database; the defence is parameterised queries. Cross-site scripting injects script into a page viewed by others, stealing sessions or acting as the user; defend with output encoding, a Content-Security-Policy and HttpOnly cookies. Cross-site request forgery tricks a logged-in user's browser into sending an unwanted request; defend with anti-CSRF tokens, SameSite cookies and by checking the origin on state-changing requests. Naming the trust boundary each attack crosses is what makes the answer convincing.

  7. 7

    Compare session cookies with JWTs, and describe the OAuth 2.0 authorisation code flow briefly.

    hard

    A session cookie holds an opaque id and the server keeps the state, which makes revocation easy but needs shared storage across servers. A JWT is a signed token carrying claims that any service can verify without a lookup, which suits distributed services but is hard to revoke before expiry, so use short lifetimes plus refresh tokens. In the authorisation code flow, the client redirects the user to the authorisation server, the user signs in and consents, the server returns a one-time code to the client's redirect URI, and the client exchanges the code, with its secret or PKCE verifier, for tokens. The access token is then sent to the API.

  8. 8

    What is the difference between a Docker image and a container, and what does Kubernetes add?

    medium

    An image is a read-only, layered package of an application and its dependencies; a container is a running instance of an image with its own isolated process, filesystem and network view, sharing the host kernel. Containers are lighter than virtual machines. Kubernetes schedules containers across a cluster and adds self-healing (restart failed pods), scaling, rolling updates, service discovery and configuration management. A Deployment declares the desired number of replicas and Kubernetes keeps reality matching it.

  9. 9

    Explain the testing pyramid and how you would test a service that calls an external payment API.

    medium

    Many fast unit tests at the base, fewer integration tests in the middle, and a small number of end-to-end tests at the top, because higher layers are slower and more fragile. For the payment call, unit test the logic with the client mocked, test the client adapter against a stub server or recorded contract, and keep one end-to-end test against a sandbox. Test failure paths deliberately: timeouts, error responses and duplicate callbacks. Contract tests catch changes in the external API early.

  10. 10

    You must find a duplicate in an array of n + 1 integers, each between 1 and n. Compare approaches.

    hard

    Sorting then checking neighbours is O(n log n) time and changes the array or needs a copy. A hash set is O(n) time and O(n) space. Treating the array as a linked list where index i points to a[i] and applying Floyd's cycle detection finds the duplicate in O(n) time and O(1) space without modifying the array, because a duplicate value means two indices point to the same node and so create a cycle. State which constraints, such as no modification and constant space, decide the approach.

  11. 11

    Why Mastercard, and what interests you about payments technology?

    easy

    Be specific about the problem space: security, reliability and speed at global scale, and the role data and machine learning play in fraud detection. Connect it to something you have built or studied. Show curiosity about how a transaction flows between parties, and avoid quoting statistics you have not verified. Keep it under a minute and finish with what you want to learn.

  12. 12

    Walk me through a project on your resume and your own contribution.

    medium

    Start with the problem and who it was for, then the architecture in two sentences, then what you personally built and the hardest decision you made, with the alternative you rejected. Mention one bug or failure and how you found it, and one thing you would redo. Interviewers drill into whatever you mention, so only include technologies you can discuss in depth.

  13. 13

    How do you keep your technical skills current?

    easy

    Describe a real routine: building a small project when you learn something new, reading documentation or engineering blogs, following a language's release notes, or solving problems regularly. Give one recent example of something you learned and applied. Specific habits beat a list of platforms.

Frequently asked questions

Does Mastercard ask security questions?

For a payments company, candidates commonly report questions on authentication and common web vulnerabilities. Prepare XSS, CSRF, SQL injection and token-based authentication.

Is Spring Boot required?

Many Java roles list it. If it is on your resume, expect questions on how a request flows through the layers.

How long are the interviews?

There is no published length. Plan for technical conversations that follow your resume and include live problem-solving.

Where do I find current openings?

Use Mastercard's own careers site. This page quotes no hiring numbers because none are sourced here.

Related guides

More in Company Interview Questions

See all in this section