Interview questions for freshers

1. Difference between stack and queue?

  • Stack:

    • Follows Last In, First Out (LIFO) order.
    • Elements are added and removed from the same end (top).
    • Common operations: push (add to the top) and pop (remove from the top).
  • Queue:

    • Follows First In, First Out (FIFO) order.
    • Elements are added at one end (rear) and removed from the other end (front).
    • Common operations: enqueue (add to the rear) and dequeue (remove from the front).

2. Difference between Java and Javascript?

  • Java:

    • A general-purpose, object-oriented programming language.
    • Typically used for building standalone applications, backend systems, and Android apps.
    • Compiled language.
    • Strongly typed.
  • JavaScript:

    • A scripting language often used for web development.
    • Executed in web browsers.
    • Interpreted language.
    • Weakly typed.

3. Purpose of full-stack development and its details?

  • Full-stack development:
    • Involves working on both the frontend and backend of a web application.
    • Full-stack developers are proficient in both client-side and server-side technologies.
    • They can handle tasks from designing user interfaces to managing databases and server logic.

4. Write 10 different SQL commands?

  • SELECT * FROM table_name;
  • INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ...);
  • UPDATE table_name SET column1 = value1 WHERE condition;
  • DELETE FROM table_name WHERE condition;
  • CREATE TABLE table_name (column1 datatype, column2 datatype, ...);
  • ALTER TABLE table_name ADD column_name datatype;
  • DROP TABLE table_name;
  • SELECT DISTINCT column_name FROM table_name;
  • ORDER BY column_name ASC/DESC;
  • GROUP BY column_name HAVING condition.

5. Write 10 different databases.

  1. 1. MySQL
  2. 2. PostgreSQL
  3. 3. MongoDB
  4. 4. SQLite
  5. 5. Microsoft SQL Server
  6. 6. Oracle Database
  7. 7. Redis
  8. 8. Cassandra
  9. 9. Firebase Realtime Database
  10. 10.CouchDB

6. Difference between DBMS and RDBMS.

  • DBMS (Database Management System):

    • Manages databases but may not necessarily support relationships between tables.
    • Examples: Microsoft Access, SQLite.
  • RDBMS (Relational Database Management System):

    • Manages databases and enforces a tabular structure with relationships between tables.
    • Examples: MySQL, PostgreSQL, Oracle.

7. What is NoSQL and give an example?

  • NoSQL:
    • A type of database management system that does not follow the traditional relational database model.
    • Examples: MongoDB (document-oriented), Cassandra (wide-column store), Redis (key-value store).

8. What is normal form and how many normal forms are available?

  • Normal Form:
    • A set of rules to organize relational databases.
    • Think of a normal form as a set of rules to keep information in a database organized and prevent unnecessary repetition.
    • Common normal forms: 1NF, 2NF, 3NF, BCNF.

9. What is CRUD operation?

  • CRUD:
    • Acronym for Create, Read, Update, Delete.
    • Basic operations performed on databases.

10. What is the purpose of code indentation?

  • Code indentation:
    • Improves code readability.
    • Helps visually identify blocks of code.
    • Conveys the structure of the code.

11. What is an event in Javascript and give 10 examples?

  • Event in JavaScript:
    • In JavaScript, an event is something that happens in the browser, such as a user clicking a button, moving the mouse, pressing a key, or the page finishing loading. JavaScript allows you to respond to these events and execute specific code when they occur.

      Here are 10 examples of events in JavaScript:

      1. Click Event:

        • Occurs when a user clicks on an HTML element, like a button.
      2. Mouseover Event:

        • Triggers when the mouse pointer moves over an element.
      3. Keydown Event:

        • Fired when a user presses a key on the keyboard.
      4. Load Event:

        • Happens when the entire page, including its resources like images, has finished loading.
      5. Submit Event:

        • Triggered when a form is submitted.
      6. Change Event:

        • Occurs when the value of an input element changes (e.g., dropdown selection changes).
      7. Focus Event:

        • Fired when an element receives focus (clicked or selected).
      8. Resize Event:

        • Happens when the browser window is resized.
      9. Scroll Event:

        • Triggered when the user scrolls through the page.
      10. Unload Event:

        • Occurs when the user navigates away from the page.

12. What is a regular expression and give some examples?

  • Regular Expression:
    • A regular expression (regex) is like a special code that allows you to define a pattern to search for or manipulate text. It's a sequence of characters that creates rules for matching strings.

      Examples in Coding Language:

      1. Finding a Specific Word:

        • If you're coding and need to find the word "apple" in a text variable, a regex like /apple/ serves as a search pattern.
      2. Matching Numbers:

        • To extract numbers from a string, a regex like /[0-9]+/ becomes a rule, saying "grab one or more digits."
      3. Checking Email Addresses:

        • When validating an email format, a regex like /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/ defines the structure of a valid email.
      4. Dates and Formats:

        • In data processing, a regex like /^\d{2}\/\d{2}\/\d{4}$/ might ensure a date follows the "MM/DD/YYYY" format.
      5. Phone Numbers:

        • For parsing phone numbers, a regex like /(\d{3})[-.\s]?(\d{3})[-.\s]?(\d{4})/ sets rules for recognizing common formats.

13. What is GET and POST methods?

  • GET:

    • Requests data from a specified resource.
    • Data is sent in the URL.
  • POST:

    • Submits data to be processed to a specified resource.
    • Data is sent in the request body.

14. How to read a file using JavaScript?

  • Use the appropriate file system module (e.g., fs in Node.js) to read the contents of a file.

15. How to read a file using Java?

  • Use java.nio.file.Files to read the contents of a file.

16. How to read a file using Python?

  • Use open function to open and read the contents of a file in Python.
  • open(file_path, 'r') as file: # Read the content of the file content = file.read() # Print what you read print('File content:', content)

17. Different versions of JavaScript?

  • ES5, ES6 (ES2015), ES7, ES8, ES9, ES10, etc.

18. Different versions of HTML?

  • HTML 4, XHTML, HTML5.

19. Different versions of CSS?

  • CSS1, CSS2, CSS3.

20. What is ECMA Script and its versions?

  • ECMA Script: European Computer Manufacturers Association script.
    • A scripting-language specification upon which JavaScript is based.
    • Versions: ES1, ES2, ES3, ES4 (abandoned), ES5, ES6 (ES2015), ES2016, ....., ES14(2023)..

21. Difference between JavaScript and TypeScript?

  • JavaScript:

    • Dynamically typed.
    • No static types.
    • Runs in the browser.
  • TypeScript:

    • Statically typed.
    • Supports static types.
    • Needs to be compiled to JavaScript.

22. What is a cron job?

  • Cron Job:
    • A scheduled task on Unix-like operating systems.
    • Uses the cron syntax to specify the schedule.

23. Write 5 Linux commands?

  • 1. ls (list directory contents).
  • 2. cd (change directory).
  • 3. mkdir (create a directory).
  • 4. cp (copy files or directories).
  • 5. rm (remove files).

24. Write 5 Windows command line commands?

  • 1. dir (list directory contents).
  • 2. cd (change directory).
  • 3. mkdir (create a directory).
  • 4. copy (copy files or directories).
  • 5. del (delete files).

25. Difference between CMD and PowerShell in Windows?

  • CMD:

    • Traditional command prompt.
    • Limited scripting capabilities.
  • PowerShell:

    • Advanced shell with scripting capabilities.
    • Object-oriented and more powerful.

26. Write a program for 5 factorial?

  • The factorial of 5 is calculated as 5! = 5 x 4 x 3 x 2 x 1 = 120.
  • CODE:
  • function factorial(n) { let result = 1; for (let i = 1; i <= n; i++) { result *= i; } return result; } const result = factorial(5); console.log("The factorial of 5 using a for loop is: " + result);

27. Write a program to find if a number is odd or even?

  • Check if the number is divisible by 2. If yes, it's even; otherwise, it's odd.
  • CODE:
  • function checkOddOrEven(number) { if (number % 2 === 0) { console.log(number + " is an even number."); } else { console.log(number + " is an odd number."); } } checkOddOrEven(7);

 

Comments

Popular posts from this blog

Python program to sum up the Salary when the Name and Age matches with subsequent rows.

Typescript basics