Krenai Services
MGHR Interview Questions and Answers
Q1. wap to print pyramid star pattern.
Print a pyramid star pattern using nested loops.
Use nested loops to print spaces and stars in each row
Increment the number of stars in each row to form a pyramid shape
Q2. What are procedures in sql.
Procedures in SQL are reusable blocks of code that perform a specific task.
Procedures are stored in the database and can be called multiple times.
They can accept input parameters and return output parameters.
Procedures can contain SQL statements, control-of-flow statements, and error handling.
Example: CREATE PROCEDURE GetEmployeeDetails AS SELECT * FROM Employees;
Example: EXEC GetEmployeeDetails;
Q3. Difference between == and .equals.
== is used for comparing reference equality, while .equals is used for comparing object equality in Java.
== compares memory addresses of objects
.equals compares the actual content of objects
== is used for comparing primitive data types
.equals is used for comparing objects in Java
Q4. What are sql joins.
SQL joins are used to combine rows from two or more tables based on a related column between them.
Joins are used to retrieve data from multiple tables in a single query.
Types of joins include INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN.
Example: SELECT * FROM table1 INNER JOIN table2 ON table1.id = table2.id;
Q5. Explain selection sort.
Selection sort is a simple sorting algorithm that repeatedly selects the minimum element from an unsorted portion of the array and swaps it with the first unsorted element.
Iterate through the array to find the smallest element.
Swap the smallest element with the first unsorted element.
Repeat the process for the remaining unsorted portion of the array.
Time complexity is O(n^2) and space complexity is O(1).
Q6. explain quick sort.
Quick sort is a sorting algorithm that uses divide and conquer approach to sort an array efficiently.
Divide the array into two sub-arrays based on a pivot element
Recursively sort the sub-arrays
Combine the sorted sub-arrays to get the final sorted array
Example: [3, 6, 8, 10, 1, 2, 1] -> [1, 1, 2, 3, 6, 8, 10]
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month