Summer - Training - File by Divyansh Srivastava
Summer - Training - File by Divyansh Srivastava
CERTIFICATE
This is to certify that the summer training project entitled “JAVA TRAINING” has been
prepared by Mr. Divyansh Srivastava under my supervision. This report has been completed as
a partial fulfilment of the requirements for the award of the degree “Bachelor of Computer
1
ACKNOWLEDGEMENT
I would like to express my special thanks of gratitude to our sir Dr. Santosh Pandey as well as
my project guide Mr. Arun Singh Yadav and my trainer Mr. Vivek Agarwal who gave me the
golden opportunity to do this wonderful project which also helped me in doing a lot of research
and I came to know about so many new things. I am really thankful to them.Secondly, I would
like to think my teachers Mr. Hemant Panday, Mr. Shivansh ojha, Mr. Akash Yadav, and Mr.
Pradyumna Mishra who helped me a lot in finalizing this project within the limited time
frame.Also, I would like to thank my parents for moral support and my teachers for their
With Regards,
Divyansh Srivastava
2311644050075
Department of Computer Science,
Goel Institute of Higher Studies Mahavidyalaya, Lucknow
2
ABOUT THE COLLEGE
G.I.H.S.M. Lucknow is one of the premier higher education institution which aims to provide
quality education to the students in the field of technical and professional education. The
institute was established with a vision to bring together the students from all backgrounds and
to motivate them to realise their potentials.
G.I.H.S.M. Lucknow was established in the year 2010. It offers various undergraduate and
postgraduate courses in the field of engineering, computer science and others. Apart from UG
and PG courses, it also has diploma courses in mechanical, civil and electrical engineering
disciplines.
The faculty of G.I.H.S.M. Lucknow is a blend of both industry experts and academicians so
that the students get the best of both the worlds. The faculty believes in imparting both
theoretical and practical knowledge for the overall personality development.
3
TRAINING ORGANIZATION CERTIFICATE
4
ABOUT THE ORGANISATION
SHRI BALAJI INFOTECH the software development company and working for the customer
satisfaction. Shri Balaji Infotech provides professional services focused on custom software
and web solutions for businesses worldwide. Our mission is to deliver cost effective, quality-
centric, timelines and scalable solutions thus helping our clients and partners to achieve
outstanding business results and generate great returns. At the helm of affairs it has strong
technical team to develop and manage software’s and create strong support for large
corporations worldwide.
In Shri Balaji Infotech we are trying to provide high quality human capital practicing ethical
business standards to our clients. We develop high-quality eye catching websites and softwares
that comply with all today's standards.
SHRI BALAJI INFOTECH provides professional services focused on custom software and
web solutions for businesses worldwide. Our mission is to deliver cost effective, quality-
centric, timelines and scalable solutions thus helping our clients and partners to achieve
outstanding business results and generate great returns. At the helm of affairs it has strong
technical team to develop and manage software’s and create strong support for large
corporations worldwide.
SBIT is an Offshore Software Development specialist that combines the definite bottom-line
benefits of Offshore Outsourcing with its recognized expertise in strategic global models that
help it in providing reliable Outsourcing Software Development Solutions. The services offered
cover Custom Software Development, Application Development, Web Application
Development, E-commerce web site design, Web Marketing, Website Design and Software
Maintenance. Our goal is to deliver premium quality software development services and
products while giving unmatched value to enterprises worldwide at an affordable cost. Our
transparent, efficient and flexible world class software development process zero downs risks
of project failures and creates powerful software solutions that meet present as well as future
demands. They can give you real feedback about us. If you have any query regarding our
services just fill our feedback form our business executives will get back to you within 24 hours
or you can contact us through the numbers available on our contact us page.
You can mail us at mail [email protected]
5
ABOUT THE TRAINER
Vivek Agarwal
Email Id:- [email protected]
Contact:- 9935868159
Objective
Process-Oriented Seeking assignment in software development a growth oriented organization
preferably IT, Service Industry and strive for excellence with dedication, positive attitude and
passion towards the work.
Work Experience
(1) Tech Mahindra, STPI Lucknow working as a Software developer, 2005.
(2) Niest Noida working as a Software developer, 2007
(4) Currently running a Education, development and automation firm M/S Shri Balaji Infotech
in Lucknow from 2008.
Technical Expertise:
Programming Languages: C,C++,C#,java,python.
Technologies : Django, REST, API,MERN,MachineLearning.
Web Related : html,css,jquery,bootstrap,react js.
Front End Tools : Visual Studio ,PyCharm,Sublime,vs code.
RDBMS : MS SQL Server ,mysql.
Networking : CCNA
Education:
6
TABLE OF CONTENT
2. Constructor 16-19
2.1 Default constructor
2.2 Parameter constructor
2.3
3. Inheritance 19-24
3.1 Single inheritance
3.2 Multilevel inheritance
3.3 Hierarchical inheritance
3.4 Hybrid inheritance
3.5 Multiple inheritance
4. Overriding 24-25
5. Overloading 25-26
6. Abstraction 27
6.1 Abstract class
8. polymorphism 34-35
9. Encapsulation 36
7
TOOLS &TECHNOLOGY
During this industrial training I have used various tools for programming, problem solving and
documentation. Here are the tools used during and after that to develop this projects report:
Tools:
• Code Editor: VS Code: Visual Studio Code combines the simplicity of a source code editor
with powerful developer tooling, like IntelliSense code completion and debugging.
First and foremost, it is an editor that gets out of your way. The delightfully frictionless edit-
build-debug cycle means less time fiddling with your environment, and more time executing
on your ideas.
SOME FEATURES OF VS CODE:
1. Command Line
2. Command Palette
3. Git Integration
4. Change language mode
5. Customization
6. Zen Mode
7. Split view
8. Status Bar
9. Debugging
10. Default Keyboard shortcuts
Technology
• Java 8: Java 8 is the most awaited release of Java programming language development
because, in the entire history of Java, it never released that many major features. It consists of
major features of Java. It is a new version of Java and was released by Oracle on 18 March
2014. Java provided support for functional programming, new Java 8 APIs, a new JavaScript
engine, new Java 8 streaming API, functional interfaces, default methods, date-time API
changes, etc.
There are a few major Java 8 features mentioned below:
• Lambda Expressions: Concise functional code using ->.
• Functional Interfaces: Single-method interfaces.
• Introduced and Improved APIs:
Stream API: Efficient Data Manipulation.
Concurrency API Improvements: New classes for parallel processing
▪ Optional Class: Handle null values safely.
▪ forEach() Method in Iterable Interface: Executes an action for each
element.
▪ Default Methods: Evolve interfaces without breaking compatibility.
▪ Static Methods: Allows adding methods with default implementations.
▪ Method References: Refer to methods easily.
• Maven
• SpringBoot
8
ABOUT TOOLS
9
1. Write a program to add two numbers using java.
class Main {
}}
Output.
10+20 = 30
import java.util.Scanner;
public class SwapTwoNumbers {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
10
b = temp;
scanner.close();
}
}
Output
import java.util.Scanner;
scanner.close();
11
}
}
Output.
Enter the first number: 15
Enter the second number: 10
The largest number is: 15
import java.util.Scanner;
scanner.close();
}
}
Output.
Enter a number: 25
25 is divisible by 5.
import java.util.Scanner;
12
// Check if the number is a multiple of both 3 and 5
if (number % 3 == 0 && number % 5 == 0) {
System.out.println(number + " is a multiple of both 3 and 5.");
} else {
System.out.println(number + " is not a multiple of both 3 and 5.");
}
scanner.close();
}
}
Output.
Enter a number: 15
15 is a multiple of both 3 and 5.
Enter a number: 10
10 is not a multiple of both 3 and 5.
import java.util.Scanner;
scanner.close();
}
13
}
Output.
Enter a year: 2020
2020 is a leap year.
Enter a year: 1900
1900 is not a leap year.
import java.util.Scanner;
scanner.close();
}
}
Output.
Enter a character: A
A is a vowel.
Enter a character: b
b is a consonant.
import java.util.Scanner;
14
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
scanner.close();
}
}
Output.
Enter a character: A
A is an uppercase letter.
Enter a character: g
g is a lowercase letter.
import java.util.Scanner;
15
break;
case 2:
dayName = "Tuesday";
break;
case 3:
dayName = "Wednesday";
break;
case 4:
dayName = "Thursday";
break;
case 5:
dayName = "Friday";
break;
case 6:
dayName = "Saturday";
break;
case 7:
dayName = "Sunday";
break;
default:
dayName = "Invalid input. Please enter a number between 1 and 7.";
}
scanner.close();
}
}
Output.
Enter a number (1-7) for the day of the week: 3
Wednesday
16
double height = scanner.nextDouble();
scanner.close();
}
}
Output:
Enter the base of the triangle: 5
Enter the height of the triangle: 10
The area of the triangle is: 25.0
import java.util.Scanner;
scanner.close();
}
}
OUTPUT:-
17
Enter the principal amount: 1000
Enter the rate of interest (in %): 5
Enter the time (in years): 2
The simple interest is: 100.0
scanner.close();
}
}
OUTPUT:-
Enter a number: 10
Original number: 10
Incremented number: 11
Decremented number: 9
18
// Calculate the perimeter
double perimeter = 4 * side;
scanner.close();
}
}
OUTPUT
Enter the length of a side of the square: 5
The perimeter of the square is: 20.0
import java.util.Scanner;
scanner.close();
}
}
OUTPUT:-
import java.util.Scanner;
class Rectangle {
// Instance variables
private double length;
private double width;
19
// Constructor to initialize the rectangle
public Rectangle(double length, double width) {
this.length = length;
this.width = width;
}
scanner.close();
}
}
OUTPUT:-
import java.util.Scanner;
class Rectangle {
// Instance method to calculate area with parameters
20
public double calculateArea(double length, double width) {
return length * width;
}
}
scanner.close();
}
}
OUTPUT:-
// Class definition
class Person {
// Instance variables
String name;
int age;
// Default constructor
public Person() {
name = "Unknown";
age = 0;
}
21
// Method to display person details
public void displayInfo() {
System.out.println("Name: " + name);
System.out.println("Age: " + age);
}
}
OUTPUT:-
Name: Unknown
Age: 0
import java.util.Scanner;
class Rectangle {
// Instance variables
private double length;
private double width;
22
public class RectangleCalculator {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
scanner.close();
}
}
OUTPUT:-
// Base class
class Animal {
// Method in the base class
public void eat() {
System.out.println("This animal eats food.");
}
}
// Derived class
class Dog extends Animal {
// Method in the derived class
public void bark() {
System.out.println("The dog barks.");
}
}
23
public class SingleInheritanceExample {
public static void main(String[] args) {
// Create an instance of the Dog class
Dog dog = new Dog();
OUTPUT:-
// Base class
class Animal {
// Method in the base class
public void eat() {
System.out.println("This animal eats food.");
}
}
24
bulldog.eat(); // Method from the Animal class
bulldog.bark(); // Method from the Dog class
bulldog.showAffection(); // Method from the Bulldog class
}
}
OUTPUT:-
// Base class
class Animal {
// Method in the base class
public void eat() {
System.out.println("This animal eats food.");
}
}
// Derived class 1
class Dog extends Animal {
// Method in the Dog class
public void bark() {
System.out.println("The dog barks.");
}
}
// Derived class 2
class Cat extends Animal {
// Method in the Cat class
public void meow() {
System.out.println("The cat meows.");
}
}
25
cat.eat(); // Method from the Animal class
cat.meow(); // Method from the Cat class
}
}
OUTPUT:-
// Base class
class Animal {
public void eat() {
System.out.println("This animal eats food.");
}
}
// Derived class 1
class Dog extends Animal {
public void bark() {
System.out.println("The dog barks.");
}
}
// Derived class 2
class Cat extends Animal {
public void meow() {
System.out.println("The cat meows.");
}
}
// Interface
interface Pet {
void play();
}
26
public static void main(String[] args) {
// Create instances of Dog, Cat, and Bulldog classes
Dog dog = new Dog();
Cat cat = new Cat();
Bulldog bulldog = new Bulldog();
OUTPUT:-
// Second interface
interface CanMeow {
void meow();
}
27
// Class implementing multiple interfaces
class Cat implements CanMeow {
@Override
public void meow() {
System.out.println("The cat meows.");
}
}
OUTPUT:-
28
// Overloaded method to add three integers
public int add(int a, int b, int c) {
return a + b + c;
}
OUTPUT:-
29
public static void main(String[] args) {
AreaCalculator calculator = new AreaCalculator();
OUTPUT:-
// Regular method
void sleep() {
System.out.println("The animal is sleeping.");
}
}
30
}
Output:
Bark
The animal is sleeping.
Meow
The animal is sleeping.
❖ WRITE A JAVA PROGRAM USING ABSTRACTION
Output:
Roar
31
private class InnerClass {
private String message;
OUTPUT:-
32
// Method to display car details
public void displayInfo() {
System.out.println("Car Make: " + make);
System.out.println("Car Model: " + model);
System.out.println("Car Year: " + year);
System.out.println(" ------------------- ");
}
}
Output:
Car Make: Toyota
Car Model: Camry
Car Year: 2020
33
return a - b;
}
Output:
Addition (5 + 3): 8
Subtraction (5 - 3): 2
Multiplication (5 * 3): 15
Division (5 / 2): 2.5
Cannot divide by zero.
Division (5 / 0): 0.0
34
class EnglishGreeting implements Greeting {
@Override
public void sayHello() {
System.out.println("Hello!");
}
}
35
}
class Main {
public static void main(String[] args) {
Output:
Reversed Number: 4321
import java.util.Scanner;
36
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
scanner.close();
}
Output:
Enter a string: A man, a plan, a canal, Panama
The string is a palindrome.
37
// Display the result
System.out.println("Hexadecimal representation: " + hexString);
}
Output:
Hexadecimal representation: 0A0F101F64FF
// Base class
class Animal {
public void makeSound() {
System.out.println("Animal makes a sound");
}
}
// Subclass Dog
class Dog extends Animal {
@Override
public void makeSound() {
System.out.println("Dog barks");
}
}
// Subclass Cat
class Cat extends Animal {
@Override
public void makeSound() {
System.out.println("Cat meows");
}
38
}
Output:
Dog barks
Cat meows
Dog barks
Cat meows
39
A1. setAge (12);
// access age using getter
System.out.println(“ animal age is ” + a1. getage( ) );
}
}
Output:
Animal age is 12
40
PROJECT CODE
package MyPackage;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Date;
import java.util.Scanner;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
/**
*/
/**
* @see HttpServlet#HttpServlet()
*/
public MyServlet() {
super();
41
// TODO Auto-generated constructor stub
/**
*/
response.sendRedirect("index.html");
/**
*/
//API Key
try {
connection.setRequestMethod("GET");
42
InputStream inputStream = connection.getInputStream();
// System.out.println(reader);
while (scanner.hasNext()) {
responseContent.append(scanner.nextLine());
// System.out.println(responseContent);
scanner.close();
//Temperature
double temperatureKelvin =
jsonObject.getAsJsonObject("main").get("temp").getAsDouble();
//Humidity
//Wind Speed
43
double windSpeed = jsonObject.getAsJsonObject("wind").get("speed").getAsDouble();
//Weather Condition
String weatherCondition =
jsonObject.getAsJsonArray("weather").get(0).getAsJsonObject().get("main").getAsString();
// Set the data as request attributes (for sending to the jsp page)
request.setAttribute("date", date);
request.setAttribute("city", city);
request.setAttribute("temperature", temperatureCelsius);
request.setAttribute("weatherCondition", weatherCondition);
request.setAttribute("humidity", humidity);
request.setAttribute("windSpeed", windSpeed);
request.setAttribute("weatherData", responseContent.toString());
connection.disconnect();
} catch (IOException e) {
e.printStackTrace();
request.getRequestDispatcher("index.jsp").forward(request, response);
44
ABOUT THE PROJECT
Introduction
The weather forecasting website is designed to provide users with real-time weather
information, including current conditions, forecasts, and severe weather alerts. The website
aims to serve a wide audience, such as travelers, outdoor enthusiasts, and anyone interested in
staying updated on weather changes. The website leverages technologies like HTML, CSS,
JavaScript, and integrates an API (e.g., OpenWeatherMap) to fetch weather data.
Key Features
The website offers several key features, including current weather updates (temperature,
humidity, wind speed), short-term and long-term weather forecasts, and a location search
function. Users can toggle between Celsius and Fahrenheit, ensuring accessibility to a
broader audience. Additionally, the website provides weather alerts for severe conditions,
helping users stay prepared.
API Integration
The weather data is fetched from a third-party weather API, such as OpenWeatherMap. The
API provides accurate and timely data on current weather and forecasts. Integration with the
API is handled via AJAX calls, ensuring the website can display real-time information with
minimal delay.
User Interface and Design
The website features a simple, user-friendly interface, designed to provide a smooth user
experience. It is responsive, ensuring that it works seamlessly on various devices, including
desktops, tablets, and smartphones. The design focuses on clear and easy-to-read weather
information, with an intuitive layout for quick navigation.
Testing and Quality Assurance
45
The website undergoes thorough testing to ensure it functions across different browsers and
devices. Performance testing is also carried out to maintain a fast loading time and ensure the
site is responsive even under heavy traffic. The error handling process ensures users are notified if
there are any issues with fetching data.
Future Enhancements
In the future, the website could be expanded with additional features, such as radar maps,
real-time weather alerts via push notifications, or even a mobile app version. User
personalization options, such as saving preferred locations or switching between different
weather themes, could also be added to improve the user experience.
This version covers the core aspects of the project while keeping it concise and clear.
CONCLUSION
This summer training has provided me with valuable insights and hands-on experience in
various Java concepts and web development. Throughout the training, I learned essential Java
programming techniques, including object-oriented programming (OOP), data structures,
algorithms, and exception handling, all of which were crucial in understanding the
fundamentals of coding and software development. The training also gave me an opportunity
to apply these concepts through practical coding exercises, which enhanced my problem-
solving skills and deepened my understanding of Java.
The mini project of developing a weather forecasting webpage allowed me to integrate my
Java knowledge with web development technologies. By creating a functional and interactive
weather forecasting website, I not only honed my skills in HTML, CSS, and JavaScript but
also learned how to work with APIs to fetch real-time weather data. This project has
significantly improved my understanding of full-stack development and how backend logic
can interact with the frontend for dynamic content delivery.
This training has equipped me with a solid foundation in both Java and web development.
The combination of theoretical learning and practical implementation has boosted my
confidence in taking on more complex programming challenges in the future. I am now better
prepared for advanced learning and real-world applications in software and web
development.
REFERENCES
Java Programming:
• "Head First Java" by Kathy Sierra and Bert Bates. O'Reilly Media, 2nd Edition, 2005.
46
• "Java: The Complete Reference" by Herbert Schildt. McGraw-Hill Education, 11th Edition,
2018.
• "HTML and CSS: Design and Build Websites" by Jon Duckett. Wiley, 2011.
• "JavaScript and JQuery: Interactive Front-End Web Development" by Jon Duckett. Wiley,
2014.
• "APIs: A Strategy Guide" by Daniel Jacobson, Greg Brail, and Dan Woods. O'Reilly Media,
2011.
Project Development:
• "Responsive Web Design with HTML5 and CSS3" by Ben Frain. Packt Publishing, 3rd Edition,
2015.
• "The Pragmatic Programmer: Your Journey to Mastery" by Andrew Hunt and David Thomas.
Addison-Wesley, 20th Anniversary Edition, 2019.
47