> For the complete documentation index, see [llms.txt](https://tingreavinash.gitbook.io/the-tech-toolbox/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tingreavinash.gitbook.io/the-tech-toolbox/question-answers/company-wise/mastercard-interview.md).

# Company 2

## Java Language Fundamentals <a href="#java-language-fundamentals" id="java-language-fundamentals"></a>

* Can we extend string class?
* Why string class is immutable?
* [What ](/the-tech-toolbox/question-answers/java-spring-boot.md#what-is-the-difference-between-string-s-and-new-string-s)is the difference between `String = "s"` and `new String("s")`
* Are strings eligible for garbage collection
* Explain the deep [explanation ](https://tingreavinash.gitbook.io/the-tech-toolbox/question-answers/company-wise/pages/fpxJZ09D2m7GmgtJcTXq#explain-the-deep-explanation-of-equals-hashcode-method.)of equals/hashcode method.
* What are immutable objects
* Java [Call by value or call by reference](https://tingreavinash.gitbook.io/the-tech-toolbox/question-answers/company-wise/pages/fpxJZ09D2m7GmgtJcTXq#java-call-by-value-or-call-by-reference-demonstrate-using-an-example.)? Demonstrate using an example.
* What is generics in Java
* Class vs object
* [How to](/the-tech-toolbox/question-answers/java-spring-boot.md#how-to-create-a-class-as-static) create a class as static
* [What happens](/the-tech-toolbox/question-answers/java-spring-boot.md#what-happens-when-return-is-used-inside-a-try-block) when `return` is used inside a try block
* [What happens](https://tingreavinash.gitbook.io/the-tech-toolbox/question-answers/company-wise/pages/fpxJZ09D2m7GmgtJcTXq#what-happens-when-system.exit-is-used-inside-a-try-block) when `System.exit()` is used inside a try block
* What is the difference between path and classpath
* [Can](/the-tech-toolbox/question-answers/java-spring-boot.md#can-a-constructor-be-made-final) a constructor be made final?
* What is the [finalize](/the-tech-toolbox/question-answers/java-spring-boot.md#what-is-the-finalize-method) method?
* Explain the [Stream API](https://tingreavinash.gitbook.io/the-tech-toolbox/question-answers/company-wise/pages/fpxJZ09D2m7GmgtJcTXq#explain-the-stream-api-in-java-8.) in Java 8.
* Explain interfaces in the collection framework.

## Threads and Concurrency <a href="#threads-and-concurrency" id="threads-and-concurrency"></a>

* [How](/the-tech-toolbox/question-answers/java-spring-boot.md#how-to-return-a-value-from-a-thread) to return a value from a thread?
* [What](/the-tech-toolbox/question-answers/java-spring-boot.md#what-is-the-callable-interface) is the Callable interface?
* How can we create a thread in Java?
* Explain [Daemon threads.](https://tingreavinash.gitbook.io/the-tech-toolbox/question-answers/company-wise/pages/fpxJZ09D2m7GmgtJcTXq#explain-daemon-threads.)
* Explain [race condition](https://tingreavinash.gitbook.io/the-tech-toolbox/question-answers/company-wise/pages/fpxJZ09D2m7GmgtJcTXq#explain-race-condition.).
* How [locks ](/the-tech-toolbox/question-answers/java-spring-boot.md#how-locks-are-used-in-multithreading)are used in multithreading?
* How [synchronization](/the-tech-toolbox/question-answers/java-spring-boot.md#how-synchronization-is-implemented-in-java) is implemented in Java?
* [On which object](/the-tech-toolbox/question-answers/java-spring-boot.md#on-which-object-the-lock-is-implemented-when-we-use-a-synchronized-method) the lock is implemented when we use a synchronized method?
* In which case do we not need to pass any mutex object?

## Collections <a href="#java-collections" id="java-collections"></a>

* HashMap internals
* Concurrent HashMap vs HashMap
* Benefits of Optional class
* Java 8/9 features - Questions around Optional class, Stream API
* What are the methods provided by HashMap
* [How to handle](/the-tech-toolbox/question-answers/java-spring-boot.md#how-to-handle-custom-objects-as-key-in-hashmap) custom objects as key in HashMap
* If equals returns true and hashcode method returns false in HashMap, will it add the object
* Explain Queue data structure.
* Explain [Tree data structure](https://tingreavinash.gitbook.io/the-tech-toolbox/question-answers/company-wise/pages/fpxJZ09D2m7GmgtJcTXq#explain-tree-data-structure.).
* What problems are related to tree data structures?

## Design Patterns <a href="#java-design-patterns" id="java-design-patterns"></a>

* Java design patterns - Explain at least 1 or 2 patterns from each category
* Demonstrate the builder pattern
* Demonstrate the observer pattern / strategy pattern
* Factory Design Pattern
* Builder Design Pattern
* Which design patterns have you used in your project

## Exceptions and Errors <a href="#exceptions-and-errors" id="exceptions-and-errors"></a>

* Can we catch the error?
* [Can have](/the-tech-toolbox/question-answers/java-spring-boot.md#can-have-custom-exceptions-can-we-have-custom-errors) custom exceptions? Can we have custom errors?

## Coding <a href="#coding" id="coding"></a>

* Find odd numbers from list of integers using Stream API
* Write a method to identify vowels in a string and number of times vowels are repeated in the same string
* Return `true` if a list of numbers contains odd numbers, `false` otherwise [using Java 8](/the-tech-toolbox/question-answers/java-spring-boot.md#return-true-if-a-list-of-numbers-contains-odd-numbers-false-otherwise-using-java-8)
* Describe your role in your current project
* How to review code of your team members and which rules you keep in mind
* Explain how to find the kth smallest element in an organization, where k represents the third youngest student.

## Spring Boot <a href="#spring-boot" id="spring-boot"></a>

* How to establish connection to DB in Spring Boot?
* Can we do autowiring by interface?
* In case of autowiring by interface, what if there are two different implementations? Which bean will be autowired?
* How to change the default web server in Spring Boot
* How to retry in Spring Boot
* How to do a health check
* What is the difference between `@Component`, `@Service`, and `@Autowire` annotations
* What is JPA
* Have you used Hibernate JPA in your Spring Boot application and how
* What is the difference between `SpringRunner` and `Mockito`
* What is the difference between soap and REST API
* What is the difference between JSON and XML
* [What](/the-tech-toolbox/question-answers/java-spring-boot.md#what-is-requestbody-and-responsebody-annotation) is `@RequestBody` and `@ResponseBody` annotation
* What is `@RequestMapping` annotation
* What is Spring Actuator
* What are the REST API URL patterns
* Create a REST controller class and add all HTTP methods
* Explain @Primary annotation.
* [How to](/the-tech-toolbox/question-answers/java-spring-boot.md#how-to-resolve-circular-dependency-problem-in-spring-boot) resolve circular dependency problem?
* When to use @SpringBootApplication and @EnableAutoConfiguration annotations?

## Microservices <a href="#microservices" id="microservices"></a>

* Can we establish parallel connections to separate DB in Java?
* Exception handling in microservices
* Circuit breaker pattern
* Data consistency in microservices in case of failure
* How to scale a pod in case of load (e.g. 70%)
* Benefits of microservices architecture? How is it different from monolithic application?
* How to do health check of microservices
* How to retry if a service is down
* How do circuit breakers work

## Testing <a href="#testing" id="testing"></a>

* Different types of testing used in a project
* How to mock objects in unit tests?
* Questions around the Mockito library
* What is a contract test / functional test / integration test, etc.
* Explain the CI/CD process

## Miscellaneous <a href="#miscellaneous" id="miscellaneous"></a>

* What is Sonar and what is its use
* Give a rating score of your skills
