Java Fullstack Development
Java Fullstack Development
Date:
June 2025
Description:
This document presents consolidated notes and examples covering essential Java backend
development concepts, including OOP principles, multithreading, exception handling, JDBC,
and real-world project structures. Compiled and refined based on training, self-study (GFG,
JavaTpoint), and real interview experiences as part of the Java Full Stack Development
certification at Linkcode Technology.
Introduction
Good morning Sir or Maam, my name is Tejas Waghmare from rajgurunagar pune. I am
currently pursuing my Bachelor of Engineering in Computer Engineering from NBN Sinhgad
School Of Engineering, with an aggregate CGPA of 8.11.
In terms of technical skills, I specialize in Java Full Stack Development, including java adv
java, JSP, Java Servlet, Spring Boot and Angular, and have hands-on experience with tools like
SQL, HTML, and CSS. I've applied these skills to various projects, such as a dynamic Bank
Management system using JSP and Servlete and a Todo Task application integrating Spring
Boot and Angular.
I recently completed an internship at KasNet Technology, where I managed and deployed
Azure cloud solutions, improving deployment efficiency. Additionally, I hold an Azure AZ-900
certification.
I am passionate about problem-solving, enjoy working on innovative projects, and am eager
to contribute my skills to a challenging and dynamic work environment. I look forward to
discussing how my skills and experiences align with the needs of organization.
Additionally, the JVM handles memory management, allocating space for objects and
performing garbage collection to reclaim unused memory.
The JRE (Java Runtime Environment) is a software package that provides everything needed
to run Java applications.
It contains core Java libraries, classes, and resources necessary for program execution,
making it a crucial component for end-users who only need to run Java applications.
It includes the JVM (Java Virtual Machine), which executes Java programs, along with the
libraries and other components required for the program to function properly.
When you install the JRE on your system, it allows you to run Java programs but does not
include tools for writing or compiling Java code.
JDK:
JDK stands for Java Development Kit which provides the environment to develop and
execute Java programs. JDK is a package that includes two things Development Tools to
provide an environment to develop your Java programs and, JRE to execute Java programs or
applications.
3. void: void is a keyword and is used to specify that a method doesn’t return anything.
As the main function doesn’t return anything we use void.
4. main: main represents that the function declared is the main function. It helps JVM
to identify that the declared function is the main function.
A Java String Pool is a place in heap memory where all the strings defined in the program are
stored.
• Object
• Interface
No, Java doesn’t provide the support of Pointer. As Java needed to be more secure because
which feature of the pointer is not provided in Java.
The primitive data types are the ones from which further data types could be created. For
example, integers can further lead to the construction of long, byte, short, etc. On the
other hand, the string cannot, hence it is not primitive.
It can be used throughout the class. The scope is limited to the method.
Instance Variable: A class variable without a static modifier known as an instance variable is
typically shared by all instances of the class. These variables can have distinct values among
several objects. The contents of an instance variable are completely independent of one
object instance from another because they are related to a specific object instance of the
class.
static keyword
In Java, the static keyword is used to indicate that a variable, method, or block belongs to
the class rather than any specific object of the class.
This means it can be accessed without creating an instance of the class.
Key Points:
1. Static Variables:
o Shared across all objects of the class.
o Example: A static variable count keeps the same value for all objects.
2. Static Methods:
o Can be called using the class name, without creating an object.
this keyword
In Java, the this keyword refers to the current object of the class.
It is used to work with the instance variables, methods, or constructors of that specific
object.
Key Uses of this Keyword:
1. Access Instance Variables:
When instance variables and method parameters have the same name, this helps
distinguish the instance variable from the local parameter.
System.out System.err
How many ways you can take input from the console?
There are two methods to take input from the console in Java mentioned below:
String StringBuffer
StringBuffer StringBuilder
It is thread-safe (two threads can’t call the It is not thread-safe (two threads can call
methods of StringBuffer simultaneously) the methods concurrently)
o Bundling data (variables) and methods (functions) into a single unit (class)
and restricting direct access to some components for better security and
control.
o Example: Using private variables with public getter and setter methods.
2. Inheritance:
o A mechanism where one class (child) inherits attributes and behaviors from
another class (parent), enabling code reuse and hierarchical relationships.
3. Polymorphism:
o The ability for a single method or object to take multiple forms, allowing
flexibility in method behavior.
o Example: Method Overloading (same name, different parameters) and
Method Overriding (same name and parameters, but different
implementation).
What is an object?
The object is a real-life entity that has certain properties and methods associated with it.
The constructor sets up the initial state of the object by assigning values to its instance
variables or performing other setup tasks.
Key Features of a Constructor:
1. Same Name as Class:
It essentially duplicates an object by initializing the new object's fields with the same values
as another object of the same class.
What is an Interface?
In Java, an interface is like a contract that defines a set of rules (methods) that a class must
follow.
It specifies what a class should do, but not how it should do it.
Key Points:
• An interface only contains method declarations (no method body).
• A class that implements the interface must provide the implementation for all the
methods.
• It helps in achieving abstraction and multiple inheritance.
Example in Simple Terms:
Think of an interface as a remote control. The remote has buttons like powerOn, volumeUp,
and channelChange. The remote doesn’t care whether it’s controlling a TV, an AC, or a music
system—each device just needs to implement these functions in its own way.
• Any class can implement multiple interfaces even when one class can extend only
one class.
• It is also used to achieve loose coupling.
interface InterfaceName {
Abstraction
In Java, abstraction is the process of hiding unnecessary details and showing only the
essential features of an object or system.
}}
Both abstract and non-abstract methods The interface contains only abstract
may be found in an abstract class. methods.
It also involves restricting direct access to some of the object's components to ensure better
control and security.
Key Features:
1. Data Hiding:
o By using private access modifiers for variables, you hide them from external
access.
2. Controlled Access:
o You provide access to the hidden data through public getter and setter
methods.
Example in Simple Terms:
Think of a capsule (medicine)—it encapsulates the ingredients inside a sealed container.
Similarly, in Java, a class hides its internal details and only exposes what is necessary through
methods.
In short, encapsulation protects data from unauthorized access and makes the code more
modular, secure, and easy to maintain.
• Aggregation is a term related to the relationship between two classes best described
as a “has-a” relationship.
• This kind is the most specialized version of association.
• It is a unidirectional association means it is a one-way relationship.
• It contains the reference to another class and is said to have ownership of that class.
Key Points:
1. Reusability:
o The child class can use the existing code of the parent class instead of writing
it again.
2. Extensibility:
o The child class can add its own features or modify the inherited ones.
3. Syntax:
o Use the extends keyword for inheritance.
• A child inherits quality like eye color or height from their parents.
• Similarly, in Java, a child class can inherit methods and variables from the parent
class.
In short, inheritance helps reduce redundancy, makes the code more organized, and
establishes a hierarchical relationship between classes.
• Multilevel Inheritance
means a class is derived from another class, which itself is derived from a third
class.
This creates a chain of inheritance where properties and methods are passed down
multiple levels.
• Hierarchical Inheritance:
Key Reasons:
1. Ambiguity (Diamond Problem):
o If two parent classes have the same method, the child class wouldn’t know
which one to use, causing confusion.
2. Complexity:
o Handling multiple parent classes makes the code harder to understand and
maintain.
Simple Example:
Imagine Parent1 and Parent2 both have a method display(). If the child class inherits from
both, Java wouldn’t know which display() to execute.
In short, Java avoids multiple inheritance to prevent errors and keep code simpler and more
reliable.
Key Points:
1. Method Overloading (Compile-time Polymorphism):
o Same method name, but different parameter lists in the same class.
o Example: One method add() can add two numbers or concatenate two
strings, depending on the input.
2. Method Overriding (Runtime Polymorphism):
o A child class provides a specific implementation for a method that is already
defined in its parent class.
o Child class bap banto… swatach dok lavto.
o Example: A Dog class overrides the speak() method of the Animal class to
bark instead of making a generic animal sound.
In short, polymorphism makes code flexible and allows a single interface to work in multiple
ways.
No, as static methods are part of the class rather than the object so we can’t override them.
It is used to represent a general concept, providing a base for other classes to build on. An
abstract class can have both abstract methods (methods without a body) and concrete
methods (methods with a body).
Key Points:
1. Abstract Methods:
o These methods are declared in the abstract class but don't have a body. The
child class must provide the implementation.
2. Concrete Methods:
o These are normal methods with code inside them, and the child class can use
them without overriding.
3. Cannot Instantiate:
o You can't create an object of an abstract class directly. Instead, you create
objects of its subclasses.
Simple Example:
Think of an abstract blueprint for a vehicle:
• An abstract class Vehicle might have an abstract method start(), but different vehicles
like Car and Bike will implement how the start() method works for them.
In short, an abstract class is used to define common characteristics while leaving the specific
implementation details to the subclasses.
Before Java 1.2, developers relied on arrays and custom data structures. These had
limitations like fixed size, no dynamic resizing, and lack of built-in methods for sorting,
searching, or manipulation. The Collection Framework solves these by:
• Providing ready-made, reusable classes and interfaces
1. Interfaces
These define the basic types of collections and the operations they support.
Interface Description
Set Unordered collection that cannot contain duplicate elements (HashSet, TreeSet)
Queue Stores elements in FIFO (First In, First Out) order (PriorityQueue, ArrayDeque)
Not part of Collection but related; stores key-value pairs (HashMap, TreeMap,
Map
LinkedHashMap)
Class Description
3. HashMap vs TreeMap
o HashMap is faster, unsorted
o TreeMap is sorted by key, slower than HashMap
4. Thread Safety
names.add("Tejas");
names.add("Sujal");
names.add("Tejas"); // allowed in List
It ensures the program doesn’t crash and can handle errors gracefully, allowing it to
continue running or terminate safely.
Key Points:
1. What is an Exception?
o An exception is an unexpected event, like dividing by zero, accessing an
invalid array index, or trying to open a non-existent file.
2. How it Works:
o Java uses a mechanism to detect and handle exceptions using try, catch,
finally, and throw blocks.
o The error is "caught" and managed instead of letting the program crash.
Simple Example:
In short, exception handling makes your program robust and user-friendly by managing
errors in a controlled way.
• Built-in Exceptions: Built-in exceptions in Java are provided by the Java Libraries.
These exceptions can be further divided into two subcategories
i.e., checked and unchecked Exceptions.
Below are some of the built-in exceptions in Java:
1. ArrayIndexOutOfBoundsExceptions
2. ClassNotFoundException
3. FileNotFoundException
4. IOException
5. NullPointerException
6. ArithmeticException
7. InterruptedException
8. RuntimeException
User-defined Exceptions in Java are used when the built-in exceptions are in Java.
Errors Exceptions
Errors can occur at compile time as All exceptions occur at runtime but checked
well as run time. Compile Time: exceptions are known to the compiler while
Syntax Error, Run Time: Logical Error. unchecked are not.
In Java, Runtime Exceptions are errors that occur during the program's execution (runtime).
They are unchecked exceptions, meaning the compiler doesn't force you to handle them or
declare them in the throws clause. Examples include:
• NullPointerException: When you try to use an object reference that is null.
• ArrayIndexOutOfBoundsException: When accessing an invalid index in an array.
• ArithmeticException: Like dividing a number by zero.
These exceptions often indicate bugs in the program that you need to fix.
What is NullPointerException?
It is a type of run-time exception that is thrown when the program attempts to use an object
reference that has a null value.
Checked Exception:
Checked Exceptions are the exceptions that are checked during compile time of a program.
In a program, if some code within a method throws a checked exception, then the method
must either handle the exception or must specify the exception using the throws keyword.
Unchecked Exception:
Unchecked are the exceptions that are not checked at compile time of a program.
Exceptions under Error and RuntimeException classes are unchecked exceptions, everything
else under throwable is checked.
The final keyword is used to make functions non-virtual. By default, all the functions are
virtual so to make it non-virtual we use the final keyword.
Final Variable: Its value cannot be changed once assigned.
Example: final int x = 10;
Super keyword:
The super keyword in Java refers to the parent class and is used for the following purposes:
class Parent {
void display() { System.out.println("Parent Method"); }
System.out.println("Child Method");
}
}
3. Access Parent Class Variables:
It accesses a variable in the parent class hidden by a child class variable.
Example:
class Parent {
int x = 10;
void show() {
System.out.println(super.x); // Access Parent's x
}
}
What is multitasking?
Multitasking in Java refers to a program’s capacity to carry out several tasks at once.
Threads, which are quick operations contained within a single program, can do this.
Executing numerous things at once is known as multitasking.
Example:
class MyThread extends Thread {
public void run() {
System.out.println("Thread is running");
}
}
3. Economy: We are able to share memory because of which the processes are
economical.
4. Scalability: Multithreading on multiple CPU machines increases parallelism.
Multithreading is a Java feature that allows concurrent execution of two or more parts of a
program for maximum utilization of the CPU. In general, threads are small, lightweight
processes with separate paths of execution. These threads use shared memory, but they act
independently, thus if any one thread fails it does not affect the other threads. There are
two ways to create a thread:
• By extending the Thread class
• By implementing a Runnable interface.
We create a class that extends the java.lang.Thread class. This class overrides the run()
method available in the Thread class. A thread begins its life inside run() method.
Syntax:
public class MyThread extends Thread {
public void run() {
// thread code goes here
}
}
Syntax:
public class MyRunnable implements Runnable {
public void run() {
// thread code goes here
}
}
A thread has its own program counter, execution stack, and local variables, but it shares the
same memory space with other threads in the same process.
Java provides built-in support for multithreading through the Runnable interface and
the Thread class.
Runnable interface
The Runnable interface in Java is used to represent a task that can be executed by a thread.
It is part of the java.lang package and has a single method:
Method:
java
Copy code
void run();
• The run() method contains the code that you want the thread to execute.
1. It allows our class to extend another class (since Java doesn't support multiple
inheritance).
2. It separates the task logic from the thread's execution logic.
Example:
class MyTask implements Runnable {
}
Key Point:
Using the Runnable interface is preferred in scenarios where your class already extends
another class.
Process Thread
The process takes more time to terminate. The thread takes less time to terminate.
The process takes more time for context The thread takes less time for context
switching. switching.
A thread in Java at any point in time exists in any one of the following states. A thread lies
only in one of the shown states at any instant:
1. New: The thread has been created but has not yet started.
2. Runnable: The thread is running, executing its task, or is ready to run if there are no
other higher-priority threads.
3. Blocked: The thread is temporarily suspended, waiting for a resource or an event.
The suspend() method of the Thread class in Java temporarily suspends the execution of a
thread.
When a thread is suspended it goes into a blocked state and it would not be scheduled by
the operating system which means that it will not be able to execute its task until it is
resumed.
There are more safer and flexible alternatives to the suspend() methods in the modern java
programming language. This method does not return any value.
Syntax:
public final void suspend();
Java Virtual Machine (JVM) automatically manages the memory periodically by running a
garbage collector which frees up the unused memory in the application.
Garbage collection makes Java memory efficient because it removes unreferenced objects
from the heap memory.
What is JDBC?
JDBC standard API is used to link Java applications and relational databases.
It provides a collection of classes and interfaces that let programmers to use the Java
programming language to communicate with the database.
The classes and interface of JDBC allow the application to send requests which are made by
users to the specified database.
There are generally four components of JDBC by which it interacts with the database:
1. JDBC API
2. JDBC Driver manager
3. JDBC Test Suite
4. JDBC-ODBC Bridge Drivers
JDBC ResultSet interface is used to store the data from the database and use it in our Java
Program.
We can also use ResultSet to update the data using updateXXX() methods.
ResultSet object points the cursor before the first row of the result data.
Using the next() method, we can iterate through the ResultSet.
RowSets are classified into five categories based on implementation mentioned below:
1. JdbcRowSet
2. CachedRowSet
3. WebRowSet
4. FilteredRowSet
5. JoinRowSet
4. It contains all the methods that can register and deregister the database driver
classes.
5. DriverManager.registerDriver() method can maintain the list of Driver classes that
have registered themselves.
Example:
String a = new String("hello");
String b = new String("hello");
System.out.println(a.equals(b)); // true (same content)
3. Basic Structure
The project is structured into three main layers:
• Frontend: A user-friendly interface for customers to interact with banking features.
• Backend: Logic implemented using JSP and Servlet for processing user requests.
• Database: JDBC is used to manage and retrieve data securely from the database for
transactions.
• Libraries:
o JDBC for database connectivity.
o Java libraries for handling authentication and transaction logic.
5. Workflow
1. The user logs into the system using secure authentication.
2. They navigate to the desired banking feature (e.g., check balance, deposit, withdraw,
mobile recharge).