0% found this document useful (0 votes)
20 views43 pages

ITR Report-1

The document is an industrial training report submitted by Karpe Aryan Amit for a six-week internship at Technogrowth Software Solutions Pvt Ltd, focusing on Full Stack Development. It outlines the training's objectives, covering key technologies such as Core Java, Advanced Java, Hibernate, Spring Boot, and Angular, aimed at bridging academic learning with real-world application. The report includes a detailed table of contents, an abstract, and sections on Java programming concepts, encapsulation, inheritance, and the use of POJOs.

Uploaded by

harsh.ks.097
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views43 pages

ITR Report-1

The document is an industrial training report submitted by Karpe Aryan Amit for a six-week internship at Technogrowth Software Solutions Pvt Ltd, focusing on Full Stack Development. It outlines the training's objectives, covering key technologies such as Core Java, Advanced Java, Hibernate, Spring Boot, and Angular, aimed at bridging academic learning with real-world application. The report includes a detailed table of contents, an abstract, and sections on Java programming concepts, encapsulation, inheritance, and the use of POJOs.

Uploaded by

harsh.ks.097
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 43

AN INDUSTRIAL TRAINING REOPRT

Submitted by
Enrolment No. Name of Student
2200800820 Karpe Aryan Amit

At
Technogrowth Software Solutions Pvt Ltd.
Under Supervision of Mr. Suraj Raskar.
Internship Start Date:1-06-2024 Internship End Date:14-07-2024

Submitted to

DEPARTMENT OF INFORMATION TECHNOLOGY

Amrutvahini Polytechnic, Sangamner


(Approved by AICTE, NEW DELHI and affiliated To MSBTE)
2024-2025
Amrutvahini Polytechnic, Sangamner
Department of Information Technology

CERTIFICATE

This Is to Certify That,


Karpe Aryan Amit has Satisfactorily Completed the 6 weeks Industrial
Training in Technogrowth Software Solution Pvt.Ltd., Pune from 1-06-
2024 to 14-07-2024. This Report Is Being Submitted in the Partial
Fulfilment for the Award of Diploma in Information Technology to
Maharashtra State Board of Technical Education, Mumbai.

Prof.Chaudhari N.K. Prof. Dharne J.A.


(H.O.D) IT (Mentor)
2
ABSTRACT

This report details the industrial training undertaken by Karpe Aryan Amit,
encompassing Full Stack Development. The training aimed to provide
practical exposure to these crucial areas of programming and software
development. It covered Core Java, Advanced Java, Hibernate, Spring Boot
and Angular.
This abstract provides an overview of the internship training program at
Technogrowth Software Solution Pvt.Ltd., a cutting-edge technology
company focused on innovation and digital solutions. The internship
program aims to bridge the gap between academic learning and real-world
application, providing students with valuable hands-on experience and
exposure to the dynamic tech industry.
The internship training at Technogrowth Software Solution Pvt.Ltd. is
designed to offer participants a comprehensive and immersive learning
experience. Through a structured curriculum and mentorship, interns have
the opportunity to work on live projects, gaining practical insights into the
development and implementation of innovative technological solutions.
Overall, the training equipped valuable knowledge and hands-on
experience, preparing them for a successful career in the software
development industry.

3
TABLE OF CONTENT

1. Introduction to Java, it's features and its structure 5

2. Keywords, variables and Datatypes in java 7

3. Encapsulation, Inheritance and Abstraction in Java 10


4. POJO class 12
5. Exception Handling and Multithreading in Java 16
6. Collection framework 21
7. JDBC 24
8. Hibernate 29
9. Spring Boot 33
10. Angular 37
11. Completion Letter/ Certificate 41
12. Conclusion 42

4
1. Introduction to Java, it's features and its structure

 Introduction to Java:

Java is a widely-used, high-level programming language initially developed


by Sun Microsystems in 1995, which is now owned by Oracle Corporation.
It is designed to be platform-independent, meaning that code written in Java
can run on any device equipped with a Java Virtual Machine (JVM), which
interprets the compiled Java bytecode. Java's design philosophy is to allow
developers to write software once and run it anywhere, thus ensuring high
portability.

Java is both simple and powerful. It combines the ease of programming with
the robustness of an industrial-strength programming language, making it an
excellent choice for a wide variety of applications ranging from mobile apps
and enterprise software to large-scale systems and web applications. Its
syntax is heavily influenced by C and C++, which makes it relatively easy
for developers familiar with these languages to learn Java.

 Features of Java:

1. Simple: Java's syntax is clear and concise, which reduces the learning
curve and makes it easier to write and maintain code. It eliminates
complex features of C++, such as pointers and operator overloading,
which simplifies development.
2. Object-Oriented: Java is based on the object-oriented programming
(OOP) paradigm, which organizes software design around data, or objects,
rather than functions and logic. This approach promotes code reuse,
scalability, and ease of maintenance.
3. Platform-Independent: One of Java's key strengths is its platform
independence. Java code is compiled into bytecode, which can be
executed on any system that has a JVM, allowing developers to create
cross-platform applications seamlessly.
4. Secure: Java provides a robust security model. It restricts operations that
can compromise system security, such as memory management, and offers
a security manager to define access policies for classes.
5. Robust: Java's strong memory management, exception handling, and
automatic garbage collection mechanisms contribute to its robustness,
minimizing the likelihood of crashes and memory leaks.
6. Multithreaded: Java supports multithreaded programming, allowing
developers to create applications that can perform multiple tasks
simultaneously, enhancing performance and responsiveness.
7. High Performance: Although Java is an interpreted language, the use of
Just-In-Time (JIT) compilers and efficient garbage collection techniques

5
allow Java applications to perform well, often comparable to those written
in native languages like C or C++.
8. Distributed: Java is designed with networking capabilities, making it easy
to work on distributed computing models, where applications are divided
into multiple components that are distributed across different networked
computers.
9. Dynamic: Java is dynamic in nature. It supports dynamic loading of
classes, which means classes can be loaded at runtime as needed, making
the applications more flexible and adaptable.

 Structure of a Java Program:

A basic Java program consists of one or more classes, and the structure is
straightforward. Here’s an example of a simple Java program:
public class Main {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}

Class Declaration: The public class Main line declares a class named Main.
In Java, all code must reside within a class. The public keyword is an access
modifier that makes the class accessible to other classes.

Main Method: The public static void main(String[] args) method is the
entry point of any Java application. It’s where the program begins execution.

 public: The method is accessible from anywhere.


 static: The method belongs to the class rather than an instance of the class, so
it can be called without creating an object of the class.
 void: The method does not return any value.
 main: The name of the method, which is special because it is the entry point
for the JVM to start executing the program.
 String[] args: The parameter args is an array of String objects that can store
command-line arguments.

Statements: Within the main method, the System.out.println("Hello,


World!"); line is a statement that prints the text "Hello, World!" to the
standard output (usually the console). System.out is a standard output stream,
and println is a method to print a line of text.

The structure of a Java program, while simple, is powerful and provides a


solid foundation for building complex applications. By adhering to the

6
principles of OOP and leveraging Java's features, developers can create
robust, maintainable, and efficient software solutions.

2. Keywords, variables and Datatypes in Java

 Keywords in Java:

Java has a set of reserved words known as keywords. These keywords have a
predefined meaning in the language and cannot be used for naming variables,
methods, classes, or any other identifiers. Java's keywords form the core
building blocks of its syntax and are integral to the language's structure and
behavior.

Some of the most commonly used keywords include:

 class: Used to define a class.


 public, private, protected: Access modifiers that determine the
visibility of classes, methods, and variables.
 static: Indicates that a particular member belongs to the class rather
than instances of the class.
 void: Specifies that a method does not return any value.
 int, float, double, char, boolean: Primitive data types.
 if, else, switch, case: Control flow statements.
 for, while, do: Looping constructs.
 try, catch, finally, throw, throws: Exception handling
mechanisms.
 extends, implements: Used in inheritance and interface
implementation.
 new: Used to create new objects.
 return: Exits from the current method and optionally returns a value.

 Structure of a Java Program:

Variables in Java:

Variables are fundamental to any programming language, including Java. A


variable is a container that holds data that can be changed during the
execution of a program. Variables are used to store information to be
referenced and manipulated in a program. They are declared with a specific
data type that determines the kind of data they can hold.

In Java, there are three main types of variables:

1. Local Variables:
o Declared inside a method, constructor, or block.
7
o Created when the method, constructor, or block is entered and
destroyed once it is exited.
o Scope is limited to the block in which they are declared.
o Must be initialized before use.

Example:
public void myMethod() {
int localVariable = 10; // Local variable
System.out.println(localVariable);
}

2. Instance Variables:
o Declared inside a class but outside any method, constructor, or
block.
o Created when an object of the class is instantiated and destroyed
when the object is destroyed.
o Each object has its own copy of instance variables.
o Initialized to default values if not explicitly initialized.

Example:
public class MyClass {
int instanceVariable; // Instance variable
}

3. Static Variables:
o Declared with the static keyword inside a class but outside any
method, constructor, or block.
o Created at the start of the program and destroyed at its end.
o Shared among all instances of a class.
o Initialized to default values if not explicitly initialized.

Example:
public class MyClass {
static int staticVariable; // Static variable
}

8
 Data Types in Java:

Java provides a rich set of data types to handle various kinds of data. These
data types are categorized into two main types: primitive data types and non-
primitive (or reference) data types.

1. Primitive Data Types: Primitive data types are predefined by the Java
language and serve as the building blocks of data manipulation. There are
eight primitive data types:
o byte: 8-bit signed integer. Range: -128 to 127.
o short: 16-bit signed integer. Range: -32,768 to 32,767.
o int: 32-bit signed integer. Range: -2^31 to 2^31-1.
o long: 64-bit signed integer. Range: -2^63 to 2^63-1.
o float: Single-precision 32-bit floating point. Used for decimal
values.
o double: Double-precision 64-bit floating point. Used for decimal
values.
o char: 16-bit Unicode character. Range: '\u0000' to '\uffff'.
o boolean: Represents one bit of information. Only two possible
values: true and false.

Example:
byte byteVar = 100;
short shortVar = 10000;
int intVar = 100000;
long longVar = 100000L;
float floatVar = 234.5f;
double doubleVar = 123.4;
char charVar = 'A';
boolean booleanVar = true;

2. Non-Primitive Data Types: Non-primitive data types, also known as


reference data types, are created by the programmer and are not defined
by Java (except for String). They include classes, interfaces, and arrays.
Reference variables are used to store references to objects.
o String: Represents a sequence of characters.
o Arrays: Collection of variables of the same type.
o Classes: Define the properties and behaviors of objects.
o Interfaces: Define a contract for classes that implement them.

Example:
String stringVar = "Hello, World!";
int[] arrayVar = {1, 2, 3, 4, 5};

class MyClass {

9
// Class definition
}

interface MyInterface {
// Interface definition
}

3. Encapsulation, Inheritance and Abstraction in Java

 Encapsulation:

Encapsulation is one of the four fundamental principles of object-oriented


programming (OOP) and is about bundling the data (variables) and methods
(functions) that operate on the data into a single unit or class. Encapsulation
restricts direct access to some of an object's components, which can prevent
the accidental modification of data. This concept is also known as data
hiding.

In Java, encapsulation is achieved by:

1. Declaring the variables of a class as private.


2. Providing public getter and setter methods to modify and view the
variable values.

Encapsulation provides several benefits:

 Control of the data: By restricting access, you can control how the data
is modified or accessed.
 Increased security: Sensitive data can be hidden from unauthorized
access.
 Flexibility: The internal implementation can be changed without affecting
other parts of the program.
 Maintainability: Makes the code easier to maintain and modify.

Example of encapsulation:
public class Employee {
// Private variables
private String name;
private int age;
private double salary;

// Public getter and setter methods


public String getName() {
return name;
}
10
public void setName(String name) {
this.name = name;
}

public int getAge() {


return age;
}

public void setAge(int age) {


if (age > 0) {
this.age = age;
} else {
System.out.println("Age cannot be negative or
zero");
}
}

public double getSalary() {


return salary;
}

public void setSalary(double salary) {


if (salary > 0) {
this.salary = salary;
} else {
System.out.println("Salary cannot be negative or
zero");
}
}
}

 Inheritance:

Inheritance is another core principle of OOP and allows a new class to


inherit properties and behaviours (methods) from an existing class. The
existing class is called the parent class or superclass, and the new class is
called the child class or subclass. Inheritance promotes code reusability and
establishes a natural hierarchical relationship between classes.

In Java, inheritance is implemented using the extends keyword. A


subclass inherits all non-private members (fields, methods) from its
superclass but can also have its own additional fields and methods or
override existing ones.

Key points about inheritance:

 Single Inheritance: Java supports single inheritance, meaning a class can


only extend one other class.

11
 Access to parent class members: Subclasses can access public and
protected members of the superclass.
 Method Overriding: Subclasses can provide a specific implementation
for a method already defined in its superclass.

Example of inheritance:
// Superclass
public class Animal {
private String name;

public Animal(String name) {


this.name = name;
}

public void eat() {


System.out.println(name + " is eating.");
}

public void sleep() {


System.out.println(name + " is sleeping.");
}
}

// Subclass
public class Dog extends Animal {
public Dog(String name) {
super(name); // Call the constructor of the
superclass
}

public void bark() {


System.out.println(getName() + " is barking.");
}
}

// Main class to demonstrate inheritance


public class Main {
public static void main(String[] args) {
Dog dog = new Dog("Buddy");
dog.eat(); // Inherited method
dog.sleep(); // Inherited method
dog.bark(); // Method defined in the subclass
}
}

4. POJO class

 POJO (Plain Old Java Object):

12
A POJO (Plain Old Java Object) is a simple Java object that does not follow
any special conventions or inherit from any special classes other than Java's
built-in Object class. POJOs are used to increase the readability and
reusability of a program by using straightforward and uncluttered code. They
are commonly used in enterprise applications to represent data and
encapsulate business logic.

The concept of POJO was introduced to differentiate between complex,


heavyweight enterprise JavaBeans (EJB) and simpler Java objects. Unlike
EJBs, POJOs do not require a specific framework to be used, making them
flexible and easy to work with.

Key Characteristics of POJOs:

 No special requirements: A POJO does not require any special class path
or configuration. It is a simple Java object that adheres to standard Java
conventions.
 Encapsulation: POJOs use private fields and public getter and setter
methods to adhere to the principle of encapsulation.
 No constraints: POJOs do not have to implement any interfaces or extend
any specific classes (other than Object).
 Lightweight: Since POJOs are free from framework-specific
dependencies, they are lightweight and easy to use in various contexts.

Structure of a POJO Class:

A typical POJO class includes:

1. Private member variables to store the data.


2. Public getter and setter methods to access and modify the data.
3. A no-argument constructor (and sometimes additional constructors) for
creating instances of the class.
4. Optional: Methods like toString(), equals(), and hashCode()
for object comparison and string representation.

Here’s an example of a simple POJO class representing a Student entity:

public class Student {


// Private member variables
private int id;
private String name;
private int age;
private String grade;

// No-argument constructor
public Student() {
}
13
// Parameterized constructor
public Student(int id, String name, int age, String
grade) {
this.id = id;
this.name = name;
this.age = age;
this.grade = grade;
}

// Getter and setter methods


public int getId() {
return id;
}

public void setId(int id) {


this.id = id;
}

public String getName() {


return name;
}

public void setName(String name) {


this.name = name;
}

public int getAge() {


return age;
}

public void setAge(int age) {


if (age > 0) {
this.age = age;
} else {
throw new IllegalArgumentException("Age cannot
be negative or zero");
}
}

public String getGrade() {


return grade;
}

public void setGrade(String grade) {


this.grade = grade;
}

// Optional: Override toString(), equals(), and


hashCode() methods
@Override
public String toString() {

14
return "Student{id=" + id + ", name='" + name + "',
age=" + age + ", grade='" + grade + "'}";
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return
false;

Student student = (Student) o;

if (id != student.id) return false;


if (age != student.age) return false;
if (!name.equals(student.name)) return false;
return grade.equals(student.grade);
}

@Override
public int hashCode() {
int result = id;
result = 31 * result + name.hashCode();
result = 31 * result + age;
result = 31 * result + grade.hashCode();
return result;
}
}

Advantages of Using POJOs:

1. Simplicity: POJOs are straightforward to write, understand, and maintain.


2. Flexibility: Since they do not depend on any frameworks or libraries,
POJOs can be used in various environments without modification.
3. Encapsulation: By using private fields and public methods, POJOs
adhere to the principle of encapsulation, promoting better design and data
integrity.
4. Ease of Testing: POJOs are easy to test, as they do not have dependencies
on external frameworks.
5. Framework Compatibility: While POJOs are framework-agnostic, many
frameworks (such as Spring, Hibernate, and JPA) support and encourage
the use of POJOs, providing the benefits of these frameworks without
enforcing strict constraints.

Using POJOs with Frameworks:

While POJOs are simple, they can be enhanced with annotations to work
with various frameworks like Hibernate (for ORM), Spring (for dependency
injection and other services), and JAX-RS (for RESTful web services).

15
These frameworks can automatically detect and process POJOs, enabling
powerful features with minimal configuration.

For example, using Hibernate annotations to map a POJO to a database table:


import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name = "students")
public class Student {
@Id
private int id;
private String name;
private int age;
private String grade;

// Constructors, getters, and setters


}

5. Exception Handling and Multithreading in Java

 Structure of a Java Program:

Exception Handling in Java:

Exception handling is a powerful mechanism in Java to handle runtime


errors, ensuring the normal flow of the application. An exception is an event
that disrupts the normal flow of the program's instructions. When an error
occurs within a method, the method creates an exception object and hands it
off to the runtime system. This exception object contains information about
the error, including its type and the state of the program when the error
occurred.

Java provides a robust framework for handling exceptions, divided into


checked exceptions, unchecked exceptions, and errors.

Types of Exceptions:

1. Checked Exceptions:
o Checked exceptions are checked at compile-time.
o These exceptions must be either caught or declared in the method
using the throws keyword.
o Examples include IOException, SQLException, and
ClassNotFoundException.
16
2. Unchecked Exceptions:
o Unchecked exceptions are not checked at compile-time, meaning
they occur at runtime.
o These exceptions do not need to be declared or caught.
o Examples include NullPointerException,
ArrayIndexOutOfBoundsException, and
ArithmeticException.
3. Errors:
o Errors are serious issues that a reasonable application should not try
to catch.
o Examples include OutOfMemoryError and
StackOverflowError.

Exception Handling Mechanism:

Java uses five keywords for exception handling:

 try: A block of code that might throw an exception.


 catch: A block of code to handle the exception.
 finally: A block of code that will always execute, regardless of
whether an exception occurred or not.
 throw: Used to explicitly throw an exception.
 throws: Used in method signatures to declare that a method might throw
exceptions.

Syntax of Exception Handling:


try {
// Code that may throw an exception
} catch (ExceptionType1 e1) {
// Handle exception of type ExceptionType1
} catch (ExceptionType2 e2) {
// Handle exception of type ExceptionType2
} finally {
// Code that will always execute
}

Example:
public class ExceptionExample {
public static void main(String[] args) {
try {
int data = 50 / 0; // This will throw
ArithmeticException
} catch (ArithmeticException e) {
System.out.println("ArithmeticException
caught: " + e.getMessage());

17
} finally {
System.out.println("Finally block
executed");
}
System.out.println("Rest of the code");
}
}

Custom Exceptions: Developers can create custom exceptions by


extending the Exception class.

class CustomException extends Exception {


public CustomException(String message) {
super(message);
}
}

public class CustomExceptionExample {


public static void main(String[] args) {
try {
throw new CustomException("This is a custom
exception");
} catch (CustomException e) {
System.out.println("Caught custom exception:
" + e.getMessage());
}
}
}

Keyword Description
try The "try" keyword is used to specify a block where we should
place an exception code. It means we can't use try block alone.
The try block must be followed by either catch or finally.
catch The "catch" block is used to handle the exception. It must be
preceded by try block which means we can't use catch block
alone. It can be followed by finally block later.
finally The "finally" block is used to execute the necessary code of the
program. It is executed whether an exception is handled or not.
throw The "throw" keyword is used to throw an exception.
throws The "throws" keyword is used to declare exceptions. It specifies
that there may occur an exception in the method.

 Multithreading in Java:

18
Multithreading is a feature in Java that allows concurrent execution of two or
more threads for maximum utilization of the CPU. A thread is a lightweight
sub-process, the smallest unit of processing. Multithreading is used to
perform multiple tasks simultaneously, thus making the application more
efficient.

Benefits of Multithreading:

 Improved performance: By utilizing CPU time more efficiently.


 Simplified modeling: Some applications are easier to model as multiple
independent or semi-independent threads than as a single-threaded
monolithic program.
 Resource sharing: Threads within the same process share resources,
which can simplify communication and data sharing between threads.

Creating Threads:

There are two ways to create a thread in Java:

1. By extending the Thread class:

class MyThread extends Thread {


public void run() {
System.out.println("Thread is running");
}

public static void main(String[] args) {


MyThread t1 = new MyThread();
t1.start(); // Start the thread
}
}

2. By implementing the Runnable interface:

class MyRunnable implements Runnable {


public void run() {
System.out.println("Thread is running");
}

public static void main(String[] args) {


MyRunnable myRunnable = new MyRunnable();
Thread t1 = new Thread(myRunnable);
t1.start(); // Start the thread
}
}

Thread Life Cycle:

A thread in Java can be in one of the following states:


19
1. New: When a thread is created but not yet started.
2. Runnable: When the thread is ready to run, waiting for CPU allocation.
3. Running: When the thread is executing.
4. Blocked/Waiting: When the thread is waiting for a resource or another
thread to complete its task.
5. Terminated: When the thread has completed its execution.

Synchronization:

When multiple threads try to access a shared resource simultaneously, it can


lead to data inconsistency. Synchronization is the process that allows only
one thread to access a resource at a time, thus preventing data inconsistency.

Example of Synchronization:
class Table {
synchronized void printTable(int n) { // Synchronized
method
for (int i = 1; i <= 5; i++) {
System.out.println(n * i);
try {
Thread.sleep(400);
} catch (InterruptedException e) {
System.out.println(e);
}
}
}
}

class MyThread1 extends Thread {


Table t;

MyThread1(Table t) {
this.t = t;
}

public void run() {


t.printTable(5);
}
}

class MyThread2 extends Thread {


Table t;

MyThread2(Table t) {
this.t = t;
}

public void run() {


t.printTable(100);
}
20
}

public class TestSynchronization {


public static void main(String args[]) {
Table obj = new Table(); // Only one object
MyThread1 t1 = new MyThread1(obj);
MyThread2 t2 = new MyThread2(obj);
t1.start();
t2.start();
}
}

6. Collection framework

 Introduction to the Collection Framework:

The Java Collection Framework is a unified architecture for representing and


manipulating collections of data. It is one of the most powerful features of
Java, providing a set of interfaces and classes for storing and managing
groups of objects. The Collection Framework is part of the java.util
package and is designed to handle groups of objects in a more systematic and
efficient manner.

Key Interfaces and Classes in the Collection Framework:

1. Interfaces:
o Collection: The root interface for all collections. It provides general
methods for adding, removing, and accessing elements.
o List: An ordered collection (also known as a sequence) that allows
duplicate elements. Examples include ArrayList,
LinkedList, and Vector.
o Set: A collection that does not allow duplicate elements. Examples
include HashSet, LinkedHashSet, and TreeSet.
o Queue: A collection used to hold multiple elements prior to
processing, typically in a FIFO (first-in-first-out) order. Examples
include PriorityQueue and LinkedList.
o Deque: A double-ended queue that allows insertion and removal of
elements from both ends. Examples include ArrayDeque.
o Map: An object that maps keys to values, with no duplicate keys
allowed. Examples include HashMap, LinkedHashMap, and
TreeMap.
2. Classes:
o ArrayList: A resizable array implementation of the List
interface.
o LinkedList: A doubly-linked list implementation of the List and
Deque interfaces.
21
o HashSet: A hash table-based implementation of the Set interface.
o TreeSet: A Set implementation that uses a tree for storage,
providing an ordered set.
o HashMap: A hash table-based implementation of the Map
interface.
o TreeMap: A Map implementation that uses a tree for storage,
providing an ordered map.
o PriorityQueue: A priority heap implementation of the Queue
interface.
o ArrayDeque: A resizable array implementation of the Deque
interface.

Core Concepts of the Collection Framework:

1. Collections and Interfaces: The Collection Framework is based on a set


of standard interfaces that define the behavior of different types of
collections. These interfaces include Collection, List, Set, Queue,
Deque, and Map. Each interface provides a specific contract that the
implementing classes must adhere to.
2. Iterators: An Iterator is an object that enables you to traverse
through the elements in a collection. The Iterator interface provides
methods like hasNext(), next(), and remove(). The for-each
loop is syntactic sugar for using an Iterator.

Example:
List<String> list = new ArrayList<>();
list.add("A");
list.add("B");
list.add("C");

Iterator<String> iterator = list.iterator();


while (iterator.hasNext()) {
String element = iterator.next();
System.out.println(element);
}

3. Generics: Generics enable types (classes and interfaces) to be parameters


when defining classes, interfaces, and methods. Using generics provides
stronger type checks at compile-time and eliminates the risk of
ClassCastException.

Example:
List<String> stringList = new ArrayList<>();
stringList.add("Hello");

22
stringList.add("World");

for (String str : stringList) {


System.out.println(str);
}

4. Comparable and Comparator: The Comparable interface is used to


define the natural ordering of objects, while the Comparator interface is
used to define custom orderings.

Example of Comparable:

public class Student implements Comparable<Student> {


private int id;
private String name;

public Student(int id, String name) {


this.id = id;
this.name = name;
}

@Override
public int compareTo(Student other) {
return this.id - other.id; // Compare based on id
}
}

Example of Comparator:

import java.util.Comparator;
public class NameComparator implements Comparator<Student> {
@Override
public int compare(Student s1, Student s2) {
return s1.getName().compareTo(s2.getName()); //
Compare based on name
}
}

Commonly Used Collections:

1. ArrayList:
o Dynamic array that allows random access.
o Fast for retrieving elements, slow for adding/removing elements
(except at the end).

Example:
List<String> arrayList = new ArrayList<>();
arrayList.add("Element 1");
arrayList.add("Element 2");
23
2. LinkedList:
o Doubly-linked list implementation.
o Fast for adding/removing elements, slow for random access.

Example:
List<String> linkedList = new LinkedList<>();
linkedList.add("Element 1");
linkedList.add("Element 2");

3. HashSet:
o Unordered collection that does not allow duplicates.
o Fast for adding, removing, and checking for elements.

Example:
Set<String> hashSet = new HashSet<>();
hashSet.add("Element 1");
hashSet.add("Element 2");

4. HashMap:
o Key-value pairs with no duplicate keys.
o Fast for adding, removing, and retrieving elements.

Example:
Map<Integer, String> hashMap = new HashMap<>();
hashMap.put(1, "Value 1");
hashMap.put(2, "Value 2");

7. JDBC

 Introduction to JDBC:

Java Database Connectivity (JDBC) is a standard Java API that facilitates


interaction between Java applications and relational databases. JDBC
provides methods for querying and updating data in a database, offering a
standard interface for database access. This allows developers to write
database-independent code, enabling seamless integration with various
databases like MySQL, Oracle, PostgreSQL, and SQL Server.

Key Components of JDBC:

1. JDBC API: The API defines a set of interfaces and classes for connecting
to a database, sending SQL queries, and processing the results.

24
2. JDBC Driver: A driver is a software component that implements the
JDBC API for a specific database. It translates JDBC method calls into
database-specific calls.
3. DriverManager: This class manages a list of database drivers and
establishes a connection to a database.
4. Connection: Represents a session with a specific database. SQL
statements are executed and results are returned within the context of a
connection.
5. Statement: Used for executing a static SQL statement and returning the
results it produces.
6. PreparedStatement: A subclass of Statement used to execute
precompiled SQL queries with parameterized inputs.
7. ResultSet: Represents the result set of a query, providing methods to
iterate through the results.

Steps to Connect to a Database Using JDBC:

1. Load the JDBC Driver:


o Drivers can be loaded using the Class.forName() method.
This step is not always necessary in modern JDBC versions as
drivers can be auto-registered.
Class.forName("com.mysql.cj.jdbc.Driver");

2. Establish a Connection:
o Use the DriverManager.getConnection() method to
establish a connection to the database.
String url = "jdbc:mysql://localhost:3306/mydatabase";
String username = "root";
String password = "password";
Connection connection = DriverManager.getConnection(url,
username, password);

3. Create a Statement:
o Use the createStatement() method of the Connection
object to create a Statement object.

Statement statement = connection.createStatement();

4. Execute a Query:
o Use the executeQuery() method for SELECT queries or
executeUpdate() for INSERT, UPDATE, DELETE, and DDL
statements.
String sql = "SELECT * FROM employees";

25
ResultSet resultSet = statement.executeQuery(sql);

5. Process the Results:


o Iterate through the ResultSet to process the results of the query.

while (resultSet.next()) {
int id = resultSet.getInt("id");
String name = resultSet.getString("name");
double salary = resultSet.getDouble("salary");
System.out.println("ID: " + id + ", Name: " + name + ",
Salary: " + salary);
}

6. Close the Resources:


o Close the ResultSet, Statement, and Connection objects
to free up database resources.
resultSet.close();
statement.close();
connection.close();

Example Code: Here's an example demonstrating the complete process of


connecting to a MySQL database and retrieving data:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCExample {


public static void main(String[] args) {
String url =
"jdbc:mysql://localhost:3306/mydatabase";
String username = "root";
String password = "password";

try {
// Load the JDBC driver
Class.forName("com.mysql.cj.jdbc.Driver");

// Establish a connection
Connection connection =
DriverManager.getConnection(url, username, password);

// Create a statement
Statement statement =
connection.createStatement();

// Execute a query
String sql = "SELECT * FROM employees";
26
ResultSet resultSet =
statement.executeQuery(sql);

// Process the results


while (resultSet.next()) {
int id = resultSet.getInt("id");
String name = resultSet.getString("name");
double salary =
resultSet.getDouble("salary");
System.out.println("ID: " + id + ", Name: "
+ name + ", Salary: " + salary);
}

// Close the resources


resultSet.close();
statement.close();
connection.close();
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
}
}
}

PreparedStatement:

PreparedStatement is used to execute parameterized queries. It


provides better performance and security compared to Statement because
it precompiles SQL queries and protects against SQL injection attacks.

Example of PreparedStatement:
String sql = "SELECT * FROM employees WHERE department = ?";
PreparedStatement preparedStatement =
connection.prepareStatement(sql);
preparedStatement.setString(1, "Sales");
ResultSet resultSet = preparedStatement.executeQuery();

while (resultSet.next()) {
int id = resultSet.getInt("id");
String name = resultSet.getString("name");
double salary = resultSet.getDouble("salary");
System.out.println("ID: " + id + ", Name: " + name + ",
Salary: " + salary);
}

resultSet.close();
preparedStatement.close();

Batch Processing:

27
Batch processing allows you to group multiple SQL statements into a batch
and execute them all at once, which can significantly improve performance.

Example of Batch Processing:


String sql = "INSERT INTO employees (name, department,
salary) VALUES (?, ?, ?)";
PreparedStatement preparedStatement =
connection.prepareStatement(sql);

preparedStatement.setString(1, "John Doe");


preparedStatement.setString(2, "Engineering");
preparedStatement.setDouble(3, 50000);
preparedStatement.addBatch();

preparedStatement.setString(1, "Jane Smith");


preparedStatement.setString(2, "HR");
preparedStatement.setDouble(3, 60000);
preparedStatement.addBatch();

int[] result = preparedStatement.executeBatch();

System.out.println("Number of rows inserted: " +


result.length);

preparedStatement.close();

Transactions:

Transactions ensure that a series of SQL statements are executed as a single


unit of work. If any statement fails, the entire transaction is rolled back.

Example of Transaction Management:


try {
connection.setAutoCommit(false); // Disable auto-commit

String sql1 = "UPDATE accounts SET balance = balance -


1000 WHERE account_id = 1";
String sql2 = "UPDATE accounts SET balance = balance +
1000 WHERE account_id = 2";

statement.executeUpdate(sql1);
statement.executeUpdate(sql2);

connection.commit(); // Commit the transaction


} catch (SQLException e) {
connection.rollback(); // Roll back the transaction in
case of error
e.printStackTrace();
} finally {

28
statement.close();
connection.close();
}
8. Hibernate

 Introduction to Hibernate:

Hibernate is an open-source Object-Relational Mapping (ORM) framework


for Java. It provides a framework for mapping an object-oriented domain
model to a relational database. Hibernate simplifies the development of Java
applications to interact with the database by eliminating the need for manual
handling of database interactions through JDBC. It allows developers to
work with high-level object-oriented concepts instead of low-level database
queries.

Key Features of Hibernate:

1. Automatic Table Creation: Hibernate can automatically create tables in


the database based on the entity classes.
2. Transparent Persistence: Entities can be persisted without writing
explicit SQL queries.
3. HQL (Hibernate Query Language): A powerful, database-independent
query language similar to SQL but works with the entity objects.
4. Caching: Hibernate supports first-level (session) and second-level
(session factory) caching to improve performance.
5. Lazy Loading: Fetches associated data only when it is accessed, reducing
the initial load time.
6. Transaction Management: Supports ACID transactions, ensuring data
integrity and consistency.
7. Extensible: Easily integrated with other Java EE frameworks like Spring.

Core Components of Hibernate:

1. Configuration Object:
o Represents the configuration or properties file required by
Hibernate.
o Contains information about database dialect, connection details, and
mapping files.

Example:
Configuration cfg = new Configuration();
cfg.configure("hibernate.cfg.xml");

2. SessionFactory:

29
o A thread-safe object used by the application to obtain Session
objects.
o Created once per application and usually instantiated during
application startup.

Example:
SessionFactory factory = cfg.buildSessionFactory();

3. Session:
o A single-threaded, short-lived object representing a conversation
between the application and the database.
o Used to perform CRUD (Create, Read, Update, Delete) operations.

Example:
Session session = factory.openSession();

4. Transaction:
o Represents a unit of work that is atomic in nature. Transactions
ensure data integrity.
o Managed through the Session object.

Example:
Transaction tx = session.beginTransaction();

5. Query:
o Used to execute queries against the database.
o Hibernate provides HQL and criteria queries.

Example:
Query query = session.createQuery("FROM Employee");
List<Employee> list = query.list();

Hibernate Configuration:

To use Hibernate, you need to configure it with the database details and
entity mappings. This configuration is usually done in an XML file named
hibernate.cfg.xml.

Example of hibernate.cfg.xml:

<!DOCTYPE hibernate-configuration PUBLIC


"-//Hibernate/Hibernate Configuration DTD 3.0//EN"

30
"http://hibernate.sourceforge.net/hibernate-
configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property
name="hibernate.dialect">org.hibernate.dialect.MySQLDialect<
/property>
<property
name="hibernate.connection.driver_class">com.mysql.cj.jdbc.D
river</property>
<property
name="hibernate.connection.url">jdbc:mysql://localhost:3306/
mydatabase</property>
<property
name="hibernate.connection.username">root</property>
<property
name="hibernate.connection.password">password</property>
<property
name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.show_sql">true</property>
<property
name="hibernate.format_sql">true</property>
<mapping resource="employee.hbm.xml"/>
</session-factory>
</hibernate-configuration>

Creating an Entity Class:

An entity class represents a table in the database. The fields of the class
represent the columns of the table. Hibernate uses annotations or XML
mappings to map the class to the table.

Example using Annotations:


import javax.persistence.*;

@Entity
@Table(name = "employee")
public class Employee {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;

@Column(name = "name")
private String name;

@Column(name = "salary")
private double salary;

// Getters and Setters


}

31
CRUD Operations with Hibernate:

1. Creating (Inserting) a Record:


Session session = factory.openSession();
Transaction tx = session.beginTransaction();

Employee emp = new Employee();


emp.setName("John Doe");
emp.setSalary(50000);

session.save(emp);
tx.commit();
session.close();

2. Reading (Fetching) a Record:


Session session = factory.openSession();
Employee emp = session.get(Employee.class, 1); // 1 is the
primary key
System.out.println("Employee Name: " + emp.getName());
session.close();

3. Updating a Record:
Session session = factory.openSession();
Transaction tx = session.beginTransaction();

Employee emp = session.get(Employee.class, 1);


emp.setSalary(60000);

session.update(emp);
tx.commit();
session.close();

4. Deleting a Record:
Session session = factory.openSession();
Transaction tx = session.beginTransaction();

Employee emp = session.get(Employee.class, 1);


session.delete(emp);

tx.commit();
session.close();

Hibernate Query Language (HQL):

HQL is similar to SQL but operates on objects rather than tables. It is


database-independent, making it a powerful tool for querying.

32
Example of HQL:
Session session = factory.openSession();
Query query = session.createQuery("FROM Employee WHERE
salary > :salary");
query.setParameter("salary", 40000);
List<Employee> list = query.list();

for (Employee emp : list) {


System.out.println(emp.getName() + " - " +
emp.getSalary());
}

session.close();

Criteria Queries:

Criteria API is another way of querying the database using Java objects and
methods instead of HQL strings.

Example of Criteria Query:


Session session = factory.openSession();
CriteriaBuilder builder = session.getCriteriaBuilder();
CriteriaQuery<Employee> query =
builder.createQuery(Employee.class);
Root<Employee> root = query.from(Employee.class);
query.select(root).where(builder.gt(root.get("salary"),
40000));

List<Employee> list =
session.createQuery(query).getResultList();

for (Employee emp : list) {


System.out.println(emp.getName() + " - " +
emp.getSalary());
}

session.close();

9. Spring Boot

 Introduction to Spring Boot:

Spring Boot is an open-source Java-based framework used to create


standalone, production-grade Spring-based applications with minimal
configuration. It simplifies the process of building and deploying
applications by providing a set of conventions and defaults. Spring Boot is
33
built on top of the Spring Framework and follows the "convention over
configuration" philosophy, aiming to reduce boilerplate code and
configuration.

Key Features of Spring Boot:

1. Autoconfiguration: Spring Boot automatically configures application


components based on dependencies and predefined configurations,
reducing manual setup.
2. Standalone: Spring Boot applications can be deployed as standalone JAR
files, embedding the web server (Tomcat, Jetty, or Undertow) and other
dependencies, simplifying deployment and scaling.
3. Opinionated Defaults: Spring Boot provides opinionated defaults for
commonly used libraries and frameworks, allowing developers to start
quickly without extensive configuration.
4. Spring Ecosystem Integration: Integrates seamlessly with other Spring
projects like Spring Data, Spring Security, and Spring Cloud.
5. Embedded Servers: Supports embedding servlet containers like Tomcat,
Jetty, and Undertow, eliminating the need for external web servers.
6. Production-ready Features: Built-in features such as health checks,
metrics, and externalized configuration make Spring Boot applications
production-ready out of the box.
7. Spring Boot Starters: Pre-configured dependencies (starters) for various
tasks such as web development, data access, messaging, etc., simplify
dependency management.

Creating a Spring Boot Application:

1. Using Spring Initializr:


o Spring Initializr is a web-based tool for generating a Spring Boot
project structure with the required dependencies.
2. Adding Dependencies:
o Dependencies can be specified in the pom.xml file (for Maven) or
build.gradle (for Gradle). Spring Boot starters provide a
convenient way to include required dependencies.

Example of pom.xml for a web application:

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>

3. Creating a Main Application Class:


34
o Create a main class annotated with
@SpringBootApplication. This annotation enables
autoconfiguration and component scanning.

Example:
import org.springframework.boot.SpringApplication;
import
org.springframework.boot.autoconfigure.SpringBootApplicati
on;

@SpringBootApplication
public class MyApplication {

public static void main(String[] args) {


SpringApplication.run(MyApplication.class, args);
}
}

4. Building and Running the Application:


o Use Maven or Gradle build tools to build the project and generate
an executable JAR file.
o Run the application using the java -jar command.

Example using Maven:


mvn clean package
java -jar target/my-application.jar

Spring Boot Annotations and Features:

1. @SpringBootApplication:
o Main annotation to mark a class as a Spring Boot application.
Enables autoconfiguration and component scanning.
2. @RestController:
o Annotation used in Spring MVC to define RESTful controllers.
Combines @Controller and @ResponseBody.

Example:
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api")
public class MyRestController {

@GetMapping("/hello")
public String hello() {
return "Hello, World!";
35
}
}

3. @Autowired:
o Annotation used for automatic dependency injection. Automatically
wires beans by type.

Example:
import
org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MyService {

public String getMessage() {


return "Hello from Service!";
}
}

@RestController
public class MyRestController {

@Autowired
private MyService myService;

@GetMapping("/message")
public String getMessage() {
return myService.getMessage();
}
}

4. Externalized Configuration:
o Spring Boot allows configuration properties to be externalized from
the application code, supporting YAML, properties files, and
environment variables.

Example application.properties:

server.port=8080
myapp.message=Hello, Spring Boot!

Accessing properties in a Spring bean:


import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class MyComponent {

36
@Value("${myapp.message}")
private String message;

public String getMessage() {


return message;
}
}

5. Spring Data Integration:


o Spring Boot seamlessly integrates with Spring Data for database
access, providing repositories and JPA support with minimal
configuration.

Example:
import
org.springframework.data.jpa.repository.JpaRepository;

public interface UserRepository extends JpaRepository<User,


Long> {
// Custom queries can be defined here
}

10. Angular

 Introduction to Angular:

Angular is a TypeScript-based open-source framework developed by Google


for building front-end web applications. It is a comprehensive platform that
provides a structured way to create dynamic Single Page Applications
(SPAs). Angular is popular for its modular architecture, powerful features,
and tools that simplify development tasks like data binding, dependency
injection, routing, and state management.

Key Features of Angular:

1. Component-Based Architecture: Angular applications are built as a


hierarchy of components, each encapsulating HTML, CSS, and TypeScript
logic. Components are reusable and self-contained units of UI.
2. Two-Way Data Binding: Angular provides a powerful data binding
mechanism that synchronizes data between the component and the view
(DOM). Changes in the model update the view, and changes in the view
update the model automatically.
3. Directives: Directives extend HTML with new attributes or elements,
enabling powerful declarative behavior in the UI. Angular has built-in
directives like ngIf, ngFor, and ngStyle, and supports creating custom
directives.
37
4. Dependency Injection (DI): Angular has a built-in DI system that facilitates
injecting dependencies into components, services, and other objects. DI
promotes modular and testable code by enabling loose coupling between
components.
5. Routing: Angular provides a powerful router (@angular/router) for
navigating between views (components) based on the URL. It supports
nested routing, lazy loading of modules, guards for authentication, and
resolver for fetching data before navigating.
6. Forms: Angular offers two types of forms: Template-driven forms and
Reactive forms (Model-driven forms). Template-driven forms are based on
directives and are suitable for simple forms. Reactive forms are model-
driven and offer more control over form validation and state management.
7. HTTP Client: Angular's HttpClientModule allows communication
with a backend server over HTTP/HTTPS. It provides methods for
performing GET, POST, PUT, DELETE, etc., operations and supports
interceptors for modifying requests and responses.
8. RxJS (Reactive Extensions for JavaScript): Angular extensively uses
RxJS for reactive programming. Observables from RxJS are used for
handling asynchronous operations, event handling, and data streams within
Angular applications.
9. Angular CLI: The Angular Command Line Interface (CLI) is a powerful
tool for initializing, developing, scaffolding, and maintaining Angular
applications. It provides commands for generating components, services,
modules, and more.

Getting Started with Angular:

1. Installation:
o Angular applications are created and managed using the Angular
CLI. Install Angular CLI globally using npm:
npm install -g @angular/cli

2. Creating a New Angular Project:


o Use the Angular CLI to generate a new project:

ng new my-angular-app
cd my-angular-app

3. Building and Running the Application:


o Use the Angular CLI commands to build and serve the application:

ng serve --open

This command builds the application and opens it in the default


browser (http://localhost:4200).
38
4. Creating Components:
o Components are the building blocks of Angular applications.
Generate a new component using the Angular CLI:
ng generate component my-component

This command creates the necessary files (my-


component.component.ts, my-
component.component.html, my-
component.component.css) and updates the module file
(app.module.ts) to declare the component.

5. Creating Services:
o Services in Angular are used for encapsulating reusable business
logic, data fetching, and interaction with external services (like
HTTP requests). Generate a service using the Angular CLI:
ng generate service my-service

This command creates a new service file (my-


service.service.ts) with a basic template.

Example of an Angular Component:

An Angular component consists of TypeScript code, HTML template, and


CSS styles.

1. Component TypeScript (my-component.component.ts):

import { Component } from '@angular/core';

@Component({
selector: 'app-my-component',
templateUrl: './my-component.component.html',
styleUrls: ['./my-component.component.css']
})
export class MyComponentComponent {
title = 'Angular Component Example';
message = 'Hello from Angular!';
}

2. Component HTML (my-component.component.html):

<div>
<h1>{{ title }}</h1>
<p>{{ message }}</p>
</div>

39
3. Component CSS (my-component.component.css):

div {
background-color: #f0f0f0;
padding: 20px;
margin: 20px;
border-radius: 5px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

4. Using the Component in App Component (app.component.html):

<app-my-component></app-my-component>

40
11.Completion letter/ Certificate:

41
12. Conclusion

42
During my internship at TechnoGrowth Software Solutions Pvt Ltd, I gained
hands-on experience in diverse technologies such as Java, Hibernate, Spring
Boot, and Angular. This internship provided me with practical insights into
software development practices, including database management, API
development, and front-end application building. I greatly appreciate the
guidance and support from the team, which enhanced my technical skills,
problem-solving abilities, and understanding of agile methodologies. This
internship has prepared me for future career opportunities and instilled in me
a commitment to continuous learning and professional growth in software
development.

43

You might also like