YASH Technologies
20+ Protiviti India Member Interview Questions and Answers
Q1. What is GCD? Explain in details
GCD stands for Greatest Common Divisor. It is the largest positive integer that divides two or more numbers without leaving a remainder.
GCD is used to find the highest common factor between two or more numbers.
It is often used in mathematical calculations and algorithms.
GCD can be calculated using various methods like Euclidean algorithm or prime factorization.
Example: GCD of 12 and 18 is 6, as 6 is the largest number that divides both 12 and 18 without leaving a remainder.
Q2. How different microservices communicate with each other
Microservices communicate with each other through APIs, message queues, or event-driven architecture.
APIs: Microservices can communicate with each other through RESTful APIs or GraphQL.
Message queues: Services can use message brokers like RabbitMQ or Kafka to send and receive messages.
Event-driven architecture: Services can publish events to a message broker and subscribe to events they are interested in.
Service discovery: Services can use tools like Consul or Eureka to disco...read more
Q3. How to handle http requests in Spring Boot
Handling http requests in Spring Boot involves creating controller classes, mapping endpoints, and using annotations like @RestController and @RequestMapping.
Create a controller class with @RestController annotation
Map endpoints using @RequestMapping annotation
Use @GetMapping, @PostMapping, @PutMapping, @DeleteMapping annotations for specific HTTP methods
Inject dependencies using @Autowired annotation
Q4. Where will be microservices deployed in AWS
Microservices can be deployed in AWS using services like ECS, EKS, Lambda, or Fargate.
Microservices can be deployed on AWS Elastic Container Service (ECS) for containerized applications.
AWS Elastic Kubernetes Service (EKS) can be used for deploying microservices using Kubernetes.
Serverless microservices can be deployed using AWS Lambda.
AWS Fargate provides serverless compute for containers, allowing for easy deployment of microservices.
Q5. how to create primary key through programming
Primary key can be created through programming by using SQL commands or ORM frameworks.
Use SQL commands like CREATE TABLE to define primary key constraints
Use ORM frameworks like Hibernate to define primary key annotations
Primary key can be a single column or a combination of columns
Primary key ensures uniqueness and helps in faster data retrieval
Q6. How to find duplicate in unsorted array
Use a hash set to keep track of seen elements and identify duplicates in an unsorted array of strings.
Iterate through the array and add each element to a hash set.
If an element is already in the hash set, it is a duplicate.
Example: ['apple', 'banana', 'apple', 'orange'] => 'apple' is a duplicate.
Q7. Enum dictionary sets array explain
Enum dictionary sets array of strings
An enum is a set of named values
A dictionary maps keys to values
An array is a collection of elements
The enum values can be used as keys in the dictionary to map to an array of strings
Q8. Difference between Structure VS class
Structures are value types while classes are reference types.
Structures are allocated on stack while classes are allocated on heap.
Structures do not support inheritance while classes do.
Structures cannot have destructors while classes can.
Structures are used for small data structures while classes are used for larger, more complex objects.
Example of structure: struct Point { int x, y; }
Example of class: class Person { string name; int age; }
Q9. What is Streams in java8
Streams in Java 8 provide a way to process collections of objects in a functional style.
Streams allow for functional-style operations on collections, such as map, filter, and reduce.
Streams can be sequential or parallel, allowing for efficient processing of large datasets.
Streams do not store elements, they are processed on-demand as needed.
Example: List
names = Arrays.asList("Alice", "Bob", "Charlie"); Stream stream = names.stream();
Q10. How the Hashmap works
Hashmap is a data structure that stores key-value pairs and allows for quick retrieval of values based on keys.
Hashmap uses a hash function to map keys to indices in an array.
Collisions can occur when multiple keys hash to the same index, which can be resolved using techniques like chaining or open addressing.
Hashmap provides constant time complexity O(1) for insertion, deletion, and retrieval operations.
Example: HashMap
map = new HashMap<>(); map.put("key1", 1); int value = ...read more
Q11. Explain Solid principle?
SOLID is a set of principles for object-oriented programming to make software more maintainable, scalable, and robust.
S - Single Responsibility Principle
O - Open-Closed Principle
L - Liskov Substitution Principle
I - Interface Segregation Principle
D - Dependency Inversion Principle
Q12. Explain ARC with example?
ARC is Automatic Reference Counting used in iOS to manage memory.
ARC is a memory management technique used in iOS development.
It automatically manages the memory of objects in an iOS app.
ARC keeps track of the number of references to an object and deallocates it when there are no more references.
Example: If an object is assigned to a variable, ARC increments the reference count by 1. If the variable is reassigned or goes out of scope, ARC decrements the reference count by 1.
A...read more
Q13. Authentication vs Authorization
Authentication verifies the identity of a user, while authorization determines what a user can access.
Authentication confirms the user's identity through credentials like passwords or biometrics.
Authorization determines the user's permissions and access levels to resources.
Example: Logging into a system with a username and password is authentication. Being able to view certain files based on your role is authorization.
Q14. Exception handling in spring boot
Exception handling in Spring Boot involves using @ControllerAdvice, @ExceptionHandler, and ResponseEntity.
Use @ControllerAdvice to define global exception handling for all controllers
Use @ExceptionHandler to handle specific exceptions in individual controllers
Return ResponseEntity with appropriate status codes and error messages
Q15. In angular how we can pass data parent to child.
In Angular, data can be passed from parent to child components using @Input decorator.
Use @Input decorator in the child component to receive data from the parent component
Define a property in the child component with @Input decorator and assign the value passed from the parent component
Parent component should bind the data to the child component using property binding in the template
Q16. diff b/w get and load method in hibernate
get() method returns null if the object is not found in the database, while load() method throws an exception.
get() method is eager loading while load() method is lazy loading.
get() method hits the database immediately while load() method hits the database only when the object is accessed.
get() method returns a proxy object while load() method returns a real object.
get() method is used when we are not sure if the object exists in the database while load() method is used when ...read more
Q17. Find the 2nd Highest salary using sql query
Use SQL query with ORDER BY and LIMIT to find 2nd highest salary.
Use SELECT statement to retrieve salary column
Use ORDER BY clause to sort salaries in descending order
Use LIMIT 1,1 to skip the highest salary and retrieve the 2nd highest salary
Q18. Find the 2nd largest number using Java 8
Use Java 8 streams to find the 2nd largest number in an array.
Convert the array to a stream using Arrays.stream()
Sort the stream in descending order using sorted()
Skip the first element (largest number) using skip(1)
Find and return the first element of the remaining stream
Q19. Sort the names using Java 8
Using Java 8, sort an array of strings containing names.
Use the Arrays.sort() method with a lambda expression to sort the array of strings.
Example: String[] names = {"Alice", "Bob", "Charlie"}; Arrays.sort(names, (a, b) -> a.compareTo(b));
Print the sorted names array to see the result.
Q20. Explain dependency injection.
Dependency injection is a design pattern where components are provided with their dependencies rather than creating them internally.
Dependency injection helps in achieving loose coupling between components.
It allows for easier testing by providing mock dependencies.
There are three types of dependency injection: constructor injection, setter injection, and interface injection.
Interview Process at Protiviti India Member
Top Senior Software Engineer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month