Try   HackMD

https://codewave16.github.io/interviewQuestion/


Question 1

import java.util.HashMap; public class PermutationDifference { public static int permutationDifference(String s, String t) { HashMap<Character, Integer> sIndexMap = new HashMap<>(); for (int i = 0; i < s.length(); i++) { sIndexMap.put(s.charAt(i), i); } HashMap<Character, Integer> tIndexMap = new HashMap<>(); for (int i = 0; i < t.length(); i++) { tIndexMap.put(t.charAt(i), i); } int difference = 0; for (char c : s.toCharArray()) { difference += Math.abs(sIndexMap.get(c) - tIndexMap.get(c)); } return difference; } }

Question 2

Answer : B


Question 3

SELECT CASE WHEN Grades.Grade < 8 THEN 'NULL' ELSE Students.Name END , Grades.Grade, Students.Marks FROM Students, Grades WHERE Students.Marks >= Grades.Min_mark AND Students.Marks <= Grades.Max_mark ORDER BY Grades.Grade DESC, Students.Name;

Question 4

WITH AvgAge AS ( SELECT rating, AVG(age) as avg_age FROM tblSailor GROUP BY rating ), MinAvgAge AS ( SELECT MIN(avg_age) as min_avg_age FROM AvgAge ) SELECT rating FROM AvgAge WHERE avg_age = (SELECT min_avg_age FROM MinAvgAge);

Question 5

pattern : 1 2 4 7 11 16 , next is 22 (+1 , +2 ,+3 , +4,+5,+6 ,if ansnwer >12 , answer - 12)
Answer : October


Question 6

class Solution { public int searchInsert(int[] nums, int target) { int left = 0, right = nums.length - 1; while (left <= right) { int mid = left + (right - left) / 2; if (nums[mid] == target) { return mid; } else if (nums[mid] < target) { left = mid + 1; } else { right = mid - 1; } } return left; } }


https://codewave16.github.io/interviewQuestion2/

Question 1: Inside which HTML element do we put the JavaScript?

​​​​Answer: <script>

Question 2: Which method can be used to find the length of a string in Java?

​​​​Answer: length()

Question 3: How do you create a function in JavaScript?

​​​​Answer: function myFunction()

Question 4: In Python, which of the following is used to define a block of code?

​​​​Answer: Indentation

Question 5: Which of the following is a correct syntax to output "Hello World" in Java?

​​​​Answer: System.out.println("Hello World");

Question 6: Which event occurs when the user clicks on an HTML element in JavaScript?

​​​​Answer: onclick

Question 7: How do you insert COMMENTS in Python code?

​​​​Answer: # This is a comment

Question 8: Which keyword is used to create a class in Java?

​​​​Answer: class

Question 9: What is the correct syntax for referring to an external script called "script.js"?

​​​​Answer: <script src="script.js">

Question 10: How do you create a variable with the floating number 2.8 in Python?

​​​​Answer: Both of the above

Question 11: Which method is used to start a thread in Java?

​​​​Answer: start()

Question 12: How do you declare a JavaScript variable?

​​​​Answer: var carName;

Question 13: What is the correct file extension for Python files?

​​​​Answer: .py

Question 14: How can you achieve inheritance in Java?

​​​​Answer: Using the extends keyword

Question 15: How do you write "Hello World" in an alert box in JavaScript?

​​​​Answer: alert("Hello World");

Section 2

Question 16:

SELECT pt.PetType, COUNT(p.PetId) AS Count FROM PetTable p JOIN PetTypeTable pt ON p.PetTypeId = pt.PetTypeId GROUP BY pt.PetType ORDER BY Count DESC;

Question 17:

public class Solution { public ListNode reverseList(ListNode head) { ListNode prev = null; ListNode current = head; while (current != null) { ListNode next = current.next; current.next = prev; prev = current; current = next; } return prev; } }

Section 3

Question 1 : What is @Bean in Spring Boot?

  • Annotation in Spring Framework.
  • Indicates a method produces a bean managed by Spring container.
  • Used in configuration classes.
  • Helps in defining beans programmatically.

Question 2 : What is Dependency Injection (DI) and Inversion of Control (IoC)?

Dependency Injection (DI):

  • Design pattern.
  • Objects receive other objects they depend on.
  • Enhances modularity and testability.
    Inversion of Control (IoC):
  • Principle in software engineering.
  • Control flow inverted, framework calls user's code.
  • DI is a specific implementation of IoC.
  • Promotes loose coupling.

Question 3 : How does a RESTful API work?

  • Uses HTTP requests for operations (CRUD: Create, Read, Update, Delete).
  • REST: Representational State Transfer.
  • Stateless communication.
  • Client-server architecture.
  • Resources represented by URIs.
  • Standard HTTP methods:
  • GET: Retrieve data.
  • POST: Create resource.
  • PUT: Update resource.
  • DELETE: Remove resource.

Question 4 : What is Spring Boot and what are its main features?

  • Framework for simplifying Spring application development.
  • Provides defaults for code and annotation configuration.
  • Main features:
  • Embedded servers (Tomcat, Jetty).
  • Simplified dependency management (via starter dependencies).
  • Auto-configuration.
  • Production-ready metrics and health checks.
  • Spring Boot CLI for rapid prototyping.

Question 5 : What is Docker and what are its basic components?

  • Platform for OS-level virtualization.
  • Packages software into containers.
  • Basic components:
  • Docker Engine:
    • Core software enabling containerization.
    • Includes Docker daemon, API, CLI.
  • Docker Hub:
    • Repository for Docker images.
    • Public and private image storage.
  • Docker Compose:
    • Tool for defining and running multi-container Docker applications.
    • Uses YAML file to configure application services.

Question 6 : What is CI/CD and why is it important?

  • CI (Continuous Integration):
    • Automates integration of code changes.
    • Ensures frequent and reliable integration.
    • Automated testing of code changes.
  • CD (Continuous Deployment/Delivery):
    • Automates deployment process.
    • Continuous Deployment: Code changes automatically deployed to production.
    • Continuous Delivery: Code changes automatically prepared for deployment.
  • Importance:
    • Speeds up release cycles.
    • Reduces manual errors.
    • Ensures consistent and reliable deployments.
    • Enhances collaboration among development teams.