[go: up one dir, main page]

0% found this document useful (0 votes)
102 views41 pages

Training Report

Uploaded by

_Saqu
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)
102 views41 pages

Training Report

Uploaded by

_Saqu
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/ 41

INDUSTRIAL TRAINING REPORT

HOSPITAL MANAGEMENT SYSTEM

Submitted in partial fulfillment of the

Requirements for the award of

Degree of Bachelor of Technology in Computer Science & Engineering

Submitted By

Name: Affan Ahmad

University Roll No.: 1513210013

SUBMITTED TO:

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

GREATER NOIDA INSTITUTE OF ENGINEERING &


TECHNOLOGY, GREATER NOIDA

1
DECLARATION

I hereby declare that the Industrial Training Report entitled JAVA CORE is an authentic record
of my own work as requirements of Industrial Training during the period from 18TH June, 2018
to 28TH July for the award of degree of B.Tech. (Computer Science & Engineering),
GREATER NOIDA INSTITUTE OF ENGINEERING & TECHNOLOGY, GREATER
NOIDA

Date: Affan Ahmad

1513210013

2
ACKNOWLEDGEMENT

I am highly grateful to Mr. Rahul Chauhan for allowing me to do this project


work. It is truly a matter of great pleasure to express my sincere thanks and
gratitude to Mr. Rahul Chauhan for his supervision and encouragement
throughout this project. I am highly obliged to Incapp lab assistants for their
guidance, kind concern and encouragement throughout this project.

I am immensely indebted to Mr. Rahul Chauhan for the invaluable help that he
rendered at every step of this project. It is a wonderful experience to be a part of.
“Codules Technologies” Where we work under brilliant minds. We owe our deep
regards for the support and kind staff authorities who are helped me in my lean
patches during these months. The knowledge we are gaining throughout our studies
have the practical implementation during this period. We are grateful to all the staff
of “Codules Technologies”

3
ABOUT COMPANY

Codules Technologies Pvt Ltd is a Business Process Automation Company


focused on bridging the gap between business goals and actuals. The prime
motive of our organization is to provide high-quality software development
services to all of our clients.

4
Table of Contents

1) Introduction
2) History of Java
3) JVM & JRE
4) JDK
5) Features of Java
6) Object
7) Class
8) Object oriented programming
a) Inheritance
i) Single Inheritance
ii) Multiple Inheritance
iii) Hierarchical Inheritance
iv)Hybrid Inheritance
b) Encapsulation
c) Abstraction
d) Polymorphism
9) Java static and this keyword
10) Super and final keyword
11) Java method overloading
12) Java method overriding
13) Packages
14) Exception handling in Java
a) Types of Exception
b) Common Scenarios of Java Exceptions

5
15) Java try-catch block
16) Project
a) Introduction
b) Purpose
c) Scope
d) Background
e) User characteristics
f) Data Tables
g) Snapshots
17) Conclusion

6
List of Tables

1) Exception keywords
2) Desk login
3) Doctor login
4) Patient Information
5) Patient diagnosis

7
List of Figures

1) Object-oriented programming
2) Inheritance
3) Single Inheritance
4) Multiple Inheritance
5) Hierarchical Inheritance
6) Hybrid Inheritance
7) Encapsulation
8) Hierarchy of Java Exception classes
9) Types of Exceptions
10) Working of try-catch block
11) DFD
12) Project homepage
13) Desk login
14) Doctor login
15) Register new patients
16) View patients
17) View diagnostics
18)

8
INTRODUCTION

Java is one of the programming language or technology used for developing web applications.
Java language developed at SUN Micro Systems in the year 1995 under the guidance of James
Gosling and their team. Originally SUN Micro Systems is one of the Academic university
(Stanford University Network).
Whatever the software developed in the year 1990, SUN Micro Systems has released on the
name of oak, which is original name of java (scientifically oak is one of the tree name). The
OAK has taken 18 months to develop. The oak is unable to fulfill all requirements of the
industry. So, James Gosling again reviews this oak and released with the name of java in the
year 1995. Scientifically java is one of the coffee seed name.

Java is a platform-independent programming language used to create secure and robust


application that may run on a single computer or may be distributed among servers and clients
over a network.
Java features such as platform-independency and portability ensure that while developing
Java EE enterprise applications, you do not face the problems related to hardware, network, and
the operating system.

9
History of Java

Java was started as a project called "Oak" by James Gosling in June 1991. Gosling's goals
were to implement a virtual machine and a language that had a familiar C like notation but with
greater uniformity and simplicity than C/C++.
The First publication of Java 1.0 was released by Sun Microsystems in 1995. It made the
promise of "Write Once, Run Anywhere", with free runtimes on popular platforms.
In 2006-2007 Sun released java as open source and platform independent software.
Over time new enhanced versions of Java have been released. The current version of Java
is Java 1.7 which is also known as Java 7.

10
JVM & JRE

 The Java virtual machine (JVM) is a software implementation of a computer that executes
programs like a real machine.
 The Java virtual machine is written specifically for a specific operating system, e.g. for
Linux a special implementation is required as well as for Windows.
 Java programs are compiled by the Java compiler into bytecode. The Java virtual machine
interprets this bytecode and executes the Java program.
 The Java runtime environment (JRE) consists of the JVM and the Java class libraries and
contains the necessary functionality to start Java programs.
 The JDK contains in addition the development tools necessary to create Java programs. The
JDK consists therefore of a Java compiler, the Java virtual machine, and the Java class
libraries.

JDK

JDK (Java SE Development Kit) Includes a complete JRE (Java Runtime Environment) plus
tools for developing, debugging, and monitoring Java applications. JDK is required to build and
run Java applications and applets.

Features of Java? Characteristics of Java?

1) Simple
 Java is a simple language because of its various features, Java Doesn’t Support
Pointers, Operator Overloading etc. It doesn’t require unreferenced object because java
support automatic garbage collection.
 Java provides bug free system due to the strong memory management.

2) Object-Oriented
 Object-Oriented Programming Language (OOPs) is the methodology which provide
software development and maintenance by using object state, behavior, and properties.

Object Oriented Programming Language must have the following characteristics.


1)Encapsulation 2) Polymorphism 3) Inheritance 4) Abstraction

11
As the languages like Objective C, C++ fulfills the above four characteristics yet they are
not fully object-oriented languages because they are structured as well as object-oriented
languages.
In java everything is an Object. Java can be easily extended since it is based on the Object
model

3) Secure
 Java is Secure Language because of its many features it enables to develop virus-free,
tamper-free systems. Authentication techniques are based on public-key encryption.
Java does not support pointer explicitly for the memory.
 All Program Run under the sandbox.

4) Robust
 Java was created as a strongly typed language. Data type issues and problems are
resolved at compile-time, and implicit casts of a variable from one type to another are
not allowed.
 Memory management has been simplified java in two ways. First Java does not
support direct pointer manipulation or arithmetic. This make it possible for a java
program to overwrite memory or corrupt data.
 Second, Java uses runtime garbage collection instead of instead of freeing of memory.
In languages like C++, it Is necessary to delete or free memory once the program has
finished with it.

5) Platform-independent
 Java Language is platform-independent due to its hardware and software environment. Java
code can be run on multiple platforms e.g. windows, Linux, sun Solaris, Mac/OS etc. Java
code is compiled by the compiler and converted into byte code. This byte code is a platform
independent code because it can be run on multiple platforms i.e. Write Once and Run
Anywhere (WORA).
6) Architecture neutral
 It is not easy to write an application that can be used on Windows, UNIX and a Macintosh.
And it’s getting more complicated with the move of windows to non-Intel CPU
architectures.

12
 Java takes a different approach. Because the Java compiler creates byte code instructions
that are subsequently interpreted by the java interpreter, architecture neutrality is achieved
in the implementation of the java interpreter for each new architecture.

7) Portable
 Java code is portable. It was an important design goal of Java that it be portable so that as
new architectures (due to hardware, operating system, or both) are developed, the java
environment could be ported to them.
 In java, all primitive types (integers, longs, floats, doubles, and so on) are of defined sizes,
regardless of the machine or operating system on which the program is run. This is in direct
contrast to languages like C and C++ that leave the sized of primitive types up to the
compiler and developer.
Additionally, Java is portable because the compiler itself is written in Java.

8) Dynamic
 Because it is interpreted, Java is an extremely dynamic language, At runtime, the java
environment can extends itself by linking in classes that may be located on remote servers
on a network (for example, the internet)
 At runtime, the java interpreter performs name resolution while linking in the necessary
classes. The Java interpreter is also responsible for determining the placement of object in
memory. These two features of the Java interpreter solve the problem of changing the
definition of a class used by other classes.

9) Interpreted
 We all know that Java is an interpreted language as well. With an interpreted language such
as Java, programs run directly from the source code.
 The interpreter program reads the source code and translates it on the fly into computations.
Thus, Java as an interpreted language depends on an interpreter program.
 The versatility of being platform independent makes Java to outshine from other languages.
The source code to be written and distributed is platform independent.
 Another advantage of Java as an interpreted language is its error debugging quality. Due to
this any error occurring in the program gets traced. This is how it is different to work with
Java.

13
10) High performance
 For all but the simplest or most infrequently used applications, performance is always a
consideration for most applications, including graphics-intensive ones such as are
commonly found on the world wide web, the performance of java is more than adequate.

11) Multithreaded
 Writing a computer program that only does a single thing at a time is an artificial constraint
that we’ve lived with in most programming languages. With java, we no longer have to live
with this limitation. Support for multiple, synchronized threads is built directly into the Java
language and runtime environment.
 Synchronized threads are extremely useful in creating distributed, network-aware
applications. Such as application may be communicating with a remote server in one thread
while interacting with a user in a different thread.
12) Distributed.
 Java facilitates the building of distributed application by a collection of classes for use in
networked applications. By using java’s URL (Uniform Resource Locator) class, an
application can easily access a remote server. Classes also are provided for establishing
socket-level connections.

Java – Basic Program


When we consider a Java program it can be defined as a collection of objects that
communicate via invoking each other’s methods. Let us now briefly look into what do class,
object, methods and instance variables mean.
 Object - Objects have states and behaviors. Example: A dog has states-color, name,
breed as well as behaviors -wagging, barking, eating. An object is an instance of a class.
 Class - A class can be defined as a template/ blue print that describe the
behaviors/states that object of its type support.
 Methods - A method is basically a behavior. A class can contains many methods. It is
in methods where the logics are written, data is manipulated and all the actions are executed.
 Instance Variables - Each object has its unique set of instance variables. An object's
state is created by the values assigned to these instance variables

First Java Program:


Let us look at a simple code that would print the words Simple Test Program.
14
public class SimpleProgram {

public static void main(String []args) {


System.out.println("Simple Test Program");
}
}

What is Object?

In real-world an entity that has state and its behavior is known as an object.

For Example:

 A Car is an object. It has states (name, color, model) and its behavior (changing gear,
applying brakes).
 A Pen is an object. Its name is Parker; color is silver etc. known as its state. It is used to write,
so writing is its behavior.

In real-world object and software object have conceptually similar characteristics. In terms of
object-oriented programming, software objects also have a state and behavior.

What is class?
 A class is a template or blueprint that is used to create objects.
 Class representation of objects and the sets of operations that can be applied to such objects.
 A class consists of Data members and methods.

The primary purpose of a class is to hold data/information. This is achieved with attributes
which are also known as data members.

Object Oriented Programming


Object Oriented programming is a programming style which is associated with the concepts like
class, object, Inheritance, Encapsulation, Abstraction, Polymorphism. Most popular
programming languages like Java, C++, C#, Ruby, etc. follow an object-oriented programming
paradigm. I will talk about object-oriented programming concepts in Java. An object-based
application in Java is based on declaring classes, creating objects from them and interacting
between these objects.

We will understand the below core concepts of Object-oriented Programming in the following
sequence:
15
1. Inheritance
2. Encapsulation
3. Abstraction
4. Polymorphism

In OOP, computer programs are designed in such a way where everything is an object that
interact with one another. Inheritance is one such concept where the properties of one class can
be inherited by the other. It helps to reuse the code and establish a relationship between
different classes.

Fig-1
As we can see in the image, a child inherits the properties from his father. Similarly, in Java,
there are two classes:

1. Parent class (Super or Base class)

2. Child class (Subclass or Derived class)

A class which inherits the properties is known as Child Class whereas a class whose properties
are inherited is known as Parent class.

Inheritance is further classified into 4 types:

Fig-2
16
1.Sinlge Inheritance

In single inheritance, one class inherits the properties of another. It enables a derived class to
inherit the properties and behavior from a single parent class. This will in turn enable code
reusability as well as add new features to the existing code.

Here, Class A is your parent class and Class B is your child class which inherits the properties
and behavior of the parent class.

Fig-3

Let’s see the syntax for single inheritance:

Class A
{
---
}
Class B extends A {
---
}

2. Multiple Inheritance

When a class is derived from a class which is also derived from another class, i.e. a class having
more than one parent class but at different levels, such type of inheritance is called Multilevel
Inheritance.

If we talk about the flowchart, class B inherits the properties and behavior of class A and class C
inherits the properties of class B. Here A is the parent class for B and class B is the parent class

17
for C. So, in this case class C implicitly inherits the properties and methods of class A along with
Class B. That’s what is multilevel inheritance.

Fig-4

Let’s see the syntax for multilevel inheritance in Java:

Class A{
---
}
Class B extends A{
---
}
Class C extends B{
---
}

3. Hierarchical Inheritance

When a class has more than one child classes (sub classes) or in other words, more than one child
classes have the same parent class, then such kind of inheritance is known as hierarchical.

If we talk about the flowchart, Class B and C are the child classes which are inheriting from the
parent class i.e. Class A.

18
Fig-5

Let’s see the syntax for hierarchical inheritance in Java:

Class A{
---
}
Class B extends A{
---
}
Class C extends A{
---
}
4. Hybrid Inheritance

Hybrid inheritance is a combination of multiple inheritance and multilevel inheritance. Since


multiple inheritance is not supported in Java as it leads to ambiguity, so this type of inheritance
can only be achieved through the use of the interfaces.

If we talk about the flowchart, class A is a parent class for class B and C, whereas Class B and C
are the parent class of D which is the only child class of B and C.

Fig-6

2. Encapsulation
19
Encapsulation is a mechanism where you bind your data and code together as a single unit. It
also means to hide your data in order to make it safe from any modification. What does this
mean? The best way to understand encapsulation is to look at the example of a medical capsule,
where the drug is always safe inside the capsule. Similarly, through encapsulation the methods
and variables of a class are well hidden and safe.

Fig-7

3. Abstraction

Abstraction refers to the quality of dealing with ideas rather than events. It basically deals with
hiding the details and showing the essential things to the user. If you look at the image here,
whenever we get a call, we get an option to either pick it up or just reject it. But in reality, there
is a lot of code that runs in the background. So you don’t know the internal processing of how a
call is generated, that’s the beauty of abstraction. Therefore, abstraction helps to reduce
complexity. You can achieve abstraction in two ways:

a) Abstract Class

b) Interface

4. Polymorphism
Polymorphism means taking many forms, where ‘poly’ means many and ‘morph’ means forms.
It is the ability of a variable, function or object to take on multiple forms. In other words,
polymorphism allows you define one interface or method and have multiple implementations.

Java static and this keyword

There are various reserve words that Java provides to do different types of operations.
Keywords are reserved words whose meanings are already known to Java compiler. There are
two essential keywords in Java that are used for very special purposes

20
What is static keyword in Java?

Static is a keyword that acts as a non-access modifier in Java that is used mainly to manage
memory. The variable or Method that are marked static belongs to the Class rather than to any
particular instance. A Static method cannot access an instance variable. If a Class contains any
static blocks, then that block will be executed only when the Class is loaded in JVM.
Programmers can apply the Java keyword static with different programming objects like:

 variables
 methods
 initialization - block
 nested class

Static keyword is unacceptable to the following

 Class
 Constructor
 Local inner classes
 Inner class methods
 Instance variables
 Local variables
 Interfaces

Static variables or methods can be invoked without having an instance of the class. Only a class
is needed to call up a static method or a static variable. If you declare any variable as static, it is
known static variable. The static variable can refer to a common property of all objects (that is
not unique for each object), e.g. company name of employees, college name of students, etc.
Memory in a static variable is reserved only once in a class area at the time of class loading.
One advantage of using static is that it increases the efficiency of the memory.
Program for static in Java

public class egStatic {


static int x = 60;
static void fun() {
System.out.println("Within Static");
}
public static void main(String[] args) {
egStatic.fun();
System.out.println(egStatic.x);
egStatic S1 = new egStatic();
egStatic S2 = new egStatic();
System.out.println(S1.x);
S1.fun();
}
}

21
What is this keyword in Java?

this is another Java keyword which as a reference to the current object within an instance
method or a constructor — the object whose method or constructor is being called. By the use
of this keyword, programmers can refer to any member of the current object within an instance
method or a constructor. This keyword can be used to refer to the current object, and it always
acts as a reference to an object in which method was invoked. There are the various uses of this
keyword in Java. These are:

 For referring current class instance variable, this keyword can be used
 To invoke current class constructor, this() is used
 this can be passed as message argument in a method call
 In a constructor call, this can be passed as argument
 For returning current class instance, this keyword is used

Program for this in Java


class Emp {
int e_id;
String name;

Emp(int e_id, String name) {


this.e_id = e_id;
this.name = name;
}
void show() {
System.out.println(e_id + " " + name);
}
public static void main(String args[]) {
Emp e1 = new Emp(1006, "Karlos");
Emp e2 = new Emp(1008, "Ray");
e1.show();
e2.show();
}
}

What is super in Java?

Super is a keyword of Java which refers to the immediate parent of a class and is used inside
the subclass method definition for calling a method defined in the superclass. A superclass
having methods as private cannot be called. Only the methods which are public and protected

22
can be called by the keyword super. It is also used by class constructors to invoke constructors
of its parent class.

Syntax:

super.<method-name>();

Usage of super
 Super variables refer to the variable of a variable of the parent class.
 Super() invokes the constructor of immediate parent class.
 Super refers to the method of the parent class.

What is final in Java?


Final is a keyword in Java that is used to restrict the user and can be used in many respects.
Final can be used with:

 Class
 Methods
 Variables

Class declared as final

When a class is declared as final, it cannot be extended further. Here is an example what
happens within a program

Example:
final class stud {
// Methods cannot be extended to its sub class
}
class books extends stud {
void show() {
System.out.println("Book-Class method");
}
public static void main(String args[]) {
books B1 = new books();
B1.show();
}

This will show an error that:

error: cannot inherit from final stud

23
class books extends stud{

Java Method Overloading

If a class has multiple methods having same name but different in parameters, it is known
as Method Overloading.

If we have to perform only one operation, having same name of the methods increases the
readability of the program.

Suppose you have to perform addition of the given numbers but there can be any number of
arguments, if you write the method such as a(int,int) for two parameters, and b(int,int,int) for
three parameters then it may be difficult for you as well as other programmers to understand the
behavior of the method because its name differs.

So, we perform method overloading to figure out the program quickly.

Advantages of method overloading

Method overloading increases the readability of the program.

Different ways to overload the method

There are two ways to overload the method in java

1. By changing number of arguments


2. By changing the data type

Java Method Overriding

Declaring a method in the subclass which already exists there in the parent class is known as
method overriding. When a class is inheriting a method from a superclass of its own, then there
is an option of overriding the method provided it is not declared as final. The advantage of
using overriding is the ability to classify a behavior that's specific to the child class, and the
child class can implement a parent class method based on its necessity.

There are certain rules that a programmer should follow to implement overriding. These are:

24
 In Java, a method can only be written in the child class and not in same class.
 Argument list should be the same as that of the overridden method of that class.
 Instance methods can also be overridden if they are inherited by the child class.
 A constructor cannot be overridden.
 Final - declared methods cannot be overridden.
 Any method that is static cannot be used to override.
 The return type must have to be the same, or a subtype of the return type declared in the
original overridden method in the parent class.
 If a method cannot be inherited, then it cannot be overridden.
 A child class within the same package as the instance's parent class can override any parent
class method that is not declared private or final.
 A child class in a different package can only override the non-final methods declared as
public or protected.

Java Packages

It is repeatedly said that one of the main features of the Object Oriented Programming is the
ability to reuse the code already written by the programmer. One way of achieving is by
extending class and using the interface. It has a limitation. What will you have to do if you have
to use a class from another program without physically copying them into the program at the
time of development? So another way of achieving the concept of reusability in Java is via the
use of Packages.

What are packages?

Packages in Java are groups of similar types of classes, interface and sub packages. It is a way
of grouping a variety of classes or interfaces collectively. The grouping is usually done
according to functionality. The Java packages act as containers for Java classes.

Here's are the benefits of organizing classes:

1. The classes contained in the packages of another program can be easily reused.
2. Packages also allow programmers to separate design from coding.
3. In packages, classes can be declared uniquely compared with classes in other packages.

25
4. Java Packages provide a way to 'hide' classes thus preventing other programs or packages
from accessing classes that are meant for internal use only.
5. Packages provide access protection.
6. Java package removes naming collision.

For most applications, programmers need to use different sets of classes, one for the internal
representation of program's data and other for the external presentation purposes. You may
build your classes for handling your program data and use existing class libraries for designing
class libraries for designing the user interface.

Exception Handling in java

The Exception Handling in Java is one of the powerful mechanism to handle the runtime
errors so that normal flow of the application can be maintained.

What is Exception in Java?

Dictionary Meaning: Exception is an abnormal condition.

In Java, an exception is an event that disrupts the normal flow of the program. It is an object
which is thrown at runtime.

What is Exception Handling?

The core advantage of exception handling is to maintain the normal flow of the application.
An exception normally disrupts the normal flow of the application that is why we use exception
handling. Let's take a scenario:

1. statement 1;
2. statement 2;
3. statement 3;
4. statement 4;
5. statement 5;//exception occurs
6. statement 6;
7. statement 7;
8. statement 8;
9. statement 9;
10. statement 10;

Suppose there are 10 statements in your program and there occurs an exception at statement 5,
the rest of the code will not be executed i.e. statement 6 to 10 will not be executed. If we perform
exception handling, the rest of the statement will be executed. That is why we use exception
handling in Java.

Hierarchy of Java Exception classes


26
The java.lang.Throwable class is the root class of Java Exception hierarchy which is inherited
by two subclasses: Exception and Error. A hierarchy of Java Exception classes are given
below:

27
Fig-8

28
Types of Java Exceptions

There are mainly two types of exceptions: checked and unchecked. Here, an error is considered
as the unchecked exception. According to Oracle, there are three types of exceptions:

1. Checked Exception
2. Unchecked Exception
3. Error

Fig-9

Difference between Checked and Unchecked Exceptions

1. Checked Exception

The classes which directly inherit Throwable class except RuntimeException and Error are
known as checked exceptions e.g. IOException, SQLException etc. Checked exceptions are
checked at compile-time.

2. Unchecked Exception

The classes which inherit RuntimeException are known as unchecked exceptions e.g.
ArithmeticException, NullPointerException, ArrayIndexOutOfBoundsException etc.
Unchecked exceptions are not checked at compile-time, but they are checked at runtime.

3. Error

Error is irrecoverable e.g. OutOfMemoryError, VirtualMachineError, AssertionError etc.

29
Keyword Description

try The "try" keyword is used to specify a block where we should place exception code.
The try block must be followed by either catch or finally. It means, we can't use try
block alone.

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 important 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 doesn't throw an exception.
It specifies that there may occur an exception in the method. It is always used with
method signature.

Java Exception keywords

Tab-1

Java Exception Handling Example

Let's see an example of Java Exception Handling where we using a try-catch statement to
handle the exception.

1. public class JavaExceptionExample{


2. public static void main(String args[]){
3. try{
4. //code that may raise exception
5. int data=100/0;
6. }catch(ArithmeticException e){System.out.println(e);}
7. //rest code of the program
8. System.out.println("rest of the code...");
9. }
10. }

Common Scenarios of Java Exceptions

30
1) A scenario where ArithmeticException occurs

If we divide any number by zero, there occurs an ArithmeticException.

1. int a=50/0;//ArithmeticException

2) A scenario where NullPointerException occurs

If we have a null value in any variable, performing any operation on the variable throws a
NullPointerException.

1. String s=null;
2. System.out.println(s.length());//NullPointerException

3) A scenario where NumberFormatException occurs

The wrong formatting of any value may occur NumberFormatException. Suppose I have a string
variable that has characters, converting this variable into digit will occur
NumberFormatException.

1. String s="abc";
2. int i=Integer.parseInt(s);//NumberFormatException

4) A scenario where ArrayIndexOutOfBoundsException occurs

If you are inserting any value in the wrong index, it would result in
ArrayIndexOutOfBoundsException as shown below:

1. int a[]=new int[5];


2. a[10]=50; //ArrayIndexOutOfBoundsException

Java try-catch block

Java try block

Java try block is used to enclose the code that might throw an exception. It must be used within
the method.

Java try block must be followed by either catch or finally block.

Java catch block

Java catch block is used to handle the Exception. It must be used after the try block only.

31
You can use multiple catch block with a single try.

Fig-10

The JVM firstly checks whether the exception is handled or not. If exception is not handled, JVM
provides a default exception handler that performs the following tasks:

 Prints out exception description.


 Prints the stack trace (Hierarchy of methods where the exception occurred).
 Causes the program to terminate.

But if exception is handled by the application programmer, normal flow of the application is
maintained i.e. rest of the code is executed.

32
Project

Hospital Management System

Introduction

Purpose

 The Software is for the automation of Hospital Management.


 It maintains two levels of user: -
 Reception desk to register patients
 Doctor panel for prescription

 The Software includes: -


 Maintaining Patient details.
 Providing Prescription.

Scope
It can be used in any Hospital, Clinic, Dispensary or Pathology labs for maintaining patient
details.

33
Background

A Hospital is a place where Patients come up for general diseases. Hospitals provide facilities
like: -
 Consultation by Doctors on Diseases.
 Diagnosis for diseases.
 Providing treatment facility.
 Facility for admitting Patients (providing beds, nursing, medicines etc.)
 Immunization for Patients/Children.

Various operational works that are done in a Hospital are: -


 Recording information about the Patients that come.
 Recording information related to diagnosis given to Patients.
 Keeping record of the Immunization provided to children/patients.
 Keeping information about various diseases and medicines available to cure
them.

These are the various jobs that need to be done in a Hospital by the operational staff and
Doctors. All these works are done on papers.

The work is done as follows: -


 Information about Patients is done by just writing the Patients name, age and gender.
Whenever the Patient comes up his information is stored freshly.
 Diagnosis information to patients is generally recorded on the document, which
contains Patient information. It is destroyed after some time period to decrease the
paper load in the office.

All this work is done manually by the receptionist and other operational staff and lot of
papers are needed to be handled and taken care of.

34
User Characteristics

Every user should be:


 Comfortable of working with computer.
 He must have knowledge in medical field.
 He must also have basic knowledge of English.

Constraints
 GUI is only in English.
 Login and password are used for identification of user and there is no facility for guest.

Data Tables

1. Desk Login Table

Field Name Data Type Description


AID VARCHAR (2) USER ID
PASSWORD VARCHAR (2)
NAME VARCHAR (2) NAME OF USER
Tab-2
2. Doctor Login

Field Name Data Type Description


DOC_ID VARCHAR (2) Doctor ID
PASSWORD VARCHAR (2)
NAME VARCHAR (2) DOCTOR NAME
Tab-3

35
3. Patient Information Table

Field Name Data Type Description


PID NUMBER Patient ID
NAME VARCHAR (2)
AGE NUMBER
GENDER VARCHAR (2)
DATE DATE
BLOOD GROUP VARCHAR (2) Can be NULL
CONTACT VARCHAR (2)
ADDRESS VARCHAR (2)
CITY VARCHAR (2)
STATE VARCHAR (2)
Tab-4

5. Patient Diagnosis

Field Name Data Type Description


PID NUMBER Patient ID
DISEASE VARCHAR (2)
DIAGNOSIS VARCHAR (2) Prescription
Tab-5

36
DFD

Fig-11
PID: Patient Id allotted during Patient registration

37
Snapshots

1. Homepage

Fig-12

2. Desk Login

Fig-13

38
3. Doctor Login

Fig-14
4. Register New Patient

Fig-15

39
5. View Patients

Fig-16
6. View Diagnostics

Fig-17

40
Conclusion

The project Hospital Management System is for computerizing the working in a hospital. The
software takes care of all the requirements of an average hospital and is capable to provide easy
and effective storage of information related to patients that come up to the hospital, provide
prescription details.

41

You might also like