Shiprocket Private Limited
TCS Interview Questions and Answers
Q1. Change detection strategy in Angular
Change detection strategy in Angular is a mechanism used to detect changes in the application state and update the view accordingly.
Angular uses Zone.js for change detection by default
Change detection can be triggered manually using ChangeDetectorRef
Optimizing change detection using OnPush strategy
Q2. what is Closure
Closure is a function that captures the variables from its surrounding scope, even after the surrounding function has finished executing.
Closure allows a function to access and manipulate variables from its outer scope.
It maintains a reference to its outer scope, even after the outer function has returned.
Closure is commonly used in event handlers and callbacks.
Q3. Dif between var, let, const
var is function scoped, let is block scoped, const is block scoped and cannot be reassigned.
var is function scoped, let is block scoped, const is block scoped and cannot be reassigned
var can be redeclared and updated, let can be updated but not redeclared, const cannot be redeclared or updated
Example: var x = 10; let y = 20; const z = 30;
Q4. Rxjs operators used
Rxjs operators are used for handling asynchronous operations in reactive programming.
Map operator: transforms the items emitted by an Observable
Filter operator: emits only those items from an Observable that pass a specified condition
Merge operator: combines multiple Observables into one by merging their emissions
SwitchMap operator: switches to a new Observable each time it is emitted
DebounceTime operator: emits a value from the source Observable only after a specified time h...read more
Q5. Next highest number
To find the next highest number, sort the numbers in ascending order and find the number immediately greater than the given number.
Sort the numbers in ascending order
Find the number immediately greater than the given number
Return the next highest number
Q6. Number of Island
Count the number of islands in a given grid of '1's and '0's.
Iterate through the grid and for each '1' encountered, perform a depth-first search to mark all connected '1's as visited.
Increment the island count for each new island encountered.
Consider edge cases like grid boundaries and handling visited cells.
Interview Process at TCS
Top Software Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month