Abhisheks 008-Hashn
Abhisheks 008-Hashn
Follow
Abhishek Sharma
Jul 25, 2023 · 42 min read
2
Table of contents
Data Structure and Algorithms [DSA]
Database Management Systems [DBMS]
Object Oriented Programming
Software Engineering
Operating System [OS]
Computer Networks
Coding Questions and Solutions
◆ Define Graph.
A graph G can be defined as an ordered set G(V, E) where V(G)
represents the set of vertices and E(G) represents the set of edges
that are used to connect these vertices. A graph can be seen as a
cyclic tree, where the vertices (Nodes) maintain any complex
relationship among them instead of having parent-child relations.
Path: A Path is the sequence of adjacent vertices connected by
the edges with no restrictions.
Cycle: A Cycle can be defined as the closed path where the initial
vertex is identical to the end vertex. Any vertex in the path can not
be visited twice
Circuit: A Circuit can be defined as a closed path where the initial
vertex is identical to the end vertex. Any vertex may be repeated.
◆ What is the difference between Null and Void?
INNER JOIN: Returns only the matching rows from both tables.
LEFT JOIN (or LEFT OUTER JOIN): Returns all rows from the left
table and matching rows from the right table.
RIGHT JOIN (or RIGHT OUTER JOIN): Returns all rows from the
right table and matching rows from the left table.
FULL JOIN (or FULL OUTER JOIN): Returns all rows when there is a
match in either the left or right table.
SELF JOIN: Joins a table with itself based on a related column.
CROSS JOIN: Produces a Cartesian product of rows from both
tables (all possible combinations).
NATURAL JOIN: Joins tables based on columns with the same
name, eliminating duplicate columns. (Less commonly used due to
ambiguity risks)
◆ Explain the differences between DELETE, TRUNCATE, and DROP
commands in SQL.
DELETE: Removes rows one by one from a table based on the
specified condition. It is a DML (Data Manipulation Language)
command and can be rolled back.
TRUNCATE: Removes all rows from a table in one shot. It is a DDL
(Data Definition Language) command and cannot be rolled back. It
also resets identity/auto-increment values.
DROP: Completely removes a table from the database, along with
its data and structure. It is a DDL (Data Definition Language)
command and cannot be rolled back.
◆ What is the role of the COMMIT and ROLLBACK statements in a
transaction?
COMMIT: The COMMIT statement is used to permanently save the
changes made in a transaction to the database.
ROLLBACK: The ROLLBACK statement is used to undo the
changes made in a transaction and restore the database to its
state before the transaction started.
◆ Aggregate Functions in SQL.
Aggregate functions in SQL are functions used to perform calculations
on sets of values and return a single result. Common aggregate
functions include SUM() , COUNT() , AVG() , MAX() , and MIN() .
◆ Write a SQL query to fetch data from multiple tables using JOIN.
COPY
◆ Display the first and last record from the Employee table.
COPY
◆ Write an SQL query for creating a new column named password for
each of the employees. Password format, the first three characters of
their name + the last three digits of their phone number.
COPY
UPDATE Employee
SET password = CONCAT(SUBSTRING(employee_name, 1, 3), RIGHT(phone_n
◆ Write a query to return the number of employees whose DOB is
between 01/01/1990 to 01/01/2001 and are grouped according to
gender.
COPY
Abstract Class:
An abstract class is a class that cannot be instantiated and serves
as a blueprint for other classes.
It may contain abstract methods (without implementation) and
concrete methods (with implementation).
Subclasses (derived classes) must provide implementations for all
abstract methods defined in the abstract class.
Interface:
An interface is a collection of abstract methods and constants.
It defines a contract for classes that implement it, specifying the
methods they must provide.
Classes can implement multiple interfaces, enabling multiple
inheritances in Java and other languages that support interfaces.
◆ What is Multithreading in Java?
Multithreading in Java is the ability of a program to execute multiple
threads (small units of a process) concurrently, allowing it to perform
multiple tasks simultaneously and make better use of available
resources. Each thread runs independently, and the Java Virtual
Machine (JVM) manages their execution, switching between them
rapidly to create the illusion of parallelism. Multithreading enhances the
performance of Java applications, especially in scenarios where tasks
can be executed concurrently, such as handling user interfaces,
background processing, or network communication.
◆ What is Thread in Java?
A thread in Java is the smallest unit of execution within a process. It
allows a program to perform multiple tasks simultaneously, making it
possible to achieve concurrent execution and better utilize CPU
resources. Threads share the same memory space and resources of
their parent process, but each thread has its own execution path,
allowing independent execution of code segments concurrently.
◆ What is Constructor in Java?
In Java, a constructor is a special method within a class that is
automatically called when an object of that class is created. It is used
to initialize the object's state and perform any setup operations
required for the object to function correctly. Constructors have the
same name as the class and do not have a return type, not even void.
They can be used to set default values, allocate memory, or perform
any other necessary tasks before the object is ready for use.
◆ What is Method in Java?
In Java, a method is a block of code that performs a specific task or
operation. It is a fundamental building block of object-oriented
programming. Methods are defined within classes and can be called to
execute the code they contain. They help in organizing and reusing
code, making programs more efficient and maintainable.
Example of a method that adds two numbers and returns the result:
COPY
Software Engineering
Computer Networks
left++;
right--;
}
COPY
public class PrintNumbersWithoutLoop {
COPY
System.out.println("Before swapping:");
System.out.println("num1 = " + num1);
System.out.println("num2 = " + num2);
System.out.println("\nAfter swapping:");
System.out.println("num1 = " + num1);
System.out.println("num2 = " + num2);
}
}
COPY
if (secondHighest != Integer.MIN_VALUE) {
System.out.println("Second highest element: " + secondH
} else {
System.out.println("Array does not have a second highes
}
}
COPY
import java.util.Scanner;
if (isPrime) {
System.out.println(number + " is a prime number.");
} else {
System.out.println(number + " is not a prime number.");
}
scanner.close();
}
return true;
}
}
if (index != -1) {
System.out.println("Element found at index: " + index);
} else {
System.out.println("Element not found in the array.");
}
}
}
return true;
}
return maxSum;
}
COPY
import java.util.HashSet;
return result.toString();
}
}
import java.util.Arrays;
import java.util.Scanner;
scanner.close();
}
import java.util.Arrays;
bubbleSort(arr);
COPY
class ListNode {
int val;
ListNode next;
ListNode(int val) {
this.val = val;
this.next = null;
}
}
public class ReverseLinkedList {
import java.util.Stack;
return dp[m][n];
}
int i = 0, j = 0, k = 0;
return mergedArray;
}
}
Written by
Abhishek Sharma
Programmer Analyst Trainee @Cognizant👨🏻💻 UEMK'23🎓 ML Enthusiast⚙️
Research & Innovation💡Open Source Mentor🥑
Follow
MORE ARTICLES
Abhishek Sharma
Abhishek Sharma
My Internship Experience at Cognizant
Technology Solutions
Cognizant is a multinational technology company that provides
information technology (IT) services a…
Abhishek Sharma
Write on Hashnode
Powered by Hashnode - Home for tech writers and readers