Synamedia
Dr Reddys Path Labs Interview Questions and Answers
Q1. What are the steps to create a basic POST API that handles all possible errors? What is marshalling? Also write test cases for api. Discuss all http status codes you know.
Creating a basic POST API with error handling, marshalling, test cases, and HTTP status codes.
Create a Node.js server using Express framework
Define a POST route that handles incoming requests
Implement error handling using try-catch blocks
Use marshalling to convert data between different formats (e.g. JSON to object)
Write test cases using a testing framework like Mocha and Chai
HTTP status codes: 200 (OK), 400 (Bad Request), 401 (Unauthorized), 404 (Not Found), 500 (Internal Se...read more
Q2. Given an array, how can you determine the frequency of a specific element and subsequently delete all occurrences of that element?
Use JavaScript methods to determine frequency and delete all occurrences of a specific element in an array of strings.
Use the reduce method to count the frequency of the specific element in the array.
Use the filter method to remove all occurrences of the specific element from the array.
Q3. What is function overriding, and how is it implemented in JavaScript?
Function overriding is a concept where a subclass provides a specific implementation of a method that is already provided by its superclass.
In JavaScript, function overriding can be achieved by defining a method in a subclass with the same name as a method in its superclass.
When an object of the subclass calls the overridden method, the subclass's implementation is executed instead of the superclass's.
This allows for customization and extension of behavior in subclasses while...read more
Q4. What is the process to create a basic connection to MongoDB?
To create a basic connection to MongoDB, you need to install the MongoDB driver, set up a connection string, and use the MongoClient to connect to the database.
Install the MongoDB driver using npm install mongodb
Set up a connection string with the MongoDB URI
Use the MongoClient to connect to the database
Q5. Can you demonstrate inheritance in JavaScript?
Yes, inheritance in JavaScript is achieved through prototype chaining.
In JavaScript, objects can inherit properties and methods from other objects through prototype chaining.
The prototype property allows objects to inherit properties and methods from another object.
Child objects can access properties and methods of their parent objects through the prototype chain.
Example: function Animal() {} Animal.prototype.eat = function() { console.log('Eating'); }; function Dog() {} Dog....read more
Q6. interchange 2 variable values , without using temporary variable
To interchange 2 variable values without using a temporary variable, you can use arithmetic operations.
Use addition and subtraction to swap values without a temporary variable.
Example: If a = 5 and b = 10, you can swap them using a = a + b and b = a - b.
Make sure to handle potential overflow or underflow when swapping values.
Q7. what is the use of static
Static is used to declare variables or methods that belong to the class rather than instances of the class.
Static variables are shared among all instances of a class.
Static methods can be called without creating an instance of the class.
Static keyword is used in Java, C++, and other programming languages.
Example: static int count = 0; // static variable
Q8. Parse json into an Object
Use a JSON parser to convert JSON data into an object in a programming language.
Use a JSON library or built-in functions in your programming language to parse the JSON data.
Map the JSON keys to object properties for easy access.
Handle any errors or exceptions that may occur during parsing.
Example: Using JSON.parse() in JavaScript to convert a JSON string into an object.
Interview Process at Dr Reddys Path Labs
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month