Technical Interview Qns & Ans Blueprint
Technical Interview Qns & Ans Blueprint
( Java ☕)
1. What is Java?
Definition:
Explanation:
Definition:
Java is platform-independent due to the JVM (Write Once, Run Anywhere). It’s
object-oriented, secure (e.g., runtime exceptions handling), and supports
multi-threading for concurrent programming.
Explanation:
Java is commonly used in building banking systems where security and concurrency
are essential.
Definition:
JDK: Development kit with tools like compiler (javac), debugger, and libraries.
The JDK is like a full kitchen with tools and ingredients to cook a dish (write a
program), the JRE is like having pre-packed ingredients (ready to execute programs),
and the JVM is the chef that cooks (executes) the dish.
Definition:
Static variables are shared among all instances of a class, while instance variables
are unique to each object.
Explanation:
Definition:
Explanation:
A class Dog can inherit from a class Animal. The Dog class will have access to
Animal's methods (like eat()), but it can also add its own methods, like bark().
Definition:
Two types:
Runtime: Overriding the speak() method in classes like Dog and Cat where each
class has its own implementation.
Definition:
Explanation:
Abstract Class is like a template for a vehicle, while Interface is like a contract that
requires any vehicle to implement methods like startEngine().
Definition:
Yes, you can overload the main( ) method, but the JVM always starts execution with
the main(String[] args) signature.
Explanation:
You can write multiple main() methods with different parameter lists, but only the
standard one will be executed by the JVM.
Definition:
In a Car class, the engine variable is private, and you use public getter and setter
methods to access or modify the engine state, ensuring proper control over the data.
Definition:
Explanation:
11. What is the difference between an abstract class and an interface in Java?
Definition:
Abstract class: Can have both abstract and concrete methods. Supports inheritance
but not multiple inheritance.
Interface: Contains only abstract methods (pre-Java 8) or default methods (Java 8+).
Supports multiple inheritance. Think of an abstract class as a blueprint with partial
implementation, and an interface as a strict contract.
Explanation:
Think of an abstract class like a vehicle blueprint that might have some predefined
methods, while an interface is like a contract that forces a class to implement certain
methods (like startEngine()).
Definition:
A constructor initializes an object when it is created. It shares the class name and
has no return type.
Example Program:
String model;
Car(String model) {
this.model = model;
Explanation:
This code defines a Car class with an instance variable model to store the car's
model. The constructor Car(String model) initializes the model variable when a
Car object is created. For example, Car car1 = new Car("Tesla"); creates a
Car object with the model set to "Tesla". The constructor assigns this value to the
object's model instance variable.
Definition:
this refers to the current instance of the class. super refers to the parent class's
instance. Example: Using this to resolve instance variable conflicts and super to call
the parent class’s constructor or method.
Explanation:
this can be used to resolve conflicts between instance variables and method
names, while super is used to invoke the parent class constructor or method.
Definition:
Method overloading allows multiple methods in a class with the same name but
different parameter lists.
Example Program:
Explanation:
This code demonstrates method overloading in Java, where two methods with the
same name add are defined but differ in parameter types. The first method takes two
int parameters and returns their sum, while the second method takes two double
parameters and returns their sum. This allows the same method name to handle both
integer and floating-point addition. The method to be called is determined by the type
of arguments passed.
Definition:
Example Program:
class Animal {
Explanation:
This code demonstrates method overriding in Java, where the Dog class overrides
the sound() method of its parent class Animal. The sound() method in Animal
prints "Generic sound", while the overridden sound() method in Dog prints "Bark".
This allows the Dog class to provide its own specific implementation of the sound()
method.
16. What are the rules for overriding methods?
Definition:
The method must have the same name, return type, and parameters. The overriding
method cannot throw broader exceptions. It must not be less accessible (e.g., public
→ protected is not allowed).
Explanation:
Method overriding ensures that the subclass method behaves consistently with the
parent method by having the same name, return type, and parameters. Allowing
broader exceptions or more restrictive access would break the contract and introduce
inconsistencies. These rules maintain the integrity of the inheritance structure and
the principle of polymorphism.
Definition:
Explanation:
Definition:
Explanation:
Final variable: Once assigned a value, it cannot be reassigned (e.g., final int x
= 10;).
Final method: Prevents subclass methods from overriding it (e.g., final void
display() {}).
Final class: Prevents other classes from inheriting from it (e.g., final class
String {} prevents subclassing).
Definition:
Explanation:
Abstraction: A Car class might have a drive() method, but the internal workings
(engine, fuel) are hidden.
Encapsulation: The Car class has private fields like fuelLevel and provides
public methods like getFuelLevel() and setFuelLevel().
Definition:
A class is a blueprint (e.g., a Car template with attributes like color, speed), while an
object is its real-world instance (e.g., a red Ferrari). Classes define properties and
behavior, and objects bring them to life.
Explanation:
Class: A Car class might have properties like color, speed, and methods like
accelerate(), brake().
Object: An object of the Car class could be a red Ferrari, where the color is "red"
and the speed is 0 initially. This object will use the methods like accelerate() to
change its speed.
( C++ 👨🏻💻)
21. What is C++?
Definition:
Explanation:
Think of C++ as a powerful tool for building complex software systems, like a video
game or an operating system. It lets developers create reusable components that
interact with each other.
Definition:
Explanation:
Imagine C as a manual for building a car. It's all about the steps (functions). C++ is
the same manual but with added instructions on designing car parts (classes) and
managing how parts interact with each other (polymorphism, inheritance).
Definition:
The key difference is access control. In a struct, members are public by default,
while in a class, members are private by default.
Explanation:
Imagine a struct as a simple table where all the data is visible and accessible to
everyone. A class, on the other hand, is like a locked box where the data is hidden,
and you need keys (methods) to access it.
24. What are constructors and destructors in C++?
Definition:
A constructor is a special function that gets called when an object is created, while a
destructor is called when an object is destroyed.
Explanation:
Think of a constructor as the assembly line for building a car. When the car is
created, the constructor initializes it with specific features. A destructor is like the car
being dismantled when no longer needed.
Definition:
Operator overloading allows you to define how operators (like +, -, etc.) behave for
user-defined types.
Explanation:
In a real-world scenario, consider a calculator. When you press the "+" button, it
adds numbers, but when you press the "+" with strings, it concatenates them.
Operator overloading allows different types to behave differently.
Definition:
Explanation:
A "Shape" class might have a draw() function, but a derived "Circle" or "Rectangle"
class would have its own version of draw() that behaves differently.
27. What is the use of the new and delete keywords in C++?
Definition:
new is used to dynamically allocate memory, and delete is used to deallocate that
memory when it's no longer needed.
Explanation:
When you rent a car, you use new to get the car. When you're done, you use delete
to return the car and free up the space.
28. What is the difference between public, private, and protected access
specifiers?
Definition:
public members are accessible from anywhere, private members are accessible
only within the class, and protected members are accessible within the class and
derived classes.
Explanation:
Definition:
A pointer holds the memory address of another variable, allowing indirect access to
data.
Explanation:
Definition:
A reference is an alias for another variable, providing a way to access that variable
indirectly.
Explanation:
A reference is like calling someone by a nickname. The nickname refers to the same
person, just like a reference points to the same variable.
Definition:
malloc() is a C function for memory allocation that doesn't call constructors, while
new is a C++ operator that allocates memory and calls the constructor.
Explanation:
Using malloc() is like buying a car without getting it equipped with the necessary
parts. new is like getting a car fully equipped and ready to drive.
Definition:
Explanation:
Imagine a global library and a university library both having a book titled "C++
Basics". Using namespaces prevents confusion between the two.
Definition:
static can be used for variables and functions to limit their scope to the current file
or class. It can also be used to keep a variable's value between function calls.
Explanation:
A static variable in a function is like a memory bank that retains the amount of money
in a cash register after each customer leaves.
34. What is the difference between call by value and call by reference?
Definition:
Call by value: When calling by value, we send a duplicate of the parameter to the
functions. These duplicated values are given a new memory address, and any
modifications to these values have no impact on the variable used in the main code.
Call by reference: Here, we give a reference of the variable's address, and it uses
that address to find the actual argument that was used to call the function. Changes
to the parameter consequently have an effect on the passing argument.
Explanation:
Think of “call by reference” as sharing the original document with someone: If they
make changes, those changes are reflected in the same document.
Definition:
Explanation:
Definition:
Inheritance allows one class to acquire the properties and behaviors of another class.
It promotes code reusability.
Explanation:
A "Dog" class inherits from an "Animal" class. The "Dog" inherits basic properties
of an "Animal" (like being able to move or eat), but it also adds unique features like
barking.
Definition:
Explanation:
Imagine a remote control that can work with different devices like a TV or an air
conditioner. The remote sends the same signal (method), but each device reacts
differently (method override).
Definition:
Encapsulation is the concept of restricting direct access to certain data in a class and
providing public methods to access or modify that data.
Explanation:
Think of a bank account. The internal balance (data) is hidden from direct access,
and you use methods like deposit() or withdraw() to modify the balance safely.
Definition:
When a function of the same name, same arguments or parameters, and same
return type already present/declared in the base class is used in a derived class is
known as Function Overriding. It is an example of Runtime Polymorphism or Late
Binding which means the overridden function will be executed at the run time of the
execution.
Explanation:
When you visit the generic restaurant, you get standard dishes, but when you visit
the specialty restaurant, the overridden method ensures you receive specialty dishes
instead. The decision to execute the overridden method happens at runtime, based
on the restaurant type.
Definition:
Global variables, such as a session id, are helpful for data that is generally constant
or that must be used by several functions in the code. On the other hand, a local
variable has a restricted scope. It exists only within the block in which it was
declared. When the block ends, the variable is destroyed, and its values are lost.
Explanation:
Think of a shopping website. A global session ID is generated when a user logs into
the site. This session ID is accessible to various functions, such as addToCart(),
checkout(), and viewOrderHistory(), ensuring the user's actions are tied to their
account throughout the session.
Within the addToCart() function, a local variable like itemCount might be used to
temporarily store the count of items being added during that specific function call.
Once the function ends, this variable is no longer needed and is destroyed.
(C 🌐)
41. What is C?
Definition:
Explanation:
Definition:
Explanation:
Definition:
Functions in C are blocks of code designed to perform specific tasks. They help in
breaking down a complex problem into simpler tasks.
Explanation:
A function is like a machine that takes input (parameters), performs some task
(processing), and gives output (return value). For example, a vending machine
(function) takes money (input), dispenses a drink (output).
44. What is a pointer in C?
Definition:
A pointer is a variable that stores the memory address of another variable, enabling
indirect access to its value.
Explanation:
Definition:
Both increment the value of i, but ++i increments first and then returns the value,
while i++ returns the value first and then increments.
Explanation:
Think of ++i as someone filling a cup (increment) and immediately handing it to you
(return value). i++ is like someone handing you the cup (return value) and then
refilling it (increment).
Definition:
A structure is a user-defined data type that groups related variables of different types
into a single unit.
Explanation:
A structure is like a recipe card that contains ingredients of different types, such as
flour (int), sugar (float), and butter (char), bundled together to form a recipe.
Definition:
An array is like a row of mailboxes (elements) where each mailbox (array element)
contains a specific piece of mail (data). All mailboxes are of the same size and type.
Definition:
Explanation:
It’s like renting a car. You decide how much space you need (memory) at the time of
renting (runtime), and when you’re done, you return the car (memory deallocation).
Definition:
Explanation:
strcpy() is like transferring an entire document into another folder, while strncpy() is
like copying only the first few pages to avoid overflowing the folder.
Definition:
malloc() allocates memory but doesn't initialize it, whereas calloc() allocates
memory and initializes it to zero.
Explanation:
Think of malloc() as buying an empty box, and calloc() is like buying a box that
comes with everything inside it already sorted (initialized).
51. What is a NULL pointer in C?
Definition:
A NULL pointer is a pointer that doesn't point to any valid memory location.
Explanation:
A NULL pointer is like a GPS that doesn’t have a destination set. It’s not pointing to
any particular location.
Definition:
Recursion is a function calling itself in order to solve a smaller instance of the same
problem.
Explanation:
Recursion is like a person in front of a mirror, where each mirror reflects the next
mirror. The person keeps seeing a smaller reflection of themselves (recursive call)
until they reach a base condition.
Definition:
Explanation:
A macro is like a shortcut key on a keyboard. Instead of typing the full sentence, you
press a key combination that inserts the predefined text (macro).
Definition:
Storage classes define the lifetime, scope, and visibility of variables. The storage
classes are auto, register, static, and extern.
Explanation:
The storage class is like a filing system. auto is temporary, like a sticky note that
disappears after a while. static is like a permanent file in a drawer. extern is like
borrowing a file from another office.
Definition:
typedef is used to create new names for existing data types, making code more
readable.
Explanation:
typedef is like creating a nickname for a person. Instead of using their full name, you
can refer to them by a shorter, more familiar name.
Definition:
Explanation:
Definition:
Function overloading refers to the ability to define multiple functions with the same
name but with different parameters (in type, number, or both) within the same scope.
It allows the compiler to decide which function to call based on the arguments
passed.
C, however, does not support function overloading because it uses a simple
name-mangling mechanism for function names in the symbol table during
compilation. Each function in C is uniquely identified by its name only, without
considering its parameters. As a result, two functions with the same name would
conflict in the symbol table, causing an error.
Explanation:
Imagine a call center where each operator is identified by a single name (like
"Agent John"). If two people are named "John", the system would be confused
about which John should take the call because it doesn’t have any extra information
(like a department or role) to distinguish between them.
Definition:
Explanation:
Imagine you are pouring liquid from one container into another. If the two containers
are compatible (e.g., both are bottles of similar size), no special effort is needed. This
is like implicit typecasting. If the containers are incompatible (e.g., a large jar into a
small glass), you’ll need to adjust or carefully measure the quantity. This resembles
explicit typecasting, where manual intervention is required.
Definition:
When a function of the same name, same arguments or parameters, and same
return type already present/declared in the base class is used in a derived class is
known as Function Overriding. It is an example of Runtime Polymorphism or Late
Binding which means the overridden function will be executed at the run time of the
execution.
Explanation:
When you visit the generic restaurant, you get standard dishes, but when you visit
the specialty restaurant, the overridden method ensures you receive specialty dishes
instead. The decision to execute the overridden method happens at runtime, based
on the restaurant type.
Definition:
Explanation:
Think of #include like a reference or citation in a book. When writing a report, you
may refer to another book or research paper for additional information. Similarly, in a
C program, #include allows you to bring in external code or libraries so that you can
use their functionality without rewriting them.
( Python 🐍)
61. What is Python?
Definition:
Explanation:
Python is often used for building web applications, like Instagram or Dropbox. Its
simplicity and readability allow developers to quickly create features like user login or
image
Definition:
Explanation:
Definition:
A list is a mutable, ordered collection of items and they are versatile and can store
multiple types of data.
Explanation:
A list is like a shopping cart that can hold multiple items. You can add or remove
products (elements), and the list maintains their order.
64. What is a tuple in Python?
Definition:
Explanation:
Definition:
The primary difference is that lists are mutable (can be changed), while tuples are
immutable (cannot be changed).
Explanation:
Think of a list as a grocery list you can edit, while a tuple is like a menu from a
restaurant that you can't change.
Definition:
Explanation:
A dictionary is like an address book, where you store names as keys and phone
numbers as values.
Definition:
self refers to the instance of the class, allowing access to its attributes and methods.
Explanation:
Think of self as the reference to your personal notebook when you're writing down
notes about your life (attributes and behaviors). In a class, self allows you to refer to
the current object instance.
Definition:
shallow copy creates a new object but does not copy nested objects, whereas deep
copy recursively copies nested objects.
shallow copy: Modifying a nested element in the copied object affects the original.
deepcopy: The original object remains unaffected after modifying the nested
elements.
Explanation:
Consider you have a notebook with pages, and you make a shallow copy. Both
notebooks share the same pages, so if you modify a page in one notebook, it
changes in both. A deep copy creates a completely separate notebook.
Definition:
Lambda functions are anonymous, small, and defined using the lambda keyword.
Explanation:
A lambda function is like a quick, one-off helper tool you use once in a while, like a
calculator for a quick sum.
Definition:
Set: A set is a collection of unique, unordered elements. It does not allow duplicate
items, and elements cannot be accessed by indexing. Sets are useful for operations
like union, intersection, and difference.
Dictionary: A dictionary is a collection of key-value pairs, where each key is unique,
and each key maps to a corresponding value. Keys are immutable (like strings or
numbers), but values can be mutable or immutable.
Explanation:
A set is like a bag of unique coins. You can quickly check if a particular coin is
present in the bag, but the order of coins doesn't matter.
A dictionary is like a contact list on your phone. Each name (key) maps to a phone
number (value). You can quickly retrieve someone's phone number by looking up
their name.
Definition:
A generator is a special type of iterator that generates values on the fly using the
yield keyword.
Explanation:
A generator is like a vending machine that gives one item at a time. You ask for a
product, and the machine gives you one, instead of giving everything at once.
Definition:
In Python, pass is a statement that does nothing. It acts as a placeholder and is used
when a statement is syntactically required but no action is needed. This is especially
useful when writing code structures where the implementation is incomplete or
planned for later.
Explanation:
Think of pass as a reserved "to-do" note. For instance, in a meeting agenda, you
might allocate time for a discussion but decide to skip it for now. Similarly, pass
allows you to define a block of code that is temporarily empty, without causing a
syntax error.
73. In Python, how do you overload methods or constructors?
Definition:
Explanation:
Think of a customer service desk where a single representative can handle different
kinds of requests based on the details provided by the customer. For example:
If a customer provides their name and ID, the representative processes their request.
If a customer provides only their name, the representative asks for additional
information.
Definition:
Explanation:
Exception handling is like having a backup plan for unforeseen situations during code
execution. For example: Imagine you're withdrawing money from an ATM. If the
machine runs out of cash, it displays an error message instead of malfunctioning.
Similarly, in Python, exceptions provide a way to respond to errors without crashing
the program.
75. What is the purpose of the "init" method in Python?
Definition:
The __init__ method in Python is a special method (often called the constructor) that
is automatically invoked when a new object of a class is created. Its primary purpose
is to initialize the attributes of the object and set up any necessary data or
configurations.
Explanation:
Definition:
List Comprehension: A concise way to create lists by iterating over an iterable and
optionally applying conditions or transformations.
Explanation:
List Comprehension: Imagine you want to calculate the areas of square tiles, each
with side lengths from 1 to 5. The list comprehension makes this calculation concise.
Definition:
The Python with statement is designed to simplify resource management, such as file
handling or database connections. It ensures that resources are properly acquired
and released (e.g., closing a file or releasing a lock) without requiring explicit cleanup
code, even if exceptions occur.
Explanation:
Definition:
Decorators in Python are functions or classes that modify the behavior of another
function, method, or class without permanently altering its source code. They allow
you to wrap another function (or class) to add functionality before or after its
execution.
Explanation:
Imagine you're building a restaurant management system, and you want to ensure
every order processing function logs the time of the request for auditing purposes.
Instead of adding logging code to every function, you can use a decorator to handle
this logging.
Definition:
Explanation:
Definition:
Explanation:
Imagine you have a long bookshelf filled with books, and you only want books 2
through 5 from the shelf. Instead of removing all the books and then picking the ones
you need, you can directly select only that range.
In Python, slicing works similarly by allowing you to extract just the portion of data
you need from a larger sequence without modifying the original data.
( SQL 🗄️)
81. What is SQL?
Definition:
Explanation:
Imagine you're working at an e-commerce company, and the company has a large
database containing customer information, orders, and products. To retrieve
customer data, place an order, or generate reports, SQL is used. For example, a
query like SELECT * FROM Customers WHERE country = 'USA'; helps you fetch
all customers from the USA.
Definition:
Explanation:
Think of a library system where information about books, authors, and members is
stored in a database. The library's database helps manage data like which books are
available, who has borrowed a book, and what the overdue fines are. By using a
DBMS, the library can easily retrieve data like the list of books by a specific author or
find out how many books a member has borrowed.
Definition:
A JOIN is a SQL operation used to combine data from two or more tables based on a
related column between them.
INNER JOIN: Returns only the rows that have matching values in both tables.
LEFT JOIN (or LEFT OUTER JOIN): Returns all rows from the left table and
matching rows from the right table, with NULLs where no match exists.
RIGHT JOIN (or RIGHT OUTER JOIN): Returns all rows from the right table and
matching rows from the left table, with NULLs where no match exists.
FULL JOIN (or FULL OUTER JOIN): Returns rows when there is a match in one of
the tables; NULLs where there is no match.
Explanation:
Think of a library system with two tables: one for Books and another for Authors. If
you wanted to find out which author wrote which book, you'd use a JOIN to combine
the data from both tables.
Definition:
Aggregate functions are functions that perform a calculation on a set of values and
return a single result.
MAX(): Returns the largest value in a set. These functions are often used with the
GROUP BY clause to summarize data.
Explanation:
In a retail store, you might want to find the total sales, average price of items, and the
number of items sold during a specific time period. Using aggregate functions like
SUM(), AVG(), and COUNT(), you can calculate these values
Definition:
Both WHERE and HAVING are used to filter records in SQL, but they are used in
different contexts.
WHERE: Filters rows before any grouping is done. It is used to filter rows from a
table before any aggregate functions are applied.
HAVING: Filters records after grouping has been done. It is typically used with
aggregate functions to filter groups of records.
Explanation:
If you have a Sales table and want to find all employees who have made more than
$10,000 in sales, you'd use WHERE. However, if you're grouping sales data by
employee and want to filter groups with sales greater than $10,000, you'd use
HAVING.
Definition:
Explanation:
Definition:
A primary key is a unique identifier for a record in a table, ensuring that each record
is distinct and identifiable.
Explanation:
In an Employees table, each employee needs a unique identifier. A primary key like
employee_id ensures that each employee record is distinct (unique).
88. What is a foreign key in SQL?
Definition:
A foreign key is a field (or combination of fields) in one table that uniquely identifies
a row of another table.
Explanation:
Consider a database with two tables: Orders and Customers. The Orders table has
a column customer_id that refers to the Customers table's id. This establishes a
relationship between the two tables. The customer_id in the Orders table is a
foreign key.
Definition:
A subquery is a query nested inside another query, which can be used to return a
value that will be used in the outer query.
Explanation:
In an e-commerce database, you may want to find the orders placed by customers
who have spent more than $1000. You could first write a subquery to find the
customers who spent more than $1000 and then use that subquery in the outer query
to find their orders.
Definition:
TRUNCATE: Removes all rows from a table but does not log individual row deletions.
DELETE: You want to remove all Orders from a specific customer but keep the rest
of the data intact.
TRUNCATE: You want to remove all rows from the Orders table quickly, without
logging individual row deletions.
DROP: You want to completely remove the Orders table and all its data from the
database.
Definition:
An index is a data structure used to improve the speed of data retrieval operations
on a table at the cost of additional space.
Explanation:
Imagine you have a Customers table with millions of records, and you frequently
query the table to find customers by their email. To speed up this search, you could
create an index on the email column.
Definition:
SQL constraints are rules applied to columns or tables to ensure the accuracy and
integrity of data.
FOREIGN KEY: Ensures the value in one table corresponds to a valid record in
another table.
In an online banking system, you might want to ensure that account balances cannot
be negative. You can use a CHECK constraint to enforce this
Definition:
Transactions ensure data integrity in a database. They follow the ACID properties
(Atomicity, Consistency, Isolation, Durability) to guarantee that a transaction is
completed successfully or rolled back if an error occurs.
Explanation:
Definition:
The GROUP BY clause is used in SQL to group rows that have the same values into
summary rows.
Explanation:
In a sales database, you may want to calculate the total sales per product category.
You would group the data by category and then use an aggregate function like SUM
to calculate the total sales.
95. What is the difference between UNION and UNION ALL in SQL?
Definition:
UNION: Combines the results of two or more queries and removes duplicate rows.
UNION ALL: Combines the results of two or more queries but does not remove
duplicates.
Explanation:
Suppose you have two tables: OnlineSales and OfflineSales. You want to combine
both tables to get a list of all sales, but you want to exclude duplicates. You would
use UNION. If you want to include duplicates, you would use UNION ALL.
Definition:
CHAR is best used for data that has a consistent length, such as country codes (e.g.,
"IN", "US"), fixed-length IDs, etc.
VARCHAR2 is best used for data with variable lengths, such as names, addresses,
or descriptions.
Explanation:
Imagine you have a customer database with a column for storing state codes (2
characters) and a column for storing customer names.
State Code (CHAR): Since state codes are always 2 characters (e.g., "NY", "TX"),
you would use CHAR(2) for the state code. This ensures that even if a code is 1
character long (e.g., "A"), it will still occupy 2 characters and pad with a space (e.g.,
"A ").
Customer Name (VARCHAR2): For a customer's name, the length varies from
person to person (e.g., "John" to "Alexander Smith"). You would use VARCHAR2 to
save space by only using the exact number of characters needed to store the name
without padding.
Definition:
A view is a virtual table based on the result of a SQL query. It does not store data
physically but displays data from one or more tables.
Explanation:
In a university database, you might have tables for Students, Courses, and
Enrollments. To simplify querying, you create a view that combines information from
these tables to show a list of students with their courses.
Explanation:
SQL is like the English language that helps us communicate with the database,
while MySQL is like a tool or machine that executes the instructions written in SQL.
Definition:
SQL databases are relational databases that use structured tables to store data.
They follow a predefined schema and are best suited for transactional data.
NoSQL databases are non-relational and store unstructured data. They do not have
a fixed schema and are designed to scale out horizontally.
Explanation:
If you were to store data for an online retail store, SQL would be best for storing
order details (structured, with a clear relationship between customers and orders),
whereas NoSQL would be better for storing user-generated content, like
comments or logs, where the data structure can change over time.
Definition:
MySQL is a relational database management system (RDBMS) that uses SQL for
querying data and organizes data in tables with rows and columns.
Explanation:
Definition:
PostgreSQL is an open-source RDBMS known for its advanced features like support
for JSON data types, full-text search, and complex queries.
NoSQL databases are non-relational and store unstructured data. They do not have
a fixed schema and are designed to scale out horizontally.
Explanation:
For a simple website, MySQL may be preferred for its simplicity and speed, but for
an enterprise application that requires complex data relationships, large datasets,
or advanced analytics, PostgreSQL may be a better choice due to its richer set of
features.
( DSA 📟)
102. What is Binary Search?
Definition:
Binary search is an efficient algorithm for finding an item from a sorted list by
repeatedly dividing the search interval in half. If the value of the search key is less
than the item in the middle, the search continues in the lower half, or in the upper half
if the value is greater.
Explanation:
Consider looking for a name in a phone book. Instead of going through each name
one by one, you would start in the middle of the phone book, check if the name
you're looking for is before or after, and continue halving the search space until you
find the name.
Definition:
Explanation:
Think of sorting players by score in a game. Starting with the first player, you
compare each pair of players, and if a higher score is found, you swap their
positions. You repeat this process until the players are arranged in descending order.
Definition:
Selection sort is a sorting algorithm that repeatedly selects the smallest (or largest,
depending on sorting order) element from the unsorted portion and swaps it with the
first unsorted element.
Explanation:
Consider organizing a line of people by height. You start with the first person, find
the shortest person in the group, and swap positions. Then, you repeat this process
for the next person until everyone is arranged by height.
Definition:
Insertion sort is a simple sorting algorithm where the list is built one item at a time. It
takes each element from the unsorted portion and inserts it into its correct position in
the sorted portion.
Explanation:
Think of sorting playing cards. When you pick up a new card, you place it in the
correct position among the cards already in your hand, keeping the hand sorted at all
times.
Definition:
Merge sort is a divide-and-conquer algorithm that splits the list into halves,
recursively sorts each half, and then merges the sorted halves to produce the sorted
list.
Explanation:
Imagine you have two sorted lists of books by genre (one for science and one for
history). Merge sort combines these lists into one sorted list by alternating the books
from each genre.
Definition:
Linear search is a simple algorithm that checks every element in the list until the
target element is found or the entire list has been searched.
Explanation:
Definition:
A stack is a linear data structure that follows the Last In First Out (LIFO) principle,
where elements are added and removed from the top of the stack.
Explanation:
Think of a stack of plates. The last plate placed on top of the stack is the first one to
be taken off.
Definition:
A queue is a linear data structure that follows the First In First Out (FIFO) principle,
where elements are added at the rear and removed from the front.
Explanation:
A line at a movie theater is a queue. The first person to get in line is the first one to
be served.
Definition:
Explanation:
Think of sorting a group of people by age. You pick a "pivot" person, and everyone
older than them goes to one side, and everyone younger goes to the other side. You
repeat this process for each group.
111. What is a Dequeue?
Definition:
A dequeue (or double-ended queue) is a data structure that allows insertion and
deletion of elements from both ends, either from the front or the back.
Explanation:
A waiting line at a customer service counter where customers can either join the
line at the front or leave the line from the back.
CODING QUESTIONS FREQUENTLY ASKED IN
TECHNICAL INTERVIEWS
➢ Fibonnaci Series
➢ Armstrong Number
➢ Palindrome Number
➢ Palindrome String
➢ Reverse a String
➢ Reverse a Number
➢ Factorial of a number
➢ Prime or not
➢ Perfect Number or not
➢ Two Strings are Anagram or not
➢ Calculate frequency of characters in a String
➢ Maximum element in an Array
➢ Minimum element in an Array
➢ Reverse an Array
➢ Second Largest element in an Array
➢ Second Smallest element in an Array
➢ Sort an Array
➢ Missing number in an Array
➢ Duplicate in an Array
➢ Remove all characters from string except alphabets