Frontend and Backend Development Interview Questions PDF
Document Details

Uploaded by NonViolentClematis
Tags
Summary
This PDF contains a comprehensive set of frontend and backend development interview questions covering a wide range of topics including JavaScript, React, CSS, and database management. Useful for those preparing for web development interviews. This document covers important concepts and is perfect for practice.
Full Transcript
Nettech Frontend Development Questions & Answers 1. What is the box model in CSS? When you create an element in a webpage, it has four layers: Content: The actual text or image inside. Padding: Space around the content. Border:...
Nettech Frontend Development Questions & Answers 1. What is the box model in CSS? When you create an element in a webpage, it has four layers: Content: The actual text or image inside. Padding: Space around the content. Border: A line surrounding the padding. Margin: Space outside the border to separate elements. Why is it important? The box model helps in designing layouts by controlling spacing and size. 2. What are semantic HTML tags? Semantic tags describe their purpose clearly. Examples: → Used for the top section of a page. → Represents an independent piece of content. → Used for the bottom section of a page. Why use them? They improve SEO, make the code easier to read, and help screen readers understand the page. 3. How can you make a website load faster? Minimize files: Reduce the size of images, CSS, and JavaScript. Use a CDN: A content delivery network loads files from servers close to users. Enable caching: Store files locally in the browser to avoid reloading them. Lazy loading: Load images only when they are needed. Nettech 1 4. What is event delegation in JavaScript? Instead of adding an event to every button, you add a single event to their parent. Example: If you have 100 buttons, you can add one event to the parent div, and it will handle clicks for all buttons inside it. Why use it? Improves performance Handles dynamic elements (new buttons added later still work) 5. What is a closure in JavaScript? A closure is when a function remembers the variables from its parent function even after the parent function is gone. Example: function outer() { let count = 0; return function inner() { count++; console.log(count); }; } let counter = outer(); counter(); // 1 counter(); // 2 Here, inner() remembers count even after outer() is finished. Why use closures? Keep data private (like a secure counter) Save memory Nettech 2 6. How do you handle asynchronous operations in JavaScript? Some tasks take time, like fetching data from a server. You handle them using: 1. Callbacks: A function inside another function. 2. Promises (.then() ): Waits for the task to complete. 3. async/await : A cleaner way to handle promises. Example (async/await): js CopyEdit async function fetchData() { let response = await fetch('https://api.example.com'); let data = await response.json(); console.log(data); } 7. What is the difference between React, Angular, and Vue? React → Fast, uses Virtual DOM, component-based. Angular → Complete framework, supports two-way data binding, used by large companies. Vue → Lightweight, simple, good for small projects. 8. How does the Virtual DOM work in React? The Virtual DOM is like a copy of the real webpage. React updates this copy first and then changes only the necessary parts in the real DOM. Why use it? Makes updates faster Reduces unnecessary re-rendering Nettech 3 9. What are hooks in React? Hooks let you use state and other features without writing class components. useState() → Stores and updates values. useEffect() → Runs code when the component updates. Example: js CopyEdit const [count, setCount] = useState(0); setCount(count + 1); // Updates count Backend Development Questions & Answers 10. What is the difference between REST API and GraphQL? REST API → Uses fixed URLs (e.g., /users/1 returns user 1). GraphQL → Lets the client ask for exactly the data it needs (more flexible). 11. What is middleware in backend development? Middleware is a function that runs between the request and the final response. Example: Logging requests Checking if a user is logged in before allowing access 12. How do you prevent SQL Injection? Use prepared statements (instead of inserting user input directly). Escape input data (sanitize values). Use ORM frameworks (like Sequelize in Node.js). Nettech 4 13. What is the difference between SQL and NoSQL databases? SQL (e.g., MySQL, PostgreSQL) → Uses tables and relationships. NoSQL (e.g., MongoDB, Firebase) → Stores data in JSON-like documents. 14. How does indexing improve database performance? An index is like a table of contents for a book—it helps find data faster. Without an index, the database searches all rows, which is slow. 15. What is the MVC architecture? It separates a web app into: Model → Handles data (Database). View → Displays data (UI). Controller → Processes user input and updates Model & View. 16. What is the role of a web server like Apache or Nginx? It receives user requests and sends back the correct webpage or data. Full Stack Development Questions & Answers 17. How do you deploy a web app on AWS or Azure? Set up a server (EC2 on AWS). Upload code (via Git, FTP). Set up a database (like MySQL or MongoDB). Configure security (firewalls, HTTPS). 18. How do you optimize a full-stack application? Use caching to reduce database queries. Minify and compress files for faster loading. Nettech 5 Use a CDN to serve static files. 19. What are common Git workflows? Feature branching → Each feature has its own branch. Git Flow → Uses main , develop , feature , release branches. 20. How do you handle Git conflicts? Use git diff to see changes. Manually edit conflicting files. Use git rebase or git merge. Advanced Topics 21. What is the difference between microservices and monolithic architecture? Microservices → The application is broken into small, independent services. Monolithic → The whole application is one big unit. 22. What are Docker containers? Docker creates lightweight, isolated environments to run applications. Why use it? Works the same on all computers. Reduces compatibility issues. 23. How do you implement OAuth authentication? OAuth lets users log in with Google, Facebook, etc. instead of creating new accounts. Users authorize the app to access their data. The app gets an access token to make API calls. Nettech 6 24. What are common web security vulnerabilities? SQL Injection → Injecting harmful code into databases. Cross-Site Scripting (XSS) → Injecting JavaScript into web pages. CSRF (Cross-Site Request Forgery) → Tricking users into performing actions. How to prevent them? Validate input Use HTTPS Sanitize user data MORE Frontend Development (HTML, CSS, JavaScript, React, Angular, Vue.js) 1. What is the difference between inline, block, and inline-block elements in HTML? Inline elements take up only as much space as needed (e.g., ). Block elements take the full width of the container (e.g., ). Inline-block elements behave like inline elements but allow setting width and height. 2. What are CSS Flexbox and Grid, and when should you use each? Flexbox is best for one-dimensional layouts (either row or column). Grid is better for two-dimensional layouts (both rows and columns). 3. How do you optimize website performance using CSS and JavaScript? Minimize CSS and JavaScript files, use lazy loading, optimize images, and use caching. 4. What are the key differences between React, Angular, and Vue.js? React is a lightweight UI library. Nettech 7 Angular is a full-fledged framework with built-in features. Vue.js is easy to learn and combines React’s and Angular’s best features. 5. How does React’s Virtual DOM improve performance? It updates only the changed parts of the UI instead of re-rendering the whole page. 6. What are hooks in React, and why are they useful? Hooks (e.g., useState , useEffect ) allow using state and lifecycle features in functional components. 7. How do you manage state in React applications? Using useState for local state and libraries like Redux for global state. 8. What is two-way data binding in Angular, and how does it work? It automatically updates the UI when the data changes and vice versa. 9. What are lifecycle methods in React and Angular? They control the component’s behavior at different stages, like mounting, updating, and unmounting. 10. How would you handle form validation in a frontend application? Using JavaScript validation methods or libraries like Formik in React. Backend Development (Node.js, Python, Java, PHP) 1. What is the difference between synchronous and asynchronous programming? Synchronous code runs step by step, while asynchronous code can run in parallel. 2. What are the advantages of using Node.js for backend development? It's fast, non-blocking, and great for real-time applications. 3. Explain the difference between RESTful APIs and GraphQL. REST sends multiple requests for different data, while GraphQL fetches all needed data in one request. Nettech 8 4. What is middleware in Express.js, and how does it work? Middleware functions process requests before they reach the final handler. 5. How does authentication work in a backend system? Using login credentials, sessions, or tokens like JWT. 6. Explain the concept of JWT (JSON Web Token) and how it's used for authentication. A JWT is a secure token that helps verify users without storing sessions. 7. What are microservices, and how do they differ from monolithic architectures? Microservices break an app into smaller services, while monolithic apps are built as a single unit. 8. How would you handle errors in a backend application? Using try-catch blocks, logging errors, and returning meaningful error messages. Database Management (MySQL, MongoDB, PostgreSQL) 1. What is the difference between relational and non-relational databases? Relational databases (SQL) store structured data, while non-relational databases (NoSQL) store flexible data. 2. How does indexing improve database performance? It speeds up search queries by creating a quick lookup structure. 3. What are transactions in databases, and why are they important? A transaction is a sequence of operations that must succeed together or fail together. 4. How would you optimize a database query for better performance? Using indexing, avoiding unnecessary columns, and optimizing SQL queries. Nettech 9 API & Third-Party Integration 1. How do you make API calls from a frontend application? Using fetch() , axios , or built-in browser APIs. 2. What is CORS (Cross-Origin Resource Sharing), and how do you handle it? CORS allows a web app to access resources from a different domain. 3. How would you integrate third-party authentication like Google or Facebook login? Using OAuth authentication and APIs like Firebase Auth. 4. What are WebSockets, and how do they differ from REST APIs? WebSockets allow real-time communication, unlike REST, which sends requests and responses. Debugging, Testing, and Optimization 1. How do you debug JavaScript code efficiently? Using console.log() , browser dev tools, and breakpoints. 2. What are unit tests, integration tests, and end-to-end tests? Unit tests check small pieces of code, integration tests check multiple components, and end-to-end tests check the full system. 3. Which tools do you use for testing frontend applications? Jest, Mocha, Cypress, and Selenium. 4. How do you test API endpoints in a backend system? Using Postman or automated tools like Jest and Supertest. 5. What are memory leaks in JavaScript, and how do you prevent them? They happen when unused memory isn’t released; prevent them by clearing event listeners and variables. 6. How do you optimize a web application for speed? Compress files, optimize images, use caching, and reduce HTTP requests. Nettech 10 Collaboration & Best Practices 1. How do you manage version control using Git? Using commands like git init , git add , git commit , and git push. 2. What is the difference between Git merge and Git rebase? Merge combines changes with a new commit, while rebase moves changes onto another branch. 3. How do you resolve merge conflicts in Git? By manually choosing which changes to keep and committing them. 4. What are Agile and Scrum methodologies, and how do they help in development? Agile is a flexible development approach, and Scrum is a framework for managing Agile projects. 5. How do you ensure security in a web application? Using HTTPS, validating user input, and preventing SQL injections and XSS attacks. 6. What steps do you take to improve code maintainability? Writing clean, well-documented code and following coding standards. These answers simplify complex topics into easy explanations. Let me know if you need more details! 🚀 4o You said: you wrote 55 questions but theres only 38 questions here ChatGPT said: You're right! I provided 38 questions instead of 55. Here are additional interview questions to cover more aspects of web development based on your requirements. Nettech 11 Frontend Development (More Questions) 1. What is the difference between localStorage, sessionStorage, and cookies? stores data permanently, sessionStorage clears data when the session localStorage ends, and cookies send data with every request. 1. How do you make a website responsive? Using media queries, flexible layouts, and CSS frameworks like Bootstrap or Tailwind. 1. What is the difference between relative, absolute, and fixed positioning in CSS? moves the element from its normal position, absolute positions it relative relative to the nearest ancestor, and fixed keeps it in place on the screen. 1. What are pseudo-classes and pseudo-elements in CSS? Pseudo-classes (e.g., :hover ) style elements based on state, while pseudo- elements (e.g., ::before ) style specific parts of an element. 1. What is the difference between ES5 and ES6 in JavaScript? ES6 introduced features like let , const , arrow functions, template literals, and modules. 1. What is event delegation in JavaScript? It allows handling events at a parent level instead of adding event listeners to individual child elements. 1. What are web components, and why are they useful? Web components are reusable UI elements built with custom elements, shadow DOM, and templates. 1. How do you handle browser compatibility issues in frontend development? Using feature detection ( Modernizr ), polyfills, and CSS prefixes. 1. What is lazy loading, and why is it used? Lazy loading loads images or resources only when needed, improving page performance. Nettech 12 Backend Development (More Questions) 1. What is the difference between MVC and MVVM architecture? MVC (Model-View-Controller) separates data, UI, and logic, while MVVM (Model-View-ViewModel) enhances UI handling with data binding. 1. What is a RESTful API, and how do you create one? A REST API follows HTTP methods (GET, POST, PUT, DELETE) to communicate between a client and a server. 1. What is the difference between NoSQL and SQL databases? SQL databases (MySQL, PostgreSQL) use structured tables, while NoSQL databases (MongoDB) store flexible JSON-like data. 1. What is an ORM, and why is it used in backend development? ORM (Object-Relational Mapping) allows interacting with databases using code instead of SQL (e.g., Sequelize, Mongoose, Hibernate). 1. What are the key differences between Python and PHP for backend development? Python is more readable and widely used in AI, while PHP is specialized for web applications. 1. What is a cron job, and when would you use it? A cron job is a scheduled task that runs at specific intervals, like sending emails or cleaning up databases. 1. What is rate limiting, and how do you implement it? Rate limiting controls the number of API requests a user can make, using tools like express-rate-limit in Node.js. 1. How do you handle file uploads in a web application? Using Multer in Node.js, Django FileField in Python, or move_uploaded_file() in PHP. Nettech 13