interview

 Capgiminin interview---Fail


1.Introduction 

2.In dependency injection : scope and transient

3.Solid Principle in your project

4.write progrmme 

Given two inputs:

  Input 1: A list of numbers

  Input 2: A target number

Find all distinct pairs from the list that add up to the target number.

 

Example:

Input 1: [8, 7, 1, 6, 5, 3, 2, 2, 4, 5]

Input 2: 10

 

Output:

8, 2  

7, 3  

6, 4  

5, 5

Below are clear and interview-ready answers for your next round:


2. Dependency Injection: Scoped vs Transient

Transient

  • A new instance is created every time it is requested.

  • Best for lightweight, stateless services.

  • Example: Utility classes, helper services, logging wrappers.

services.AddTransient<IEmailService, EmailService>();

Scoped

  • One instance per HTTP request.

  • Shared across all components within the same request.

  • Best for database operations, business logic tied to a single request.

services.AddScoped<IStudentService, StudentService>();

Interview Explanation:

I use Transient when the service is stateless and cheap to create.
I use Scoped for database context and business services to maintain consistency within a single request.


3. SOLID Principles in Your Project (Simple & Perfect Answer)

S — Single Responsibility Principle

  • Each class had only one responsibility.

  • Example: In my project, PurchaseOrderService handled PO logic, while EmailService handled notifications.

O — Open/Closed Principle

  • Classes open for extension, closed for modification.

  • Example: Added new discount types by extending strategy classes without touching existing logic.

L — Liskov Substitution Principle

  • Derived classes should work anywhere the base class works.

  • Example: Payment classes like CreditCardPayment and UPIPayment replaced the base class PaymentMethod.

I — Interface Segregation Principle

  • Small, specific interfaces instead of large ones.

  • Example: IEmailSender, ISmsSender instead of one heavy INotificationService.

D — Dependency Inversion Principle

  • Depend on abstractions, not concrete classes.

  • Example: Services injected using interfaces via DI container.

⮞ This is a perfect senior-level answer.


4. Program: Find Distinct Pairs That Sum to Target

C# Optimized Solution Using HashSet

public static void FindPairs(int[] nums, int target) { HashSet<int> seen = new HashSet<int>(); HashSet<string> printed = new HashSet<string>(); foreach (int num in nums) { int complement = target - num; if (seen.Contains(complement)) { int a = Math.Min(num, complement); int b = Math.Max(num, complement); string key = $"{a},{b}"; if (!printed.Contains(key)) { Console.WriteLine($"{a}, {b}"); printed.Add(key); } } seen.Add(num); } }

Example Output

For input:
[8, 7, 1, 6, 5, 3, 2, 2, 4, 5]
Target = 10

Output:

8, 2 7, 3 6, 4 5, 5


LTI Mind tree interview --Fail ---27-11-2025


1.String and String Builder 

2.Extension Method 

3.Middleware responsebality

4.CORS and CORS Policy in coding

5.Sequence of Filters

6.Student and Deparment Cross join how you write

7.in function have one Select query and update query how you manage 

8.React JS , What is Layout Effect

9.Hooks 


1. String vs StringBuilder

String

  • Immutable (value cannot change once created).

  • Every modification creates a new object → more memory + slow for repeated operations.

  • Use when values are small and rarely changed.

StringBuilder

  • Mutable (can modify without creating new objects).

  • Best for loops, concatenations, dynamic strings.

  • Faster & more memory-efficient for heavy string operations.


2. Extension Methods

  • Extension methods allow adding new methods to an existing class without modifying the class.

  • Defined inside a static class and must have static methods.

  • First parameter uses this keyword.

Example:

public static class MyExtensions { public static bool IsGreaterThan(this int value, int number) { return value > number; } }

Usage:

int x = 10; bool result = x.IsGreaterThan(5);

3. Middleware Responsibilities

Middleware in ASP.NET Core:

  • Processes HTTP requests and responses.

  • Executes in a pipeline sequence.

  • Can perform logging, authentication, routing, exception handling, caching, CORS, compression, etc.

  • Each middleware can pass the request to the next middleware or short-circuit the pipeline.


4. CORS and CORS Policy

CORS (Cross-Origin Resource Sharing)
Allows or blocks cross-domain API calls from browsers.

Example: Frontend on http://localhost:3000 calling API on http://localhost:5000.

CORS Policy Setup (ASP.NET Core)

Program.cs

builder.Services.AddCors(options => { options.AddPolicy("AllowReact", policy => policy .WithOrigins("http://localhost:3000") .AllowAnyHeader() .AllowAnyMethod()); });

Enable:

app.UseCors("AllowReact");

5. ASP.NET Core Filters Sequence

Order of execution (outer → inner → return):

  1. Authorization Filter

  2. Resource Filter

  3. Action Filter

  4. Exception Filter

  5. Result Filter

Memory trick: AR AER
Authorization → Resource → Action → Exception → Result


6. Student and Department Cross Join Query

SELECT S.StudentName, D.DepartmentName FROM Student S CROSS JOIN Department D;

No ON condition in CROSS JOIN → returns all combinations.


7. In a function if you have SELECT and UPDATE query, how to manage?

Answer:

  • Use Transaction to maintain data consistency.

  • If SELECT result is required for UPDATE, use BEGIN TRANSACTION.

  • If any failure occurs, rollback.

Example:

using (var tran = context.Database.BeginTransaction()) { var data = context.Students.FirstOrDefault(x => x.Id == 1); data.Name = "Updated Name"; context.SaveChanges(); tran.Commit(); }

Or in SQL:

BEGIN TRANSACTION; SELECT * FROM Student WHERE StudentID = 1; UPDATE Student SET Name = 'ABC' WHERE StudentID = 1; COMMIT;

8. In React JS, what is useLayoutEffect?

  • Similar to useEffect but runs synchronously after DOM updates and before the browser paints.

  • Used when:

    • You need to measure DOM elements (width/height).

    • You need to adjust UI before the screen is visible.

  • Prevents flickering.

Example:

useLayoutEffect(() => { console.log("Runs before paint"); });

9. Hooks in React

Hooks are functions that let you use React features in functional components.

Common Hooks:

  • useState → State management

  • useEffect → Side effects (API calls, timers)

  • useContext → Global state

  • useRef → Access DOM elements

  • useMemo → Performance optimization (memoized values)

  • useCallback → Memoized functions

  • useReducer → Complex state logic

  • useLayoutEffect → DOM measurements before paint




Comments

Popular posts from this blog

Show Toaster message Simple example in HTML

₹2.5 Lakh ki Alkaline Machine: Investment Ya Hype?" Japan Technology Wale Alkaline Water Systems: Science Ya Sirf Marketing? "Alkaline Water Machines — Health Ke Naam Par Business?

SQL interview questions