1 / 9

Full stack developer interview questions with answers for freshers_Credo Systemz

Indiau2019s First AI-Enhanced Full Stack Developer Program<br><br>Credo Systemz is the best Full Stack training institute in Chennai that offers advanced level practical based training.<br><br>Learn MEAN, MERN, Java spring, Python, and .NET Full Stack Development with hands-on projects, AI-powered learning tools and Job focussed training. Join us and become a industry-ready Full Stack Developer in 4 to 6 months.<br>

Swetha38
Télécharger la présentation

Full stack developer interview questions with answers for freshers_Credo Systemz

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Full stack developer interview questions with answers for freshers 1. Explain how promises work in JavaScript. A promise in JavaScript represents the eventual result of an asynchronous operation. It can be in one of three states: pending, fulfilled, or rejected. Promises allow for chaining .then() and .catch() methods to handle asynchronous code more cleanly than callbacks. 2. What is Docker, and how is it used in full stack development? Docker is a platform that uses containers to package an application with all its dependencies, ensuring consistency across different environments. Developers use Docker to create isolated environments for applications, making it easier to develop, test, and deploy code. 3. What is the difference between localStorage and sessionStorage in JavaScript? Both are part of the Web Storage API: localStorage stores data with no expiration date, meaning it persists even after the browser is closed. sessionStorage stores data for a single session (until the browser or tab is closed). 4. Explain the difference between SQL JOINs (INNER, LEFT, RIGHT, FULL) INNER JOIN: Returns records that have matching values in both tables. LEFT JOIN: Returns all records from the left table and matched records from the right table. RIGHT JOIN: Returns all records from the right table and matched records from the left table. FULL JOIN: Returns all records when there is a match in either the left or right table.

  2. 5. Explain CSRF and how to prevent it. CSRF (Cross-Site Request Forgery) is an attack where unauthorized commands are sent from a user that the website trusts. It can be prevented by: Using anti-CSRF tokens. Setting SameSite attribute for cookies. Requiring re-authentication for sensitive actions. 6. How do you ensure security in a full stack application? Key security practices include: Implementing authentication and authorization. Protecting against SQL injection and XSS. Using SSL/TLS for HTTPS. Applying CORS policies. Sanitizing inputs and encoding outputs. 7. How would you optimize a slow SQL query? Use indexes to speed up search queries. Avoid SELECT *, only select necessary columns. Use EXPLAIN to understand how the query is being executed. Minimize the use of subqueries, prefer JOINs when applicable. Optimize database schema (e.g., normalize or denormalize as needed). 8. How would you approach integrating third-party services (like payment gateways) into your application? Start by understanding the API documentation of the third-party service, ensuring that you have the required authentication mechanisms (e.g., API keys, OAuth tokens) in place. Use webhooks provided by the service to handle real-time events like payment confirmations or failed transactions.

  3. Ensure that the integration is secure by using HTTPS, validating responses from the third-party service, and avoiding sensitive data exposure (e.g., encrypt credit card information). 9. Implement bubble sort in JavaScript. function bubbleSort(arr) { let len = arr.length; for (let i = 0; i < len; i++) { for (let j = 0; j < len - i - 1; j++) { if (arr[j] > arr[j + 1]) { [arr[j], arr[j + 1]] = [arr[j + 1], arr[j]]; } } } return arr; } 10. Write a Python function to check if a linked list has a cycle. def hasCycle(head): slow, fast = head, head while fast and fast.next: slow = slow.next fast = fast.next.next if slow == fast: return True return False 11. Create a basic authentication middleware in Express (Node.js). function authMiddleware(req, res, next) { const token = req.headers[&#8216;authorization&#8217;]; if (token === &#8216;your-secret-token&#8217;) { next(); } else {

  4. res.status(403).send(&#8216;Unauthorized&#8217;); } } app.use(authMiddleware); 12. Write a function to remove duplicates from an array in JavaScript. function removeDuplicates(arr) { return [&#8230;new Set(arr)]; } console.log(removeDuplicates([1, 2, 2, 3, 4, 4])); 13. Find the longest word in a string using JavaScript. function longestWord(str) { let words = str.split(&#8216; &#8216;); return words.reduce((longest, word) => word.length > longest.length ? word : longest, &#8220;&#8221;); } console.log(longestWord(&#8220;Full stack developer interview questions&#8221;)); / 14. How to create a basic form validation in React?? function validateForm() { const [email, setEmail] = useState(&#8220;&#8221;); const [error, setError] = useState(&#8220;&#8221;); const handleSubmit = (e) => { e.preventDefault(); if (!email.includes(&#8216;@&#8217;)) { setError(&#8220;Invalid email&#8221;); } else { setError(&#8220;&#8221;); alert(&#8220;Form submitted&#8221;);

  5. } }; return ( <form onSubmit={handleSubmit}> <input type="text" value={email} onChange={(e) => setEmail(e.target.value)} /> {error &#038;&#038; <p>{error}</p>} <buttontype="submit">Submit</button> </form> ); } 15. How to find the depth of a binary tree in Python? class Node: def __init__(self, value): self.left = None self.right = None self.value = value def maxDepth(node): if node is None: return 0 else: left_depth = maxDepth(node.left) right_depth = maxDepth(node.right) return max(left_depth, right_depth) + 1 16. Merge two sorted arrays in JavaScript. function mergeSortedArrays(arr1, arr2) { return [&#8230;arr1, &#8230;arr2].sort((a, b) => a &#8211; b); } console.log(mergeSortedArrays([1, 3, 5], [2, 4, 6])); 17. How to make an HTTP GET request in React using fetch?

  6. useEffect(() => { fetch(&#8216;https://api.example.com/data&#8217;) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error(&#8216;Error fetching data:&#8217;, error)); }, []); 18. Write a Python function to check if a linked list has a cycle. def hasCycle(head): slow, fast = head, head while fast and fast.next: slow = slow.next fast = fast.next.next if slow == fast: return True return False 19. Create a basic authentication middleware in Express (Node.js). function authMiddleware(req, res, next) { const token = req.headers[&#8216;authorization&#8217;]; if (token === &#8216;your-secret-token&#8217;) { next(); } else { res.status(403).send(&#8216;Unauthorized&#8217;); } } app.use(authMiddleware); 20. Create a simple Todo App in React. function TodoApp() { const [todos, setTodos] = useState([]); const [newTodo, setNewTodo] = useState(&#8220;&#8221;);

  7. const addTodo = () => { setTodos([&#8230;todos, newTodo]); setNewTodo(&#8220;&#8221;); }; return ( <div> <input type="text" value={newTodo} onChange={(e) => setNewTodo(e.target.value)} /> <button onClick={addTodo}>Add</button> <ul> {todos.map((todo, index) => ( <li key={index}>{todo}</li> ))} </ul> </div> ); } 21. Create a function that returns the Fibonacci sequence up to n in Python. def fibonacci(n): sequence = [0, 1] while len(sequence) < n: sequence.append(sequence[-1] + sequence[-2]) return sequence[:n] print(fibonacci(5)) 22. Write a program to implement a stack in JavaScript. class Stack { constructor() {

  8. this.items = []; } push(element) { this.items.push(element); } pop() { return this.items.pop(); } peek() { return this.items[this.items.length &#8211; 1]; } isEmpty() { return this.items.length === 0; } } 23. Write a function to check if two strings are anagrams in JavaScript. function areAnagrams(str1, str2) { const format = str => str.replace(/[^\w]/g, &#8221;).toLowerCase().split(&#8221;).sort().join(&#8221;); return format(str1) === format(str2); } console.log(areAnagrams(&#8220;listen&#8221;, &#8220;silent&#8221;)); 24. Write a SQL query to fetch the second-highest salary from an “employees” table. SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM employees); 25. Implement a basic REST API with Express (Node.js).

  9. const express = require(&#8216;express&#8217;); const app = express(); app.use(express.json()); app.get(&#8216;/api/users&#8217;, (req, res) => { res.send([{ id: 1, name: &#8216;John&#8217; }]); }); app.listen(3000, () => { console.log(&#8216;Server is running on port 3000&#8217;); });

More Related