Cognizant
50+ Godrej Agrovet Interview Questions and Answers
Q1. What are custom hooks in React, and what are their use cases? Additionally, can you provide an example of a custom hook that performs an API call and utilizes the retrieved data?
Custom hooks in React are reusable functions that allow you to extract component logic into separate functions for better code organization and reusability.
Custom hooks are created using the 'use' prefix and can be used to share logic between components.
Use cases for custom hooks include fetching data from an API, handling form state, managing local storage, and more.
Example of a custom hook for API call: const useFetchData = (url) => { // logic to fetch data from API }
Q2. If I have assigned different colors to an ID and a class and applied both to the same element, which color will be applied based on CSS specificity precedence?
The color applied will be based on the specificity of the selector, with ID having higher specificity than class.
ID has higher specificity than class in CSS
Color applied will be based on the selector with higher specificity
Example: If ID selector has color red and class selector has color blue, the color applied will be red
Q3. What will be the output of the following JavaScript code fragment: `const a; function test() { console.log(a); }; test();`?
The code will throw an error because 'a' is declared but not initialized.
The code will result in a ReferenceError because 'a' is declared but not assigned a value.
Variables declared with 'const' must be initialized at the time of declaration.
Initializing 'a' with a value before calling test() will prevent the error.
Q4. What is the difference between class-based components and functional components in React?
Class-based components use ES6 classes and have lifecycle methods, while functional components are simpler and use functions.
Class-based components use ES6 classes to create components, while functional components are created using functions.
Class-based components have lifecycle methods like componentDidMount and componentDidUpdate, while functional components do not.
Functional components are simpler and more lightweight compared to class-based components.
With the introductio...read more
Q5. How can you implement the lifecycle of a React component in a functional component?
Implementing the lifecycle of a React component in a functional component
Use the useEffect hook to replicate lifecycle methods like componentDidMount, componentDidUpdate, and componentWillUnmount
Pass an empty array as the second argument to useEffect to mimic componentDidMount
Pass a variable or state as the second argument to useEffect to mimic componentDidUpdate
Return a cleanup function inside useEffect to mimic componentWillUnmount
Q6. What is the architecture of Redux, and what purposes do middlewares serve within it?
Redux is a predictable state container for JavaScript apps. Middlewares are functions that intercept actions before they reach the reducer.
Redux follows a unidirectional data flow architecture.
Middlewares in Redux are functions that can intercept, modify, or dispatch actions.
Common use cases for middlewares include logging, asynchronous API calls, and handling side effects.
Examples of popular Redux middlewares are Redux Thunk for async actions and Redux Logger for logging act...read more
Q7. What are the various methods for creating an object in JavaScript?
Various methods for creating an object in JavaScript include object literals, constructor functions, ES6 classes, and Object.create() method.
Object literals: var obj = { key: value };
Constructor functions: function ObjectName() { this.key = value; } var obj = new ObjectName();
ES6 classes: class ClassName { constructor() { this.key = value; } } var obj = new ClassName();
Object.create() method: var obj = Object.create(proto);
Q8. What are the differences between shallow copy and deep copy in JavaScript?
Shallow copy only copies the references of nested objects, while deep copy creates new copies of nested objects.
Shallow copy creates a new object but does not create copies of nested objects, only copies their references.
Deep copy creates a new object and also creates new copies of all nested objects.
Shallow copy can be achieved using Object.assign() or spread operator, while deep copy can be achieved using JSON.parse(JSON.stringify()).
Q9. How can you use CSS to arrange elements in a row and column layout?
CSS can be used to arrange elements in a row and column layout using flexbox or grid layout properties.
Use display: flex; for a row layout and display: flex; flex-direction: column; for a column layout
Use justify-content and align-items properties to align items in the main axis and cross axis respectively
For grid layout, use display: grid; and grid-template-columns or grid-template-rows to define the layout
Q10. What is spring and spring boot ? difference between them. What is single important spring boot dependency that make any spring project a spring boot app?
Spring is a Java framework for building web applications. Spring Boot is a tool that simplifies the process of creating Spring-based applications.
Spring is a popular Java framework that provides a wide range of features for building web applications.
Spring Boot is a tool that makes it easier to create Spring-based applications by providing a set of pre-configured defaults.
The main difference between Spring and Spring Boot is that Spring requires a lot of configuration, while ...read more
Q11. 1. What is architecture of JVM? How does memory management do in JVM? what are various segment of Heap memory like Eden, survival and old memory?
JVM architecture includes class loader, bytecode verifier, interpreter, JIT compiler, and runtime data areas. Memory management is done through garbage collection.
JVM has class loader to load class files and bytecode verifier to check the code for security and correctness.
Interpreter executes the bytecode and JIT compiler optimizes the code for better performance.
Runtime data areas include method area, heap, stack, and PC registers.
Memory management is done through garbage co...read more
Q12. What is the difference between useMemo and useCallback in React?
useMemo is used to memoize a value, while useCallback is used to memoize a function.
useMemo is used to memoize a value and recompute it only when its dependencies change.
useCallback is used to memoize a callback function and prevent unnecessary re-renders.
Example: useMemo can be used to memoize the result of a complex computation, while useCallback can be used to memoize an event handler function.
Q13. What are the various state management techniques available in React?
Various state management techniques in React include Context API, Redux, and local state.
Context API: React's built-in solution for passing data through the component tree without having to pass props down manually at every level.
Redux: A popular state management library for React applications, allowing for a centralized store to manage application state.
Local state: Managing state within individual components using useState hook or this.state in class components.
Q14. What are block scope and function scope in JavaScript?
Block scope and function scope are two types of scopes in JavaScript that determine the visibility and accessibility of variables.
Block scope refers to the visibility of variables within a block of code enclosed by curly braces. Variables declared with 'let' and 'const' have block scope.
Function scope refers to the visibility of variables within a function. Variables declared with 'var' have function scope.
Variables declared with 'let' and 'const' are only accessible within t...read more
Q15. Have you had experience working with semantic tags in HTML?
Yes, I have experience working with semantic tags in HTML.
Used semantic tags like <header>, <nav>, <main>, <section>, <article>, <aside>, <footer> for better structure and SEO.
Understand the importance of using semantic tags for accessibility and search engine optimization.
Semantic tags help in organizing content and making it more readable for developers and browsers.
Q16. Have you utilized CSS preprocessors, and if so, which ones?
Yes, I have utilized CSS preprocessors such as SASS and LESS.
I have experience using SASS to streamline my CSS workflow by utilizing variables, mixins, and nesting.
I have also worked with LESS to improve code organization and maintainability through features like variables and functions.
Q17. What's is uses of cache memory in application and which cache you used in your application and why ??
Cache memory is used to store frequently accessed data for faster retrieval, improving application performance.
Cache memory reduces the time taken to access data by storing frequently used data closer to the processor.
It helps in improving the overall performance of the application by reducing latency.
Different types of cache memory include L1, L2, and L3 caches, each with varying sizes and speeds.
In my application, we used L1 cache for storing critical data that needed to be...read more
Q18. 2. What are aggregation and composition relationship between entities?
Aggregation and composition are relationships between entities in object-oriented programming.
Aggregation is a 'has-a' relationship where one entity contains another entity as a part.
Composition is a 'part-of' relationship where one entity is a part of another entity.
Aggregation is represented by a diamond-shaped arrowhead pointing to the contained entity.
Composition is represented by a filled diamond-shaped arrowhead pointing to the containing entity.
Example of aggregation: ...read more
Q19. What is event bubbling in JavaScript?
Event bubbling is the propagation of events from the target element up through its ancestors in the DOM tree.
Events triggered on a child element will 'bubble up' and trigger on parent elements.
Event listeners can be attached to parent elements to handle events from multiple child elements.
Stopping event propagation can be done using event.stopPropagation() or event.stopImmediatePropagation().
Q20. In which scenario you use documents based database over SQL based database and why ??
Document-based databases are preferred for unstructured data and flexible schemas, while SQL databases are better for structured data and complex queries.
Use document-based databases for unstructured data like JSON, XML, etc.
Document-based databases have flexible schemas, allowing for easy changes and additions to data structure.
SQL databases are better for structured data with complex relationships and queries.
Examples of document-based databases include MongoDB, Couchbase, ...read more
Q21. What is hoisting in JavaScript?
Hoisting in JavaScript is the behavior where variable and function declarations are moved to the top of their containing scope during the compilation phase.
Variable declarations are hoisted to the top of their scope, but not their initializations.
Function declarations are fully hoisted, meaning they can be called before they are declared.
Hoisting can lead to unexpected behavior if not understood properly.
Q22. What techniques you use to optimise your application/code
I use techniques like code refactoring, performance profiling, caching, and database optimization to optimize my applications.
Code refactoring to improve code readability and maintainability
Performance profiling to identify bottlenecks and optimize critical sections
Caching to store frequently accessed data and reduce database queries
Database optimization by indexing tables, optimizing queries, and reducing data redundancy
Q23. Filter top 3 student from each class based on their marks. From 100 students list
Filter top 3 students from each class based on their marks from a list of 100 students.
Sort students in each class by marks in descending order
Select top 3 students from each class
Q24. How do you unit test a spring application
Unit testing a Spring application involves using frameworks like JUnit and Mockito to test individual components in isolation.
Use JUnit and Mockito frameworks for unit testing
Mock dependencies using Mockito to isolate components
Test individual components like controllers, services, and repositories separately
Use @RunWith(SpringRunner.class) to enable Spring support in JUnit tests
Q25. 3. How HashMap internally works?
HashMap is a data structure that stores key-value pairs and uses hashing to retrieve values quickly.
HashMap uses an array of buckets to store key-value pairs
The hash code of the key is used to determine the index of the bucket where the key-value pair will be stored
If two keys have the same hash code, they are stored in the same bucket as a linked list
When retrieving a value, the hash code of the key is used to find the bucket and then the linked list is searched for the key
H...read more
Q26. Definitions to scenarios based on the experience level.
Providing definitions to scenarios based on experience level.
Define scenarios based on experience level
Provide clear and concise definitions
Use relevant examples to illustrate definitions
Q27. What deployment tools you have used?
I have experience with various deployment tools such as Jenkins, Ansible, and Docker.
Jenkins for continuous integration and deployment
Ansible for configuration management and deployment
Docker for containerization and deployment
Q28. what is dependency injection in spring
Dependency injection in Spring is a design pattern where objects are provided with their dependencies rather than creating them internally.
In Spring, dependency injection is achieved through either constructor injection or setter injection.
It helps in achieving loose coupling between classes and promotes easier testing and maintenance.
Example: In Spring framework, you can define dependencies in a configuration file and let the framework inject them into the classes at runtime...read more
Q29. Functionality of your current working application
Our current working application is a project management tool for software development teams.
Allows creation of projects and tasks with deadlines
Assigns tasks to team members and tracks progress
Integrates with version control systems like Git
Generates reports on project status and team performance
Q30. Angular architecture and it's components
Angular architecture and its components
Angular follows a component-based architecture
Components are the building blocks of Angular applications
Each component has a template, class, and metadata
Modules are used to organize components and services
Services are used for sharing data and functionality between components
Directives are used to add behavior to elements in the DOM
Pipes are used for data transformation
RxJS is used for reactive programming
Angular CLI is used for generat...read more
Q31. Give an example of inner join, outer join
Inner join combines rows from two tables based on a related column, while outer join includes unmatched rows from one or both tables.
Inner join: SELECT * FROM table1 INNER JOIN table2 ON table1.column = table2.column
Outer join: SELECT * FROM table1 LEFT OUTER JOIN table2 ON table1.column = table2.column
Q32. Printing 1 to 20 number without using any loop.
Use recursion to print numbers from 1 to 20 without using loops.
Use a recursive function to print numbers from 1 to 20.
Base case: when the number reaches 20, stop recursion.
Each recursive call should print the current number and then call itself with the next number.
Q33. What is singelton property in bpel?
Singleton property in BPEL ensures only one instance of a service is created and shared among multiple clients.
Ensures only one instance of a service is created
Shared among multiple clients
Helps in managing resources efficiently
Q34. Z index in CSS and universal selector
Explanation of Z index in CSS and universal selector
Z index determines the stacking order of elements on a webpage
Higher Z index elements appear on top of lower Z index elements
Universal selector (*) selects all elements on a webpage
Universal selector can be used to apply styles to all elements at once
Q35. What is oracle database architecture
Oracle database architecture is a set of components that work together to manage data storage and retrieval.
Oracle database architecture consists of physical and logical structures
Physical structures include data files, redo logs, and control files
Logical structures include tablespaces, schema objects, and segments
Oracle database architecture also includes background processes and memory structures
Oracle database architecture supports client-server architecture and distribute...read more
Q36. Diff between == and equals in Java
In Java, == compares the references of objects, while equals compares the actual values of objects.
Use == to compare primitive data types like int, char, etc.
Use equals to compare objects like Strings, where you want to compare the actual values.
Override equals method in custom classes to define how objects should be compared.
Q37. What are thymeleaf expressions
Thymeleaf expressions are used in Thymeleaf templates to display dynamic data and perform operations.
Thymeleaf expressions are enclosed in double curly braces like {{ expression }}
They can be used to display variables, perform arithmetic operations, iterate over collections, and more
Example: {{ user.name }} will display the name of the user object
Q38. What are types of flow?
Types of flow include laminar, turbulent, steady, unsteady, compressible, and incompressible.
Laminar flow is smooth and predictable, while turbulent flow is chaotic and unpredictable.
Steady flow has a constant velocity and direction, while unsteady flow changes over time.
Compressible flow involves changes in density, while incompressible flow does not.
Examples of flow include blood flow in the circulatory system and air flow in a ventilation system.
Q39. Data models in the project I worked
I have worked with various data models in my projects.
I have experience with relational data models such as ER diagrams and SQL databases.
I have also worked with NoSQL data models such as document-based and key-value stores.
I have used data modeling tools such as ERwin and ER/Studio.
I have designed and implemented data models for various applications including e-commerce and healthcare systems.
Q40. What is dependency injection
Dependency injection is a design pattern in which components are given their dependencies rather than creating them internally.
Dependency injection helps in achieving loose coupling between classes.
It allows for easier testing by providing a way to mock dependencies.
There are three types of dependency injection: constructor injection, setter injection, and interface injection.
Q41. Implementation of redux
Redux is a predictable state container for JavaScript apps.
Redux is a library for managing application state.
It provides a single source of truth for the entire application state.
Actions are dispatched to update the state, which is done through reducers.
Selectors can be used to retrieve specific parts of the state.
Middleware can be used to intercept and modify actions before they reach the reducers.
Examples of Redux-based frameworks include React-Redux and Angular-Redux.
Q42. What is hooks ?
Hooks are a feature in React that allow you to use state and other React features without writing a class.
Hooks were introduced in React 16.8.
They let you use state and other React features in functional components.
Examples of hooks include useState, useEffect, useContext, etc.
Q43. How js engine works
JS engine is responsible for executing JavaScript code in a web browser.
JS engine parses and executes JavaScript code line by line.
It consists of a memory heap for storing variables and a call stack for managing function calls.
JS engine uses various optimization techniques like JIT compilation to improve performance.
Examples of popular JS engines include V8 (used in Chrome) and SpiderMonkey (used in Firefox).
Q44. use of context api in react
Context API in React is used for passing data through the component tree without having to pass props down manually at every level.
Context API provides a way to share values like themes, user data, etc. across the component tree without having to pass props down manually at every level.
It consists of three main parts: Provider, Consumer, and createContext.
Provider component allows consuming components to subscribe to context changes.
Consumer component allows consuming context...read more
Q45. Error handling in react
Error handling in React
Use try-catch blocks to handle errors in asynchronous code
Use error boundaries to catch errors in components
Use propTypes to validate props and prevent errors
Use console.error() to log errors to the console
Handle network errors with HTTP status codes and error messages
Q46. Pure component in react
A pure component in React is a component that does not re-render unless its props have changed.
Pure components extend React.PureComponent class
Pure components implement shouldComponentUpdate method to compare props and state for changes
Pure components are useful for optimizing performance by preventing unnecessary re-renders
Q47. Hooks in react
Hooks are a feature in React that allow you to use state and other React features without writing a class.
Hooks were introduced in React 16.8
They allow you to use state and other React features in functional components
useState is a commonly used hook for managing state
useEffect is another commonly used hook for handling side effects
Custom hooks can be created to reuse logic across components
Q48. Phases of life cycle
Phases of software development life cycle include planning, analysis, design, implementation, testing, and maintenance.
Planning: defining project scope, goals, and requirements
Analysis: gathering and analyzing user needs and system requirements
Design: creating a detailed plan for the software solution
Implementation: coding and integrating software components
Testing: verifying that the software meets requirements and is free of defects
Maintenance: making updates and improvemen...read more
Q49. Pros and Cons of Microservices
Microservices offer scalability and flexibility but can introduce complexity and communication challenges.
Pros: Scalability - allows for independent scaling of services
Pros: Flexibility - enables teams to work on different services concurrently
Cons: Complexity - managing multiple services can be challenging
Cons: Communication - requires robust communication between services
Cons: Testing - can be more complex due to distributed nature
Example: Netflix uses microservices to hand...read more
Q50. Arraylist implementation
ArrayList is a resizable array implementation in Java.
ArrayList in Java is a dynamic array that can grow or shrink in size.
It is part of the Java Collections Framework.
Example: ArrayList<String> names = new ArrayList<String>();
Q51. Explain about exadata
Exadata is an engineered system designed for running Oracle Database workloads.
Exadata combines hardware and software components to provide high performance and scalability for Oracle Database workloads.
It uses a combination of flash storage and disk storage to provide fast access to data.
Exadata also includes specialized software that offloads database processing from the database server to the storage servers, improving performance.
It is commonly used for data warehousing, ...read more
Q52. Explain OOp concerts
OOP concepts are fundamental principles in object-oriented programming that help in organizing and designing code.
Encapsulation: Bundling data and methods that operate on the data into a single unit (class).
Inheritance: Ability for a class to inherit properties and behavior from another class.
Polymorphism: Ability for objects of different classes to respond to the same message in different ways.
Abstraction: Hiding the complex implementation details and showing only the necess...read more
More about working at Cognizant
Top HR Questions asked in Godrej Agrovet
Interview Process at Godrej Agrovet
Top Senior Software Engineer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month