DSA & Java Lectures
DSA & Java Lectures
● 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
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:
● 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.
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
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.
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