0% found this document useful (0 votes)
13 views34 pages

Java Programming Internship Report - Full Stack

The document is an internship training report by Pothuru Karthik, submitted to the Department of Artificial Intelligence and Data Science at Dhanalakshmi Srinivasan University, detailing his Java programming internship at Codetech. It includes sections on the importance, objectives, and scope of the training, as well as a structured overview of training activities, projects, and the organization profile. The report emphasizes the hands-on experience gained in Java programming, object-oriented principles, and application development techniques during the internship period from September 25 to October 25, 2025.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views34 pages

Java Programming Internship Report - Full Stack

The document is an internship training report by Pothuru Karthik, submitted to the Department of Artificial Intelligence and Data Science at Dhanalakshmi Srinivasan University, detailing his Java programming internship at Codetech. It includes sections on the importance, objectives, and scope of the training, as well as a structured overview of training activities, projects, and the organization profile. The report emphasizes the hands-on experience gained in Java programming, object-oriented principles, and application development techniques during the internship period from September 25 to October 25, 2025.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

Java Programming

An Internship Training Report submitted to

Department of Artificial Intelligence and Data Science

in partial fulfilment of the Degree of

B.Tech. Artificial Intelligence and Data Science

Submitted by

POTHURU KARTHIK(1522051246)

1
Artificial Intelligence and Data Science

Certificate

This is to certify that the Internship Training Report entitled "Java Programming", in partial
fulfilment of the requirements for the award of the Degree of B.Tech. Artificial Intelligence and
Data Science is a record of original training undergone by POTHURU KARTHIK (Reg No.
1522051246) during the year of his study in the Department of Artificial Intelligence and Data
Science, Dhanalakshmi Srinivasan University under my supervision and the report has not formed
the basis for the award of any Degree/Fellowship or other similar title to any candidate of any
University.

Signature of the Guide Signature of Head of the Department

Place:

Date:

Submitted to the Department of Artificial intelligence and Data Science, Dhanalakshmi


Srinivasan University for the examination held on

INTERNAL EXAMINER EXTERNAL EXAMINER

2
INTERNSHIP CERTIFICATE

3
DECLARATION

I,POTHURU KARTHIK (Reg. NO. 1522051246), hereby declare that the Internship Training
Report, entitled "Java Programming" submitted to the Dhanalakshmi Srinivasan University in
partial fulfilment of the requirements for the award of the Degree of B.Tech. Artificial Intelligence
and Data Science is a record of original training undergone by me during the period 25 September
–25 October under the supervision and guidance of Ms.C.Aarthy, Assistant Professor, Department
of Artificial Intelligence and Data Science, Dhanalakshmi Srinivasan University and it has not
formed the basis for the award of any Degree/Fellowship or other similar title to any candidate of any
University.

Place: Signature of the Student

Date:

4
ACKNOWLEDGEMENT

I would like to express my heartfelt gratitude to all those who supported and guided me during
the successful completion of my Java programming internship and this report. First and foremost,
I extend my sincere thanks to the management of CODETECH for providing me with the
invaluable opportunity to undertake my internship in their esteemed organization. Their support,
resources, and professional training environment greatly contributed to my learning and skill
development throughout the training period. I am immensely thankful to the management of
Dhanalakshmi Srinivasan University for their continuous encouragement and for creating an
academic ecosystem conducive to learning and professional growth.

I am profoundly grateful to our respected Dr.S.Padmapriya,Associate Professor Head of the


Department of Artificial intelligence and Data Science for her unwavering guidance, insightful
advice, and valuable mentorship throughout my internship and project work. I would also like to
convey my sincere appreciation to my faculty guide, Ms.C.Aarthy, Assistant Professor,
Department of Artificial intelligence and Data Science for her consistent support, constructive
feedback, and meticulous supervision that enabled me to complete my training and report
effectively. Her encouragement and guidance played a pivotal role in shaping my understanding
and application of Java programming concepts.

Lastly, I extend my gratitude to all my colleagues, peers, and friends who offered their support
and encouragement during this internship journey.

5
Tables of Content

CHAPTER NO. PARTICULARS PAGE NO.

Certificate 2

Company Certificate 3

Declaration 4

Acknowledgement 5

Contents 6

List of Images 7

I
Introduction 8-9

II
Codetech 10 - 12

III Training activities 13 - 14

IV Projects 15 - 21

V Challenges and learning outcomes 22

6
VI Conclusion 23

Appendices

Sample code 24-34


Screen shot

LIST OF IMAGES

FIGURE NO. FIGURE NAME PAGE NO.

1 Basic Java Programs 13

2 Object-Oriented Programming Programs 17

3 Java Collections and File Handling 18

4 Student Management System 19

7
I. INTRODUCTION

1.1 Importance of the Training

The training during my Java programming internship at Codetech was invaluable in bridging
the gap between theoretical knowledge and real-world software development practices. In
today’s technology-driven world, Java plays a crucial role in building secure, portable, and
highperformance applications across web, mobile, and enterprise platforms. Gaining practical
experience in Java enabled me to understand its importance in developing reliable software
systems that meet industry standards.This internship provided hands-on exposure to core and
advanced Java concepts, object-oriented programming, data structures, and application
development techniques. It strengthened my ability to write efficient, maintainable code and
enhanced my problem-solving abilities. Beyond technical learning, the training emphasized
teamwork, debugging practices, version control, and industry workflows, which are essential
for becoming a successful Java developer.

1.2 Objectives of the Training

The main objective of the Codetech Java training program is to equip learners with
comprehensive knowledge and practical skills in Java programming, enabling them to build
robust software applications with confidence. The program aims to strengthen students’
understanding of core Java concepts, object-oriented principles, and essential data structures
while also introducing them to industry-relevant frameworks such as Spring Boot. Through
hands-on projects, coding practice, and mentor-led guidance, the course focuses on enhancing
problem-solving abilities, logical thinking, and real-world application development skills.
Additionally, the training seeks to prepare learners for internship and job opportunities by
offering career support, resume building, and interview preparation, ultimately helping them
become competent and job-ready Java developers.

1.3 Scope of the Training

The Codetech Java training program offers strong scope for students and beginners who want
to build a career in software development. Through a structured 3-month curriculum, learners
gain a solid foundation in Java fundamentals, object-oriented programming, data structures,
algorithms, and essential backend development concepts. The inclusion of Spring Boot and
industry-level projects helps students understand real-world application development, making
them better prepared for technical interviews and professional work environments. With the

8
added support of IBM certification, hands-on project work, and placement assistance, the course
enhances employability and opens opportunities for roles such as Java Developer, Backend
Developer, and Software Engineer. Since Java continues to be widely used in enterprise
applications, banking systems, and large-scale backend systems, the long-term career scope
remains strong. Overall, Codetech’s Java training is a valuable pathway for students aiming for
a stable and growing career in the IT industry.

1.4 Period of the Training

The internship was carried out over a period of one month, during which I actively participated
in learning sessions, coding tasks, and project work from 25th September 2025 to 25th October
2025 During this time, I was able to strengthen my programming skills significantly and
complete various Java-based on mini-project that aligned with industry requirements.

1.5 Chapterisation Scheme

This report is structured into the following chapters for clear and organized documentation:

• Chapter I: Introduction — providing an overview of the internship’s importance,


objectives, scope, period, and report structure related to the Java programming training.
• Chapter II: Organization Profile — describing Codetech mission, background,
services, and operational approach in delivering technical training programs.
• Chapter III: Training Activities — detailing the daily tasks, responsibilities, coding
exercises, and Java-related activities performed throughout the internship.
• Chapter IV: Projects — elaborating on the Java applications developed, concepts
implemented, tools used, and key learning outcomes from each project.
• Chapter V: Challenges and Learning Outcomes discussing the difficulties
encountered during programming tasks, debugging issues, and the technical and
professional skills gained through the internship.
• Chapter VI: Conclusion and Recommendations — summarizing the internship
experience and providing suggestions for enhancing future training programs.

9
II. CODETECH

2.1 About CODETECH

Codetech is a dynamic and forward-thinking organization dedicated to empowering individuals


through skill development and industry-oriented training programs. The company offers
highquality, structured learning experiences in various technical domains, including Java
programming, software development, data science, and emerging technologies. With a strong
focus on bridging the gap between academic concepts and practical industry applications, Skill
Vertex provides hands-on training designed to prepare students and professionals for real-world
challenges.

Established with the mission of enhancing employability among learners, Codetech collaborates
with industry experts, educational institutions, and corporate partners to ensure that its training
modules remain aligned with current technological trends. The organization emphasizes not
only technical expertise—such as Java fundamentals, OOP concepts, database connectivity, and
application development—but also essential soft skills like teamwork, communication, and
analytical thinking. This holistic approach equips learners with the knowledge and confidence
needed to excel in competitive technology-driven careers.

2.2 Vision and Mission

Vision: To become a leading global platform for skill development and applied learning,
empowering individuals with industry-relevant technical expertise to succeed in a rapidly
evolving digital world.

Mission:

• To provide high-quality, affordable, and practical training programs in emerging and


indemand technologies.

• To foster critical thinking, innovation, and problem-solving abilities among learners.


• To build strong partnerships with academic institutions and industry leaders for
comprehensive learning experiences.

• To help students bridge the gap between classroom learning and industry expectations
through hands-on projects, coding exercises, and internship-based training.

10
2.3 Key Domains

Codetech offers training and development programs across multiple specialized domains,
including:

• Java Programming and Software Development


• Full Stack Web Development
• Data Science and Machine Learning
• Cybersecurity
• UI/UX Designing
• Cloud Computing and DevOps
• Aptitude and Soft Skills Training

2.4 Services Offered

Codetech provides comprehensive training services in Java programming and related


technologies, including:

• Internship Programs: Practical Java-based training focused on core and advanced


concepts, hands-on coding exercises, and real-time project development to strengthen
programming skills.

• Workshops & Bootcamps: Intensive short-term sessions covering essential Java topics
such as OOP concepts, collections, exception handling, file handling, multithreading, and
introductory frameworks.

• Corporate Training: Customized Java training solutions for organizations aiming to


upskill their workforce in software development, programming logic, and application
building.

• Capstone Projects: Real-world Java application development projects that simulate


industry challenges, helping learners apply theoretical knowledge to practical scenarios.

• Mentorship & Career Guidance: One-on-one mentoring, coding support, resume


building, interview preparation, and guidance for roles in Java development and software
engineering.

11
2.5 Benefits of Codetech Java Programming Training

Codetech’s Java programming programs offer significant advantages:

• Emphasis on hands-on learning through real coding tasks, problem-solving sessions,


and Java-based projects.

• Training aligned with industry requirements, focusing on current technologies,


programming standards, and employer expectations.

• Flexible and scalable course offerings suitable for beginners, intermediate learners, and
working professionals.

• Strong focus on employability, including development of soft skills, logical reasoning,


and technical readiness for software development roles.

• Affordable and high-value learning experience, ensuring accessible and effective


training for all learners.

2.6 Address and Contact Information

Corporate Office:

Codetech 8-7-7/2,Plot No.51 Opp:Naveena


School,HasthinapuramCentral,Hyderabad,500
079,Telangana

Contact Information:

• Phone: +91 6301408361

• Email: www.codetech.com

• Website:https://codetech.com,

12
III. TRAINING ACTIVITIES
3.1 Training Activities Overview
The Java programming internship at Codetech was carefully structured to gradually strengthen
both my theoretical foundation and practical programming abilities. Each session helped deepen
my understanding of core Java concepts, object-oriented principles, and application development
techniques. The hands-on training approach allowed me to apply industry-oriented coding
practices, improve my problem-solving skills, and work on real-time Java programs and
miniprojects. Through this well-designed learning experience, I gained confidence in writing
efficient code, debugging issues, and understanding how Java is effectively used to build robust,
scalable applications.

3.2 Task 1: Basic Java Programs

My first task involved writing simple Java programs focusing on arithmetic operations, control
statements, loops, and conditional logic. These exercises helped me understand the structure of a
Java program and the role of variables, data types, and operators.

• Outcome: Successfully implemented multiple beginner-level Java programs


demonstrating correct syntax usage, logic building, and execution using the Java compiler.

• Learning: Strengthened my understanding of Java fundamentals, loop constructs,


conditional statements, and the basic structure of executable programs.

3.3 Task 2: Object-Oriented Programming Programs

The second task focused on implementing Object-Oriented Programming concepts such as


classes, objects, constructors, inheritance, polymorphism, and encapsulation. I created small
applications to demonstrate each concept.

• Outcome: Built OOP-based Java programs such as employee management modules,


inheritance hierarchies, and class-based operations showcasing correct implementation of OOP
principles.

• Learning: Enhanced skills in designing modular programs, reusing code, working with
objects, and applying core OOP features effectively

3.4 Task 3: Java Collections and File Handling

13
In this task, I developed programs using the Java Collections Framework (ArrayList, HashMap,
LinkedList) and practiced file input/output operations for reading and writing data.

• Outcome: Delivered functional programs involving data storage, retrieval, sorting, and
file operations for data management.

• Learning: Gained experience in data structures, file handling, exception management,


and writing efficient, structured code.

3.5 Task 4: Student Management System

The final task was to develop a console-based Student Management System using Java, where
users could add, update, search, and delete student records. The program also included
menudriven options and error handling.

• Outcome: Created a fully functional Java-based management application supporting


CRUD operations with clean and user-friendly logic flow.

• Learning: Improved skills in project structuring, user input handling, data management,
and integrating multiple Java concepts in a single application.

These activities provided a strong foundation in Java programming and gave me valuable
handson experience in developing real-world applications. The structured learning approach
prepared me to confidently handle more advanced Java projects and software development tasks
in the future.

14
IV. PROJECTS

4.1 Project 1: Java-Based Console Application Introduction:


The first task assigned during my internship was to develop a Java-based console application
focusing on core object-oriented programming (OOP) concepts. The goal was to create a
functional program that performs specific operations using classes, methods, and data
handling techniques in Java.

Objectives:

• Create an efficient and user-friendly console application using Java.


• Implement OOP concepts such as classes, objects, inheritance, and methods.
• Ensure proper handling of user input and display meaningful output.

Development and Implementation:

Using Java, I designed the program structure by defining classes and implementing functions
to handle the required operations. The project involved reading user input through the Scanner
class performing logical operations, and printing structured output.

Exception handling was used to avoid runtime errors, and modular programming techniques
ensured code readability.

Outcome:

The final product was a fully functional Java console application that performed the intended
tasks smoothly. The structured approach improved program efficiency and made debugging
easier.

Learning:

This task enhanced my understanding of Java syntax, object-oriented programming,


exception handling, and modular coding practices. I gained hands-on experience in building
Java applications and managing program flow effectively.

This task strengthened my understanding of Java-based web application development,


backend-frontend integration, event handling, and responsive UI design.

15
4.2 Task 2: Object-Oriented Programming
16
The second task during my internship focused on developing Java programs using
ObjectOriented Programming (OOP) principles. This task helped me understand how real-
world entities can be modeled in Java using classes, objects, and various OOP concepts. The
goal was to build structured, reusable, and modular programs.
Objectives:

• Learn core OOP concepts such as classes, objects, inheritance, polymorphism,


encapsulation, and abstraction.

• Implement Java programs that demonstrate real-world modeling through OOP.


• Write programs that improve modularity and reusability using methods and class
structures.

• Strengthen understanding of constructor usage and access modifiers.

Development and Implementation:

Using Java, I developed multiple OOP-based programs that implement the major concepts of
object-oriented programming. The tasks included:

• Class and Object Program – Creating simple classes with attributes and methods.

• Constructor Program – Implementing parameterized and default constructors.

• Inheritance Program – Demonstrating single and multilevel inheritance.

• Polymorphism Program – Using method overloading and overriding.

• Encapsulation Program – Using private data members with getter and setter methods.

• Abstraction Program – Implementing abstract classes and interfaces.

Each program was structured to clearly reflect how OOP improves organization, maintainability,
and reusability in software development.

Outcome:

The final output was a collection of well-structured OOP programs demonstrating all major
principles of object-oriented programming. These programs helped me understand how Java is
used to build large-scale applications using modular design.

17
4.3 Task 3: Java Collections and File Handling
The third task of my internship focused on implementing Java programs using Collections
Framework and File Handling techniques. The goal was to understand how Java manages
dynamic data structures and how to read/write data using files for persistent storage.

Objectives:

• Learn the purpose and usage of Java Collections such as ArrayList, HashSet, and
HashMap.

• Implement programs that store, update, and retrieve data using collection classes.
• Understand file input and output operations using FileReader, FileWriter, BufferedReader,
and BufferedWriter.

• Practice creating, reading, writing, and appending data to files.

Development and Implementation:

Using Java, I developed several programs demonstrating the use of collections and file handling.
These included:
• ArrayList Program: Adding, removing, and iterating through list elements.
• HashSet Program: Ensuring unique entries and demonstrating set operations.
• HashMap Program: Storing key-value pairs and performing lookups.
• File Write Program: Writing user data into a text file.
• File Read Program: Reading file content line by line through buffered streams.
18
• Combined Program: Using collections to store user data and exporting it to files.

These programs were executed through the command line using JDK, ensuring efficient data
management and file operations.

Outcome:

The final output was a set of practical Java programs demonstrating dynamic data storage using
Collections and file persistence using File I/O. This task enhanced my understanding of data
structures and file management in Java.

Learning:

This task improved my ability to handle data efficiently using Java’s built-in collection classes. It
also strengthened my understanding of file operations, buffered streams, and persistent data
storage.

4.4 Task 4: Student Management System

The fourth task assigned during my internship involved developing a Student Management
System using Java. The goal of this project was to create a program that could efficiently manage

19
student records, including adding, updating, deleting, and displaying student details. This task
helped me apply object-oriented principles and data-handling skills in a real-world scenario.

Objectives:

• Build a structured Java application using classes and objects to represent student data.

• Implement CRUD (Create, Read, Update, Delete) operations using Java logic.

• Use Collections Framework such as ArrayList to store multiple student objects


dynamically.

• Improve the ability to manage and organize data within a program.

Development and Implementation:

Using Java, I designed a simple console-based Student Management System. The implementation
included:

• Student Class: Contained attributes like ID, name, age, department, and marks along with
constructors and getter/setter methods.

• ArrayList Storage: Used to store and manage multiple student objects efficiently.

• Menu-Driven Program: Allowed users to choose actions like adding new students,
viewing all students, searching for a student, updating details, or deleting records.

• Input Handling: Utilized Java’s Scanner class to collect user input from the console.

• Validation: Added basic validations to avoid duplicate IDs and incorrect data.

This task helped me integrate object-oriented design with data structures in a functional Java
program.

Outcome:

The final output was a functional and user-friendly Student Management System capable of
handling multiple student records. This enhanced my understanding of real-world application
development using Java.

Learning:

20
Through this project, I developed strong skills in object-oriented programming, data management
using collections, and writing modular, structured Java code. It also strengthened my
problemsolving skills and taught me how to design interactive Java applications.

21
V. CHALLENGES AND LEARNING OUTCOME
During my journey of learning the Java programming language, I encountered several
challenges that played a significant role in strengthening my technical foundation and
problemsolving abilities. One of the major challenges was understanding the depth of Object-
Oriented Programming (OOP) concepts such as inheritance, polymorphism, abstraction, and
encapsulation. Applying these principles effectively in real projects required continuous practice
and conceptual clarity. Another challenge was managing Java’s strict syntax requirements,
where even minor errors in brackets, data types, or method structures often resulted in
compilation issues. This process, although demanding, improved my attention to detail and
logical thinking. Working with Java Collections such as ArrayList, HashMap, and HashSet also
presented difficulties initially, especially in understanding their internal behavior and choosing
the appropriate data structure for different scenarios. File handling and exception management
further added complexity, requiring a proper understanding of Java I/O streams and robust
errorhandling mechanisms. Debugging runtime exceptions such as NullPointerException and
ClassCastException strengthened my analytical skills and ability to identify root causes
efficiently.

Learning Outcomes

Despite these challenges, the learning process significantly enhanced my overall proficiency in
Java. Through consistent practice and guidance, I gained strong command over OOP principles
and became confident in designing modular, reusable, and scalable Java applications. I
developed practical expertise in using Java Collections, file handling, and exception
management, which are essential for building reliable backend systems. Additionally, working
on Java projects improved my logical reasoning, algorithmic thinking, and code-optimization
skills. I also learned the importance of writing clean, well-structured code and using
industrylevel practices such as proper documentation, efficient debugging techniques, and
systematic project organization. Beyond technical skills, learning Java improved my confidence
in problem-solving and prepared me to handle real-world project requirements more effectively.
Overall, this experience has laid a solid technical foundation, enabling me to grow as a
competent developer and adapt efficiently in the fast-paced field of software development.

22
VI. CONCLUSION

Learning Java programming has been a highly enriching and transformative experience,
bridging the gap between theoretical concepts and practical software development skills.
Through this learning journey, I immersed myself in core Java principles, including
objectoriented programming, collections, exception handling, and file management. These
concepts not only strengthened my technical foundation but also enabled me to develop
structured, efficient, and scalable applications. Working on Java-based projects deepened
my understanding of writing clean, maintainable code and following modular design
practices, which are essential for building robust software systems.
The hands-on exercises and project implementations significantly enhanced my
problemsolving abilities, especially as I navigated debugging challenges, optimized code
performance, and applied suitable data structures for real-world scenarios. These
experiences helped me cultivate essential programming habits such as logical thinking,
accuracy, and effective code organization. Moreover, the process improved my confidence
in handling complex programming tasks and prepared me to approach software
development with a more analytical and solution-oriented mindset.
Beyond technical skills, learning Java also fostered valuable soft skills such as patience,
persistence, and continuous learning—qualities that are crucial in the ever-evolving field of
technology. This journey has laid a strong foundation for my growth as a developer and has
motivated me to further enhance my expertise in advanced Java frameworks and backend
development. Moving forward, I am better equipped to apply my knowledge, take on more
challenging projects, and contribute meaningfully to the software industry.

23
VII. APPENDIES

Basic Java Programs import java.util.Scanner; public

class EvenOdd {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);


System.out.print("Enter a number: ");
int num = sc.nextInt(); if(num % 2 ==
0) {

System.out.println(num + " is Even");

} else {

System.out.println(num + " is Odd");

}
} public class Factorial { public static

void main(String[] args) { int num

= 5, fact = 1; for(int i = 1; i <=

num; i++) { fact *= i;

System.out.println("Factorial: " + fact);

} public class Fibonacci { public static

void main(String[] args) {

int a = 0, b = 1, c;

System.out.print(a + " " + b + " ");

24
for(int i = 1; i <= 10; i++) {

c = a + b;

System.out.print(c + " ");

a = b; b = c;

} public class ReverseNumber {

public static void main(String[] args) {

int num = 1234, rev = 0; while(num

!= 0){ int digit = num % 10;

rev = rev * 10 + digit; num /= 10;

System.out.println("Reversed: " + rev);

} public class Palindrome { public static

void main(String[] args) { int num = 121,

temp = num, rem, rev = 0; while(num >

0) { rem = num % 10; rev =

rev * 10 + rem;

num /= 10;

if(temp == rev)

25
System.out.println("Palindrome number");

else

System.out.println("Not a palindrome");

Object-Oriented Programming Programs

class Student {

String name;

int age; void

display() {

System.out.println("Name: " + name);

System.out.println("Age: " + age);

} public class Main { public static

void main(String[] args) { Student

s1 = new Student(); s1.name =

"Rahul"; s1.age = 20;

s1.display();

} class

Animal {

void eat() {

System.out.println("Animals eat food");

}
26
} class Dog extends Animal

{ void bark() {

System.out.println("Dog barks");

} public class TestInheritance { public

static void main(String[] args) {

Dog d = new Dog();

d.eat();

d.bark();

} class Shape {

void draw() {

System.out.println("Drawing shape");

} class Circle extends Shape

{ void draw() {

System.out.println("Drawin

g circle");

class Square extends Shape {

void draw() {

System.out.println("Drawing square");

27
}

public class Polymorphism { public

static void main(String[] args) {

Shape s; s = new Circle();

s.draw(); s=

new Square();

s.draw();

} abstract class

Vehicle { abstract

void start();

} class Bike extends Vehicle

{ void start() {

System.out.println("Bike starts with kick");

public class AbstractDemo { public

static void main(String[] args) {

Vehicle v = new Bike();

v.start();

28
class BankAccount { private double

balance; public void deposit(double

amount) { balance += amount;

public double getBalance() {

return balance;

public class EncapsulationDemo { public

static void main(String[] args) {

BankAccount b = new BankAccount();

b.deposit(5000);

System.out.println("Balance: " + b.getBalance());

Java Collections & File Handling import

java.util.ArrayList;

public class ArrayListExample { public

static void main(String[] args) {

ArrayList<String> names = new ArrayList<>();

29
names.add("John");

names.add("Riya");

names.add("Asha");

for(String s : names) {

System.out.println(s);

import java.util.HashMap;

public class HashMapExample { public

static void main(String[] args) {

HashMap<Integer, String> map = new HashMap<>();

map.put(101, "Ram");

map.put(102, "Shyam");

map.put(103, "Mohan");

System.out.println(map);

import java.io.FileWriter;

public class FileWrite { public static

void main(String[] args) {

try {

FileWriter fw = new FileWriter("output.txt");

fw.write("Hello Java File Handling!");

fw.close();
30
System.out.println("File written successfully.");

catch(Exception e) {

System.out.println(e);

import java.io.FileReader;

public class FileRead { public static

void main(String[] args) {

try {

FileReader fr = new FileReader("output.txt");

int i; while((i =

fr.read()) != -1) {

System.out.print((char)i);

fr.close();

catch(Exception e) {

System.out.println(e);

Student Management

System import java.util.*;

import java.io.*;

class Student {
31
int id;

String name;

int age;

Student(int id, String name, int age)

{ this.id = id; this.name =

name; this.age = age;

public String toString() { return

id + " " + name + " " + age;

public class StudentManagementSystem {

static ArrayList<Student> students = new ArrayList<>();

public static void addStudent() {

Scanner sc = new

Scanner(System.in);

System.out.print("Enter ID: "); int id

= sc.nextInt();

System.out.print("Enter Name: ");

String name = sc.next();

System.out.print("Enter Age: "); int

age = sc.nextInt();

students.add(new Student(id, name, age));

System.out.println("Student Added Successfully!\n");


32
}

public static void displayStudents() {

for(Student s : students) {

System.out.println(s);

public static void saveToFile() {

try {

FileWriter fw = new FileWriter("students.txt");

for(Student s : students) {

fw.write(s.toString() + "\n");

fw.close();

System.out.println("Data Saved to File!\n");

catch(Exception e) {

System.out.println(e);

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

int choice;

while(true) {

System.out.println("\n----- Student Management System -----");

System.out.println("1. Add Student");

System.out.println("2. Display Students");


33
System.out.println("3. Save to File");

System.out.println("4. Exit");

System.out.print("Enter Choice: ");

choice = sc.nextInt();

switch(choice) { case 1: addStudent();

break; case 2: displayStudents(); break;

case 3: saveToFile(); break; case 4:

System.exit(0); default:

System.out.println("Invalid Choice!");

34

You might also like