Technical Interview Questions
Technical Interview Questions
Database Concepts:
6. What is normalization?
o Normalization is the process of organizing data in a database to reduce
redundancy and improve data integrity. It involves dividing large tables
into smaller, related tables and defining relationships between them
according to rules designed to safeguard the data and make the database
more efficient.
7. What is DDL and DML?
o DDL (Data Definition Language) includes SQL commands like CREATE, DROP,
and ALTER used to define or modify data structures. DML (Data Manipulation
Language) includes commands such as SELECT, INSERT, UPDATE, and DELETE,
used to manage data within those structures.
8. Difference between DELETE, TRUNCATE, and DROP
o DELETE removes rows from a table based on the condition provided and can
be rolled back.
o TRUNCATE removes all rows from a table, resetting the table to empty
(faster than DELETE and cannot be rolled back).
o DROP completely removes the entire table structure and its data from
the database, which cannot be rolled back.
9. MySQL vs Oracle
o MySQL is an open-source relational database management system known for
its ease of use and speed, ideal for small to medium applications. Oracle
Database is a comprehensive, multi-model database management system
known for its feature-rich, enterprise-scale capabilities, supporting large
applications and businesses.
10. Types of databases
o Relational databases: Store data in tables and rows, using SQL for
data manipulation (e.g., MySQL, PostgreSQL).
o NoSQL databases: Designed for specific data models and have flexible
schemas for building modern applications (e.g., MongoDB, Cassandra).
o In-memory databases: Store data in main memory to facilitate faster
response times (e.g., Redis, SAP HANA).
o Distributed databases: Spread data across multiple servers or locations,
providing high availability and redundancy (e.g., Apache Cassandra).
11. What is NoSQL?
o NoSQL databases are non-tabular databases designed to store large volumes of
data in ways other than the relational model. These types include document,
key-value, wide-column, and graph databases. They provide flexible schemas
and scale easily with large amounts of data and high user loads.
12. Difference between unique and primary key in SQL
o A primary key uniquely identifies each record in a table and cannot be NULL.
A unique key also ensures uniqueness for a column or set of columns, but
unlike a primary key, it can accept one NULL value.
13. Hashmap and hashtable
o In the context of database terminology, these terms are often used to describe
data structures in programming. A hashmap is a data structure that uses a hash
function to compute an index into an array in which an element will be found
or inserted. A hashtable is a type of hashmap that is synchronized.
14. SQL update query
o Here’s an example of an SQL UPDATE query:
UPDATE Employees
SET Email = 'new.email@example.com'
WHERE EmployeeID = 1;
15. What are different types of joins?
o INNER, LEFT, RIGHT, FULL OUTER JOIN.
def reverse_string(s):
return s[::-1]
def is_palindrome(s):
return s == s[::-1]
def reverse_integer(n):
return int(str(n)[::-1]) if n >= 0 else -int(str(-n)[::-1])
def fibonacci(n):
a, b = 0, 1
series = []
while len(series) <
n:
series.append(a)
a, b = b, a + b
return series
def is_prime(n):
if n <= 1:
return False
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return True
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n-1)
def classify_grade(score):
if score > 70:
if score >= 90:
return "Excellent"
elif score >= 80:
return "Very Good"
else:
return "Good"
else:
return "Needs Improvement"
24. Code for separating vowels from a string
def extract_vowels(s):
vowels = 'aeiouAEIOU'
return ''.join([char for char in s if char in vowels])
25. Code for adding two numbers without using a temporary variable
26. Write a program to add first and last digit of the given number (1234)
def add_first_last(n):
n_str = str(n)
return int(n_str[0]) + int(n_str[-1])
def merge_sort(arr):
if len(arr) > 1:
mid = len(arr) // 2
L = arr[:mid]
R = arr[mid:]
merge_sort(L)
merge_sort(R)
i = j = k = 0
class Node:
def init (self, key):
self.left = None
self.right = None
self.val = key
def print_inorder(root):
if root:
print_inorder(root.left)
print(root.val, end=' ')
print_inorder(root.right)
def print_preorder(root):
if root:
print(root.val, end=' ')
print_preorder(root.left)
print_preorder(root.right)
def print_postorder(root):
if root:
print_postorder(root.left)
print_postorder(root.right)
print(root.val, end=' ')
def find_last_vowel(word):
vowels = 'aeiouAEIOU'
for char in reversed(word):
if char in vowels:
return char
return None
def find_largest_word(sentence):
words = sentence.split()
return max(words, key=len)
33. Write a code to convert Celsius to Fahrenheit
def celsius_to_fahrenheit(c):
return (c * 9/5) + 32
def array_to_string_array(arr):
return [str(element) for element in arr]
35. Write code to swap variables with and without temporary variables
import numpy as np
def transpose_matrix(M):
return np.transpose(M)
import heapq
while priority_queue:
current_distance, current_node =
heapq.heappop(priority_queue)
def count_palindromes(strings):
return sum(1 for string in strings if string == string[::-1])
def find_maximum(arr):
return max(arr)
40. Code for method overloading (in Java since Python does not support method
overloading by default)
41. Python program code to remove empty inner lists from a nested list
def remove_empty_lists(nested_list):
return [elem for elem in nested_list if elem]
def remove_duplicates(lst):
return list(set(lst))
OOPS
50. Inheritance
def speak(self):
pass
51. Encapsulation
print(message)
def get_balance(self):
return self. balance
o Encapsulation: Bundling the data and methods that operate on the data within
one unit and hiding details from outside modules.
o Inheritance: Mechanism where a new class is derived from an existing class,
inheriting its features and potentially adding new features or modifying
existing ones.
o Polymorphism: The ability of different objects to be accessed through
the same interface, typically by overriding methods.
o Abstraction: The concept of hiding complex reality while exposing only the
necessary parts. It is closely related to encapsulation.
Overloading: Occurs when two or more methods in one class have the same method
name but different parameters. Overloading is related to compile-time (or static)
polymorphism.
Overriding: Involves redefining a method in a subclass that has already been defined
in the superclass. It is a part of runtime (or dynamic) polymorphism.
# Overriding example
class Parent:
def say_hello(self):
return "Hello from Parent"
class Child(Parent):
def say_hello(self): # Overriding the Parent class method
return "Hello from Child"
54. How one class inherits from another and its types
A class can inherit from another class by simply passing the parent class as a
parameter to the child class. The different types of inheritance include:
o Single Inheritance: A child class inherits from one parent class.
o Multiple Inheritance: A child class inherits from more than one parent class.
o Multilevel Inheritance: A form of inheritance where a class is derived from a
child class, making it a grandchild class.
o Hierarchical Inheritance: Several derived classes inherit from a single base
class.
o Hybrid Inheritance: A combination of two or more types of inheritance.
# Example of single inheritance
class Parent:
pass
Web Technologies:
Here’s a simple example using Python’s requests library to interact with a REST API:
import requests
● A responsive website automatically changes to fit the device you’re viewing it on.
Typically, responsive design uses CSS media queries to change styles based on the
target device such as display type, width, height, etc., to ensure that web content looks
and works well on all screen sizes and devices. This approach provides an optimal
viewing experience—easy reading and navigation with a minimum of resizing,
panning, and scrolling.
Here is an example of a CSS media query that changes the layout of a website based
on the width of the browser window:
/* Base styles for a layout that applies when the screen width is
600px or greater */
.container
{ width: 85%;
margin: auto;
}
/* CSS media query for screens that are less than 600px wide */
@media (max-width: 600px) {
.container
{ width: 100%;
padding: 0 10px;
}
.column
{ float:
none; width:
100%;
}
}
In this example, the .container class has a width of 85% of the browser window by
default, but on screens that are less than 600 pixels wide, it switches to 100% width
with added padding, making it more suitable for smaller screens.
● Manual testing is the process of manually checking software for defects. Testers
perform this process by running the software under various conditions and usage
scenarios to ensure it behaves as expected. This type of testing does not involve
automated tools or scripts. Instead, testers use the application as end users would,
trying various input and usage combinations, checking the correct output, and
identifying any unexpected behavior or bugs.
● In software testing, the terms defect and bug are often used interchangeably, but they
can have subtly different meanings depending on the context:
o Bug: A bug refers to an error, flaw, failure, or fault in a computer program
or system that produces an incorrect or unexpected result or causes it to
behave in unintended ways. The term is often used during the development
phase when developers find that the software is not performing as expected.
o Defect: A defect is a term often used in a formal software testing environment
to describe any deviation from the specifications or expectations outlined in
the client’s documentation. It typically enters the conversation once the
software reaches QA teams.
Essentially, both terms refer to issues in the software, but "defect" might be used more
in quality assurance and "bug" more in development contexts.
65. What is SDLC?
Ans: Software Development Life Cycle – requirement to maintenance.
66. What is CI/CD?
Ans: Continuous Integration/Deployment – automating software delivery.
● Arrays are a collection of elements, each identified by at least one array index or key.
An array is a container that holds data (values or variables), typically of the same data
type, in contiguous memory locations. In many programming languages, arrays are
fixed in size and cannot be resized dynamically.
68. How to connect Python and database
● To connect Python to a database, you generally use a library specific to that type of
database. For example, for SQLite, you use sqlite3, and for MySQL, you might use
PyMySQL. Here's how you might connect to a SQLite database:
import sqlite3
connection = sqlite3.connect('example.db')
cursor = connection.cursor()
# Perform database operations
connection.close()
● Python provides several functions and methods that are built into the open() function
to handle files. Files can be opened in read (r), write (w), append (a), or read and write
(r+) modes.
● Python includes many built-in functions like print(), len(), type(), int(), str(),
and many others that are readily available for use without needing to import libraries.
● Yes, multilevel inheritance is possible in Java, where a class can inherit from a child
class, thus making a chain of inheritance. For example, class A -> class B ->
class C.
● Python's standard mutable and immutable data types include int, float, complex,
bool, str (string), list, tuple, dict (dictionary), set, and frozenset.
75. What is Call by Reference and Call by Value Method?
● Call by value: Copies the actual value of an argument into the formal parameter of
the function. Changes made to the parameter inside the function do not affect the
argument.
● Call by reference: Copies the address of an argument into the formal parameter.
Changes made to the parameter affect the argument used to call the function.
76. Python Questions: How to del file and what is sequence function
77. init
● Python does not have traditional access specifiers (like private, protected, or
public in Java). However, it follows a convention of prefixing the name of the
member with a single underscore to imply that it is protected and with double
underscores to make it private.
● Memory management in Java is primarily divided into two parts: heap and stack. The
heap is where the objects are allocated, and the stack is where the method invocations
and the local variables are stored.
● In Java, you can assign elements from an array to a Vector using a loop or using
Collections.addAll(vector, array). In C++, you can initialize a vector with an
array directly or copy elements similarly.
82. Divide an array and store into two different arrays?
def divide_array(arr):
mid = len(arr) // 2
return arr[:mid], arr[mid:]
● Lists are mutable (can be modified), and tuples are immutable (cannot be
modified). Lists use square brackets [ ], and tuples use parentheses ( ).
● A lambda function is a small anonymous function in Python, defined with the lambda
keyword. Lambda functions can have any number of arguments but only one
expression.
multiply = lambda x, y: x * y
print(multiply(5, 6)) # Outputs 30
● A linked list is a linear data structure where each element (node) contains a reference
(link) to the next node in the sequence. Unlike arrays, linked lists do not have
indexed elements and their elements are not stored contiguously in memory.
87. ChatGPT?
89. What is DL
● Instagram AI: Instagram uses artificial intelligence to power various features, such
as content recommendations in the Explore tab, photo and video analysis to identify
and filter out inappropriate content, and facial recognition to suggest tags in photos.
● Google AI: Google incorporates AI across many of its products and services,
including Google Search, where it improves search algorithms; Google Photos, where
it recognizes faces; and Google Assistant, an AI-driven virtual assistant.
● General AI, or Artificial General Intelligence (AGI), refers to a type of AI that can
understand, learn, and apply intelligence across a broad range of tasks, mimicking
human intelligence. Unlike narrow AI, which is designed to perform specific
tasks, AGI can theoretically perform any intellectual task that a human can do.
● LLM stands for "Large Language Model." These are deep learning models
specifically designed to understand and generate human-like text based on the input
they receive. They are trained on vast datasets to handle a variety of language-based
tasks. Examples include OpenAI's GPT series.
● Saying Java is "better" is subjective and depends on the context. Java is widely
praised for its platform independence (write once, run anywhere - WORA), robust
memory management, extensive libraries, strong community support, and its
widespread use in enterprise environments, particularly for backend and mobile
Android app development.
● Updating features on deployed apps generally involves several steps: developing and
testing the new features in a development environment, updating the codebase and
committing these changes to a version control system, building and deploying these
changes to a staging environment to mimic production, conducting further testing, and
then deploying to production, often using continuous integration/continuous
deployment (CI/CD) pipelines.
● Both are object-oriented languages, but there are key differences: C++ is platform-
dependent, supports multiple inheritance directly, and uses manual memory
management. Java runs on a virtual machine, supports only single inheritance directly
(interfaces can be used for a similar effect to multiple inheritance), and has automatic
garbage collection.
● A private constructor is a constructor that cannot be accessed outside of its class. This
is used to restrict instantiation of the class from outside and to implement singletons
or factory method patterns.
106. Exceptions
● Exceptions are events that can modify the normal flow of a program. They are used
for handling errors or other exceptional events in languages like Java and Python. An
exception is typically thrown when an error occurs, and caught in a try/catch block to
manage the error.
● UI (User Interface) refers to the aesthetic elements through which a user interacts
with a device or application. UX (User Experience) is the overall experience a user
has with a product or service, especially in terms of how easy or pleasing it is to use.
● In SQL, char and varchar are both used to store character data. char is used
for fixed-length strings while varchar is used for variable-length strings.
112. How much time will you take to create simple, medium and complex wireframe
● The time to create a wireframe can vary greatly depending on the complexity of the
application, the clarity of requirements, and the designer's experience. A simple
wireframe might take a few hours to a day, a medium complexity wireframe might
take several days, and a complex one could take weeks.
A wrapper class is a class whose object wraps or contains primitive data types. In
Java, wrapper classes convert primitive data types into objects. Objects are necessary
to modify the arguments passed into a method (because primitive types are passed by
value).
Pass Statement:-The pass statement is simply a null statement. Pass statements are used to
postpone compilation time.
Break Statement:- Break is a loop control statement that is used to end a loop if the
required target is satisfied.
Local Variable:-These variables are defined in short blocks of code like as functions, control
statement blocks, and so on. The default value of local variables is “garbage value.”
Global Variable:-Global variables exist outside of functions and are available to all functions;
their values can be altered by any function. Global value is set to zero by default.
Type casting is a data conversion mechanism that converts data from one data type to another.
Join Union
It integrated information into new columns. It integrates data to create new rows.
It retrieves matched records from two or It combines the results of two separate
more tables. select statements.
Different datatypes from relevant columns The data types of the selected relevant
might be used. columns should be the same.
129. What is the difference between primary and unique keys?
A primary key identifies data A secondary key is a key that is used in addition to
within a table. or instead of the primary key to locate data.
Only one primary key can exist . There may be multiple unique keys.
It builds a clustered index. It generates an index that is not clustered
Example:
If we want to delete from students table the record of student name Jenny, we will use
Big data refers to extremely large and complex datasets that traditional data processing
systems cannot easily handle. These datasets are often characterized by their volume, velocity,
and variety. Big data can be structured, unstructured, or semi-structured and is used to extract
insights and make informed decisions.