You are on page 1of 54

IT companies

● Types
● Salaries
● Interview questions comes from which topics
Course details
● Data Structures and Algorithms (to improve problem solving / logical skills)
● Java
● OOPs
● DBMS
● Project (if any)
● Aptitude
● Communication skills
● Interview preparation
What is Programming Language ? why it’s needed
● What is software / hardware
● How hardware understands software
● Binary numbers
● Low level / High level programming language
What is computer ?
● System software / Application software
● RAM / CPU / HDD or SSD what happens when program executes
● Volatile / non volatile
C hello world program
● Explain hello world C program
● What is function?
● Why data types there in programming languages?
● Int, float, char, long, double
● Scope of variable: how much data stored in memory while code runs
● Memory management / efficient memory usage
Data types
Function programs
1. Sum, sub, mult, div, mod methods
2. ATM: deposit, withdraw, balance
continue / break / return / comment / switch case
Switch case programs:
1. Print which size : 29 - small, 35 - medium, 40 - large, 45 - extra large, default - unknown
2. Print week day: 1 - Sunday, 2 - Monday, 3 - Tuesday…etc
3. Print month: 1 - January, 2 - February, 3 - March … etc
Loops / if condition / modulo operator
1. Print 1 to 100 (for and while loop both)
2. Print 1 to 100 in reverse (for and while loop both)
3. Print table of 5
4. Print odd / even from 1 to 100
5. Find big numbers from 2 numbers
6. Find big numbers from 3 numbers
7. Year / month / day from a number
8. Hours, minutes, seconds
9. Swap two numbers
10. Reverse an integer
11. Count number of digits in integer
12. Check if number is palindrome or not
13. Multiplication of two numbers without using (*) operator
14. Power of number (base and exponent)
15. factorial
16. Check if number is prime number or not
17. Fibonacci
Scanner in java
Patterns
● Pattern programs, how pattern works
Array
● Array memory allocation
● Why array starts from 0
● Array programs
What is Data Structures and
Algorithms

● Difference between database & data structures


● Algorithms. eg.need pic from friend -> two ways online and offline, what is
better
Time & Space complexity
Array programs
Exception handling
1) Checked Exception
The classes that directly inherit the Throwable class except
RuntimeException and Error are known as checked
exceptions. For example, IOException, SQLException, etc.
Checked exceptions are checked at compile-time.

2) Unchecked Exception
The classes that inherit the RuntimeException are known as
unchecked exceptions. For example, ArithmeticException,
NullPointerException, ArrayIndexOutOfBoundsException,
etc. Unchecked exceptions are not checked at compile-time,
but they are checked at runtime.

3) Error
Error is irrecoverable. Some example of errors are
OutOfMemoryError, VirtualMachineError, AssertionError etc.
Checked Exception
try {
FileReader fileReader = new FileReader("Test.txt");
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}

try {
Class.forName("com.addzero.SomeClass");
} catch (ClassNotFoundException e) {
System.out.println("Class was not found.");
}
Sorting Algorithms
1. Bubble sort
2. Selection sort
3. Insertion sort
2D array (matrix)
OOP
1. Class
2. Object
3. Constructor (default, parameterised, copy)
4. This keyword
5. Access modifiers: public, default, protected, private
6. Getter / Setter methods
7. Static keyword
8. Encapsulation
9. Inheritance (single, multilevel, hierarchical, multiple, hybrid)
10. Super keyword
11. Polymorphism (Runtime, Compile time),
12. Final keyword (with variable, method, class)
13. Abstraction: abstract class, Interface
14. Default method / static method in interface
15. Inheritance (IS-A), Aggregation (Has-A)
16. Enums
How Internet works
What happens behind the scene when you hit URL in the browser??
This is very frequently asked questions in interview
Steps 👇
🎈Browser look for cache for a DNS record to find IP address of URL.
🎈it will look for four type of cache (browser cache, OS cache, router cache, ISP cache)
If it is not in cached, ISP's DNS server initiates a DNS query to find the IP address
🎈 The browser initiates a TCP connection with the serve.
🎈 The browser sends an HTTP request to the webserver
🎈 The server sends out an HTTP response and display HTML content.
These steps happen in just a few milliseconds (just blink your eyes)
Java Wrapper class
Java Collection
Framework
String
● How its stored in memory in java
StringBuilder
The function of StringBuilder is very much similar to the StringBuffer class (Will
see after multi-threading), as both of them provide an alternative to String Class
by making a mutable sequence of characters. However, the StringBuilder class
differs from the StringBuffer class on the basis of synchronization. The
StringBuilder class provides no guarantee of synchronization whereas the
StringBuffer class does.
Stack
What is prefix / infix / postfix notations
Queue
Simple
Circular
DEQueue
Priority queue
LinkedList
HashSet / HashMap
Equals() and Hashcode() in Java
Map
interface
Recursion
DBMS

● BookMyShow DB design
● ACID properties
LRU cache
Binary tree
Types of Binary Tree based on the number of children:

1. Full Binary Tree 2. Degenerate (or pathological) tree


A Binary Tree is a full binary tree if every A Tree where every internal node has one child. Such
node has 0 or 2 children. trees are performance-wise same as linked list. A
degenerate or pathological tree is a tree having a
single child either left or right.
Types of Binary Tree based on the number of children:

3. Skewed Binary Tree

A skewed binary tree is a


pathological/degenerate tree in which
the tree is either dominated by the left
nodes or the right nodes. Thus, there
are two types of skewed binary tree:
left-skewed binary tree and
right-skewed binary tree.
Types of Binary Tree On the basis of the completion of levels:

1. Complete Binary Tree 2. Perfect Binary Tree


A Binary tree is a Perfect Binary Tree in which all the
A Binary Tree is a Complete Binary Tree if all
the levels are completely filled except
internal nodes have two children and all leaf nodes are
possibly the last level and the last level has at the same level.
all keys as left as possible.
Types of Binary Tree On the basis of the completion of levels:

3. Balanced Binary Tree


A binary tree is balanced if the height of the tree is O(Log n) where n is the number of nodes. For Example, the AVL
tree maintains O(Log n) height by making sure that the difference between the heights of the left and right subtrees
is at most 1
Some Special Types of Trees:
On the basis of node values, the Binary Tree can be classified into the following
special types:

1. Binary Search Tree


2. AVL Tree
3. Red Black Tree
4. B Tree
5. B+ Tree
6. Segment Tree
Binary Search Tree
is a node-based binary tree data structure that has the following properties:

● The left subtree of a node contains only nodes with keys lesser than the node’s key.
● The right subtree of a node contains only nodes with keys greater than the node’s key.
● The left and right subtree each must also be a binary search tree.

public void insert(int value) {


root = insert(root, value); private static boolean search(Node root, int value){
} if (root == null){
return false;
private Node insert(Node root, int value) { }
if(root == null){ if (root.data == value){
root = new Node(value); return true;
}
return root;
if (root.data > value){
}else if(value > root.data){ return search(root.left, value);
root.right = insert(root.right, value); }
}else { return search(root.right, value);
root.left = insert(root.left, value); }
}
return root;
}
Delete in BST public void delete(int value) {
root = delete(root, value);
}
3 cases:
1) Node to be deleted is the leaf: private Node delete(Node root, int value) {
if (root == null){
Simply remove it from the tree. return root;
2) Node to be deleted has only one child: }
if (value > root.data){
Copy the child to the node and delete the node.
root.right = delete(root.right, value);
3) Node to be deleted has two children: }else if (value < root.data){
Find inorder successor of the node. Copy root.left = delete(root.left, value);
}else {
contents of the inorder successor to the node and
if (root.left == null){
delete the inorder successor. return root.right;
}else if (root.right == null){
private int minValue(Node node) { return root.left;
int min = node.data; }
while (node.left != null){ root.data = minValue(root.right);
min = node.left.data; root.right = delete(root.right, root.data);
} }
return min; return root;
} }
Exception handling
1) Checked Exception
The classes that directly inherit the Throwable class except
RuntimeException and Error are known as checked
exceptions. For example, IOException, SQLException, etc.
Checked exceptions are checked at compile-time.

2) Unchecked Exception
The classes that inherit the RuntimeException are known as
unchecked exceptions. For example, ArithmeticException,
NullPointerException, ArrayIndexOutOfBoundsException,
etc. Unchecked exceptions are not checked at compile-time,
but they are checked at runtime.

3) Error
Error is irrecoverable. Some example of errors are
OutOfMemoryError, VirtualMachineError, AssertionError etc.
Checked Exception
try {
FileReader fileReader = new FileReader("Test.txt");
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}

try {
Class.forName("com.addzero.SomeClass");
} catch (ClassNotFoundException e) {
System.out.println("Class was not found.");
}
Java Multithreading

1) Java Thread Example by extending Thread class 2) Java Thread Example by implementing Runnable interface

public class AddZeroGroup{


public class AddZeroGroup{
public static void main(String[] args){
public static void main(String[] args){
for (int i = 0; i < 10; i++) {
for (int i = 0; i < 10; i++) {
TestThread testThread = new TestThread(i);
TestThread testThread = new TestThread(i);
Thread t1 = new Thread(testThread);
testThread.start();
t1.start();
}
}
}
}
}
}
class TestThread extends Thread{
class TestThread implements Runnable{
int no;
int no;
public TestThread(int no) {
public TestThread(int no) {
this.no = no;
this.no = no;
}
}
public void run(){
public void run(){
System.out.println("running " + no);
System.out.println("running " + no);
}
}
}
}
StringBuffer

The function of StringBuilder is very much similar to the StringBuffer


class, as both of them provide an alternative to String Class by making
a mutable sequence of characters. However, the StringBuilder class
differs from the StringBuffer class on the basis of synchronization. The
StringBuilder class provides no guarantee of synchronization whereas
the StringBuffer class does.
Garbage collection
In java, garbage means unreferenced objects. Garbage Collection is process of reclaiming the runtime unused memory
automatically. In other words, it is a way to destroy the unused objects. To do so, we were using free() function in C
language and delete() in C++. But, in java it is performed automatically. So, java provides better memory management.

It makes java memory efficient because garbage collector removes the unreferenced objects from heap memory. It is
automatically done by the garbage collector(a part of JVM) so we don't need to make extra efforts.

How can an object be unreferenced?


There are many ways:
1) By nulling the reference
2) By assigning a reference to another
3) By anonymous object etc. ex. new Student();

We can also request JVM to run Garbage Collector. There are two ways to do it :
● Using System.gc() method: System class contain static method gc() for requesting JVM to run Garbage Collector.
● Using Runtime.getRuntime().gc() method: Runtime class allows the application to interface with the JVM in
which the application is running. Hence by using its gc() method, we can request JVM to run Garbage Collector.
● There is no guarantee that any of the above two methods will run Garbage Collector.
● The call System.gc() is effectively equivalent to the call : Runtime.getRuntime().gc()
Comparable and Comparator
Comparable and Comparator both are interfaces and can be used to sort collection elements.
Advanced Sorting algorithms

1. Priority Queue
2. Heap sort
3. Merge sort
4. Quick sort

You might also like