bridge global interview questions node,react, mongodb,psql,golang,ruby on rails developer 2024

By | 7 months ago

reactinterviewnodepsqlgolangcareerskochiruby on railsinfoparkbridge globalit jobsmern stack

Node.js

1. What is an Event Emitter?

  • **Answer:** An Event Emitter is a pattern used in Node.js that enables one part of your application to communicate with other parts by emitting events. It provides a way to register event handlers and trigger them when specific events occur. The `events` module in Node.js provides the `EventEmitter` class for this purpose.

2. What are decorators?

  • **Answer:** Decorators are functions that modify classes, methods, properties, or parameters at design time. Though not native in JavaScript, Node.js supports them via Babel or TypeScript. They provide metadata or functionality such as logging, validation, or security.

3. How does the Event Loop work in Node.js?

  • **Answer:** The Event Loop is a core mechanism that allows Node.js to perform non-blocking I/O operations. It queues and handles asynchronous callbacks, delegating tasks to the appropriate system resource and running callbacks on completion.

4. How can large computation be handled in the browser without blocking the UI?

  • **Answer:** Web Workers are used for running scripts in background threads. They allow computation to occur concurrently without blocking the main thread, thus keeping the UI responsive.

5. Explain a recent project in detail.

  • **Answer:** (Customize based on a specific project. E.g., "Developed a RESTful API using Node.js and Express for an e-commerce platform. Implemented authentication with JWT, optimized MongoDB queries for scalability, and integrated the API with a React frontend.")

PostgreSQL

1. How can you update a student's status to 1 if it's 0 and 0 if it's 1, in a single query?

  • **Answer:** You can use an SQL `CASE` statement in an `UPDATE` query:
UPDATE students SET status = CASE WHEN status = 0 THEN 1 ELSE 0 END

2. How do you find employees without projects, given tables for employees, projects, and project_employees?

  • **Answer:** Use a `LEFT JOIN` to find unmatched rows:
SELECT e.id, e.name FROM employees e LEFT JOIN project_employees pe ON e.id = pe.employee_id WHERE pe.employee_id IS NULL

3. How can you find the student with the second-highest marks?

  • **Answer:** You can use the `LIMIT` clause with an offset:
SELECT name, marks FROM students ORDER BY marks DESC LIMIT 1 OFFSET 1

Ruby on Rails

1. What is the difference between `find` and find_by_id?

  • **Answer:**

  • find: Raises an exception if a record is not found.

  • `find_by_id: Returns nil` if no record is found.

2. How do you set CSRF protection, and what is it?

  • **Answer:** Cross-Site Request Forgery (CSRF) protection prevents unauthorized actions on authenticated web applications. In Rails, enable it with `protect_from_forgery` in the ApplicationController. Tokens are included in forms or requests to ensure only authorized requests are processed.

Golang

What is a goroutine, and what is its advantage?

  • **Answer:** A goroutine is a lightweight thread managed by the Go runtime. Goroutines are cheaper than OS threads, allowing thousands to run concurrently. They enable high concurrency by being non-blocking and using channels for safe communication.