Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Industrial Training Report (Abhishek Ray) 901

Download as pdf or txt
Download as pdf or txt
You are on page 1of 33

INDUSTRIL TRAINING REPORT

ON
CORE JAVA

UNDERTAKEN
Central Tool Room & Training Centre , Bhubanswar

Submitted in partial fulfillment of the requirements for the award of Degree of


BACHELOR OF TECHNOLOGY
In
Computer Science & Engineering

Submitted by: Submitted to:


Abhishek Ray Dr. B.D.K. Patro (Head of Department)

(1783910901) Dr. Vivek Srivastava (Assistant Professor)

Department of Computer Science & Engineering


Rajkiya Engineering College , Kannauj
ACKNOWLEDGEMENT

I am grateful to Central Tool Room & Training Centre , Bhubanswar for giving me

opportunity to Industrial Training & Advanced Software Training. I would like to also thank

my institute, Rajkiya Engineering College , Kannauj for giving permission and necessary

administrative support to take up the training work at Central Tool Room & Training Centre ,

Bhubanswar .

Deepest thanks to our Trainer Mrs. Niharika Pattnaik (Senior Trainer) for his guidance,

monitoring, constant encouragement and correcting various assignments of ours with attention

and care. He has taken pain to go through the project and training sessions and make necessary

corrections as when needed and we are very grateful for that.

Abhishek Ray
1783910901
CONTENT
1. Acknowledgement
2. Certificate
3. Introduction
4. Application
5. History of Java
6. Features of Java
7. Java virtual Machine Architecture
8. Java Variable
9. Data Types in Java
10. Oprators in Java
11. Loops in Java
12. Java Object Oriented
13. multithreading in Java
14. Java I/O
15. Java Read Class
16. Java Write Class
17. Java Buffered Write Class
18. Java Swing
19. Java JDBC
20. Conclusions
Introduction
What is Java

Java is a programming language and a platform. Java is a high level, robust, object-


oriented and secure programming language.

java is a general purpose programming language that is class-based, object-oriented, and


designed to have as few implementation dependencies as possible. It is intended to
let application developers write once, run anywhere (WORA), meaning that compiled Java
code can run on all platforms that support Java without the need for recompilation Java
applications are typically compiled to bytecode that can run on any Java virtual
machine (JVM) regardless of the underlying computer architecture. The syntax of Java is
similar to C and C++, but it has fewer low-level facilities than either of them. As of 2019,
Java was one of the most popular programming languages in use according to GitHub,
particularly for client-server ) and released in 1995 as a core component of Sun
Microsystems' Java platform. The original and reference implementation Java compilers,
virtual machines, and class libraries were originally released by Sun under proprietary
licenses. As of May 2007, in com web applications, with a reported 9 million developers.

Java was originally developed by James Gosling at Sun Microsystems (which has since been
acquired by Oracle with the specifications of the Java Community Process, Sun
had relicensed most of its Java technologies under the GNU General Public License.
Meanwhile, others have developed alternative implementations of these Sun technologies,
such as the GNU Compiler for Java (bytecode compiler), GNU Class path (standard
libraries), and Iced Tea-Web (browser plugin for applets).

Application

According to Sun, 3 billion devices run Java. There are many devices where Java is currently
used. Some of them are as follows:

1. Desktop Applications such as acrobat reader, media player, antivirus, etc.


2. Web Applications such as irctc.co.in, javatpoint.com, etc.
3. Enterprise Applications such as banking applications.
4. Mobile
5. Embedded System
6. Smart Card
7. Robotics
8. Games, etc.

Java Micro Edition (Java ME)


Java Platform, Micro Edition or Java ME is a computing platform for development and
deployment of portable code for embedded and mobile devices (micro-controllers, sensors,
gateways, mobile phones, personal digital assistants, TV set-top boxes, printers). Java ME
was formerly known as Java 2 Platform, Micro Edition or J2ME.
Java Standard Edition (Java SE)
Java Platform, Standard Edition (Java SE) is a computing platform for development and
deployment of portable code for desktop and server environments. Java SE was formerly
known as Java 2 Platform, Standard Edition (J2SE).

Java Enterprise Edition (Java EE)


Java Enterprise Edition (Java EE), formerly Java 2 Platform, Enterprise Edition (J2EE),
currently rebranded as Jakarta EE, is a set of specifications, extending Java SE 8[1] with
specifications for enterprise features such as distributed computing and web services.[2] Java
EE applications are run on reference runtimes, that can be micro services or application
servers, which handle transactions, security, scalability, concurrency and management of the
components it is deploying.
Java EE is defined by its specification. The specification defines APIs (application
programming interface) and their interactions. As with other Java Community
Process specifications, providers must meet certain conformance requirements in order to
declare their products as Java EE compliant.
Examples of contexts in which Java EE referencing runtimes are used are: e-commerce,
accounting, banking information systems.
History of Java

 Java was originally designed for interactive television, but it was too advanced technology
for the digital cable television industry at the time. The history of java starts with Green
Team. Java team members (also known as Green Team), initiated this project to develop a
language for digital devices such as set-top boxes, televisions, etc. However, it was suited for
internet programming. Later, Java technology was incorporated by Netscape.

The principles for creating Java programming were "Simple, Robust, Portable, Platform-
independent, Secured, High Performance, Multithreaded, Architecture Neutral, Object-
Oriented, Interpreted and Dynamic".

Currently, Java is used in internet programming, mobile devices, games, e-business solutions,
etc. There are given the significant points that describe the history of Java.

1) James Gosling, Mike Sheridan, and Patrick Naughton initiated the Java language


project in June 1991. The small team of sun engineers called Green Team.

2) Originally designed for small, embedded systems in electronic appliances like set-top
boxes.

3) Firstly, it was called "Green talk" by James Gosling, and file extension was .gt.

4) After that, it was called Oak and was developed as a part of the Green project.

Why Java named "Oak"?

5) Why Oak? Oak is a symbol of strength and chosen as a national tree of many countries
like U.S.A., France, Germany, Romania, etc.
6) In 1995, Oak was renamed as "Java" because it was already a trademark by Oak
Technologies.

Why Java Programming named "Java"?

7) Why had they chosen java name for java language? The team gathered to choose a new
name. The suggested words were "dynamic", "revolutionary", "Silk", "jolt", "DNA", etc.
They wanted something that reflected the essence of the technology: revolutionary, dynamic,
lively, cool, unique, and easy to spell and fun to say.

According to James Gosling, "Java was one of the top choices along with Silk". Since Java
was so unique, most of the team members preferred Java than other names.

8) Java is an island of Indonesia where first coffee was produced (called java coffee).

9) Notice that Java is just a name, not an acronym.

10) Initially developed by James Gosling at Sun Microsystems (which is now a subsidiary of


Oracle Corporation) and released in 1995.

11) In 1995, Time magazine called Java one of the Ten Best Products of 1995.

12) JDK 1.0 released in (January 23, 1996).

Java Version History

Many java versions have been released till now. The current stable release of Java is Java SE
10.

1. JDK Alpha and Beta (1995)


2. JDK 1.0 (23rd Jan 1996)
3. JDK 1.1 (19th Feb 1997)
4. J2SE 1.2 (8th Dec 1998)
5. J2SE 1.3 (8th May 2000)
6. J2SE 1.4 (6th Feb 2002)
7. J2SE 5.0 (30th Sep 2004)
8. Java SE 6 (11th Dec 2006)
9. Java SE 7 (28th July 2011)
10. Java SE 8 (18th March 2014)
11. Java SE 9 (21st Sep 2017)
12. Java SE 10 (20th March 2018)

.
The traditional Hello world program can be written in Java as:
public class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World!"); // Prints the string to the console.
}
}

Features of Java

The primary objective of Java programming language creation was to make it portable,


simple and secure programming language. Apart from this, there are also some excellent
features which play an important role in the popularity of this language. The features of Java
are also known as java buzzwords.

A list of most important features of Java language is given below.

1. Simple
2. Object-Oriented
3. Portable
4. Platform independent
5. Secured
6. Robust
7. Architecture neutral
8. Interpreted
9. High Performance
10. Multithreaded
11. Distributed
12. Dynamic

Simple

Java is very easy to learn, and its syntax is simple, clean and easy to understand. According to
Sun, Java language is a simple programming language because:

o Java syntax is based on C++ (so easier for programmers to learn it after C++).
o Java has removed many complicated and rarely-used features, for example, explicit
pointers, operator overloading, etc.
o There is no need to remove unreferenced objects because there is an Automatic
Garbage Collection in Java.
Object-oriented

Java is an object-oriented programming language. Everything in Java is an object. Object-


oriented means we organize our software as a combination of different types of objects that
incorporates both data and behavior.

Object-oriented programming (OOPs) is a methodology that simplifies software development


and maintenance by providing some rules.

Basic concepts of OOPs are:

1. Object
2. Class
3. Inheritance
4. Polymorphism
5. Abstraction
6. Encapsulation

Platform Independent

Java is platform independent because it is different from other languages like C, C++, etc.
which are compiled into platform specific machines while Java is a write once, run anywhere
language. A platform is the hardware or software environment in which a program runs.

There are two types of platforms software-based and hardware-based. Java provides a
software-based platform.

The Java platform differs from most other platforms in the sense that it is a software-based
platform that runs on the top of other hardware-based platforms. It has two components:

1. Runtime Environment
2. API(Application Programming Interface)

Java code can be run on multiple platforms, for example, Windows, Linux, Sun Solaris, Mac/
OS, etc. Java code is compiled by the compiler and converted into bytecode. This bytecode is
a platform-independent code because it can be run on multiple platforms, i.e., Write Once and
Run Anywhere(WORA).

Secured

Java is best known for its security. With Java, we can develop virus-free systems. Java is
secured because:

o Class loader: Class loader in Java is a part of the Java Runtime Environment (JRE)
which is used to load Java classes into the Java Virtual Machine dynamically. It adds
security by separating the package for the classes of the local file system from those
that are imported from network sources.
o Bytecode Verifier: It checks the code fragments for illegal code that can violate
access right to objects.
o Security Manager: It determines what resources a class can access such as reading
and writing to the local disk.

Java language provides these securities by default. Some security can also be provided by an
application developer explicitly through SSL, JAAS, Cryptography, etc.

Robust

Robust simply means strong. Java is robust because:

o It uses strong memory management.


o There is a lack of pointers that avoids security problems.
o There is automatic garbage collection in java which runs on the Java Virtual Machine
to get rid of objects which are not being used by a Java application anymore.
o There are exception handling and the type checking mechanism in Java. All these
points make Java robust.

Architecture-neutral

Java is architecture neutral because there are no implementation dependent features, for
example, the size of primitive types is fixed.

In C programming, int data type occupies 2 bytes of memory for 32-bit architecture and 4
bytes of memory for 64-bit architecture. However, it occupies 4 bytes of memory for both 32
and 64-bit architectures in Java.

Portable

Java is portable because it facilitates you to carry the Java bytecode to any platform. It doesn't
require any implementation.

High-performance

Java is faster than other traditional interpreted programming languages because Java
bytecode is "close" to native code. It is still a little bit slower than a compiled language (e.g.,
C++). Java is an interpreted language that is why it is slower than compiled languages, e.g.,
C, C++, etc.
Comparison Index C++ Java

Platform- C++ is platform- Java is platform-independent.


independent dependent.

Mainly used for C++ is mainly used for Java is mainly used for application programming. It is widely
system programming. used in window, web-based, enterprise and mobile
applications.

Design Goal C++ was designed for Java was designed and created as an interpreter for printing
systems and systems but later extended as a support network computing. It
applications was designed with a goal of being easy to use and accessible
programming. It was to a broader audience.
an extension of C
programming
language.

Goto C++ supports the go Java doesn't support the goto statement.
to statement.

Multiple C++ supports multiple Java doesn't support multiple inheritance through class. It can
inheritance inheritance. be achieved by interfaces in java.

Operator C++ supports operator Java doesn't support operator overloading.


Overloading overloading.

Pointers C++ supports pointers. Java supports pointer internally. However, you can't write the
You can write pointer pointer program in java. It means java has restricted pointer
program in C++. support in java.

Compiler and C++ uses compiler Java uses compiler and interpreter both. Java source code is
Interpreter only. C++ is compiled converted into bytecode at compilation time. The interpreter
and run using the executes this bytecode at runtime and produces output. Java is
compiler which interpreted that is why it is platform independent.
converts source code
into machine code so,
C++ is platform
dependent.

Call by Value and C++ supports both call Java supports call by value only. There is no call by reference
Call by reference by value and call by in java.
reference.

Structure and C++ supports Java doesn't support structures and unions.
Union structures and unions.

Thread Support C++ doesn't have Java has built-in thread support.


built-in support for
threads. It relies on
third-party libraries for
thread support.

Documentation C++ doesn't support Java supports documentation comment (/** ... */) to create
comment documentation documentation for java source code.
comment.

Virtual Keyword C++ supports virtual Java has no virtual keyword. We can override all non-static
keyword so that we methods by default. In other words, non-static methods are
can decide whether or virtual by default.
not override a
function.

unsigned right C++ doesn't support Java supports unsigned right shift >>> operator that fills zero
shift >>> >>> operator. at the top for the negative numbers. For positive numbers, it
works same like >> operator.

Inheritance Tree C++ creates a new Java uses a single inheritance tree always because all classes
inheritance tree are the child of Object class in java. The object class is the
always. root of the inheritance tree in java.

Hardware C++ is nearer to Java is not so interactive with hardware.


hardware.

Object-oriented C++ is an object- Java is also an object-oriented language. However, everything


oriented language. (except fundamental types) is an object in Java. It is a single
However, in C root hierarchy as everything gets derived from
language, single root java.lang.Object.
hierarchy is not
possible.

Distributed

Java is distributed because it facilitates users to create distributed applications in Java. RMI
and EJB are used for creating distributed applications. This feature of Java makes us able to
access files by calling the methods from any machine on the internet.

Multi-threaded

A thread is like a separate program, executing concurrently. We can write Java programs that
deal with many tasks at once by defining multiple threads. The main advantage of multi-
threading is that it doesn't occupy memory for each thread. It shares a common memory area.
Threads are important for multi-media, Web applications, etc.

Dynamic

Java is a dynamic language. It supports dynamic loading of classes. It means classes are
loaded on demand. It also supports functions from its native languages, i.e., C and C++.

Java supports dynamic compilation and automatic memory management (garbage collection).

C++ vs Java

There are many differences and similarities between the C++ programming language


and Java. A list of top differences between C++ and Java are given below:

JVM (Java Virtual Machine) Architecture


1. Java Virtual Machine
2. Internal Architecture of JVM

JVM (Java Virtual Machine) is an abstract machine. It is a specification that provides runtime
environment in which java bytecode can be executed.

JVMs are available for many hardware and software platforms (i.e. JVM is platform
dependent).
What is JVM

1. A specification where working of Java Virtual Machine is specified. But


implementation provider is independent to choose the algorithm. Its implementation
has been provided by Oracle and other companies.
2. An implementation Its implementation is known as JRE (Java Runtime Environment).
3. Runtime Instance Whenever you write java command on the command prompt to run
the java class, an instance of JVM is created.

Java Variables

A variable is a container which holds the value while the java program is executed. A
variable is assigned with a datatype.

Variable is a name of memory location. There are three types of variables in java: local,
instance and static.

There are two types of data types in java: primitive and non-primitive.

Variable

Variable is name of reserved area allocated in memory. In other words, it is a name of


memory location. It is a combination of "vary + able" that means its value can be changed.

1. int data=50;//Here data is variable  

Types of Variables

There are three types of variables in java:

o local variable
o instance variable
o static variable

1) Local Variable

A variable declared inside the body of the method is called local variable. You can use this
variable only within that method and the other methods in the class aren't even aware that the
variable exists.

A local variable cannot be defined with "static" keyword.


2) Instance Variable

A variable declared inside the class but outside the body of the method, is called instance
variable. It is not declared as static.

It is called instance variable because its value is instance specific and is not shared among
instances.

3) Static variable

A variable which is declared as static is called static variable. It cannot be local. You can
create a single copy of static variable and share among all the instances of the class. Memory
allocation for static variable happens only once when the class is loaded in the memory.

Example to understand the types of variables in java

class A{  
int data=50;//instance variable  
static int m=100;//static variable  
void method(){  
int n=90;//local variable  
}  
}//end of class  
Data Types in Java

Data types specify the different sizes and values that can be stored in the variable. There are
two types of data types in Java:

1. Primitive data types: The primitive data types include boolean, char, byte, short, int,
long, float and double.
2. Non-primitive data types: The non-primitive data types include Classes, Interfaces,
and Arrays.

Java Primitive Data Types

In Java language, primitive data types are the building blocks of data manipulation. These are
the most basic data types available in Java language.

There are 8 types of primitive data types:

o boolean data type


o byte data type
o char data type
o short data type
o int data type
o long data type
o float data type
o double data type

Data Default Default size


Type Value

boolea false 1 bit


n

char '\u0000' 2 byte

byte 0 1 byte

short 0 2 byte

int 0 4 byte

long 0L 8 byte

float 0.0f 4 byte

double 0.0d 8 byte

Operators in java

Operator in java is a symbol that is used to perform operations. For example: +, -, *, / etc.

There are many types of operators in java which are given below:

o Unary Operator,
o Arithmetic Operator,
o Shift Operator,
o Relational Operator,
o Bitwise Operator,
o Logical Operator,
o Ternary Operator and
o Assignment Operator.
Operator Precedence

Operator Category Precedence


Type

Unary postfix expr++ expr--

prefix ++expr --expr +expr -expr ~ !

Arithmetic multiplicative */%

additive +-

Shift shift << >> >>>

Relational comparison < > <= >= instanceof

equality == !=

Bitwise bitwise AND &

bitwise ^
exclusive OR

bitwise |
inclusive OR

Logical logical AND &&

logical OR ||

Ternary ternary ?:

Assignment assignment = += -= *= /= %= &= ^= |= <<=


>>= >>>=
Loops in Java

In programming languages, loops are used to execute a set of instructions/functions


repeatedly when some conditions become true. There are three types of loops in java.

o for loop
o while loop
o do-while loop

OOPs (Object-Oriented Programming System)

Object means a real-world entity such as a pen, chair, table, computer, watch, etc. Object-
Oriented Programming is a methodology or paradigm to design a program using classes
and objects. It simplifies software development and maintenance by providing some
concepts:

o Object
o Class
o Inheritance
o Polymorphism
o Abstraction
o Encapsulation

Object

Any entity that has state and behavior is known as an object. For example, a chair, pen, table,
keyboard, bike, etc. It can be physical or logical.

An Object can be defined as an instance of a class. An object contains an address and takes
up some space in memory. Objects can communicate without knowing the details of each
other's data or code. The only necessary thing is the type of message accepted and the type of
response returned by the objects.

Example: A dog is an object because it has states like color, name, breed, etc. as well as
behaviors like wagging the tail, barking, eating, etc.

Class

Collection of objects is called class. It is a logical entity.

A class can also be defined as a blueprint from which you can create an individual object.
Class doesn't consume any space.
Inheritance

When one object acquires all the properties and behaviors of a parent object, it is known as
inheritance. It provides code reusability. It is used to achieve runtime polymorphism.

Polymorphism

If one task is performed in different ways, it is known as polymorphism. For example: to


convince the customer differently, to draw something, for example, shape, triangle, rectangle,
etc.

In Java, we use method overloading and method overriding to achieve polymorphism.

Another example can be to speak something; for example, a cat speaks meow, dog barks
woof, etc.

Abstraction

Hiding internal details and showing functionality is known as abstraction. For example phone
call, we don't know the internal processing.

In Java, we use abstract class and interface to achieve abstraction.

Encapsulation

Binding (or wrapping) code and data together into a single unit are known as encapsulation.
For example, a capsule, it is wrapped with different medicines.

A java class is the example of encapsulation. Java bean is the fully encapsulated class
because all the data members are private here.

Class

o It should start with the uppercase letter.


o It should be a noun such as Color, Button, System, Thread, etc.
o Use appropriate words, instead of acronyms.
o Example: -

public class Employee  
{  
//code snippet  
}  
Interface

o It should start with the uppercase letter.


o It should be an adjective such as Runnable, Remote, ActionListener.
o Use appropriate words, instead of acronyms.
Example: -

interface Printable  
{  
//code snippet  
}  

Method

o It should start with lowercase letter.


o It should be a verb such as main(), print(), println().
o If the name contains multiple words, start it with a lowercase letter followed by an
uppercase letter such as action Performed().
Example:-

 class Employee  
{  
//method  
void draw()  
{  
//code snippet  
}  
}  
Variable
o It should start with a lowercase letter such as id, name.
o It should not start with the special characters like & (ampersand), $ (dollar), _
(underscore).
o If the name contains multiple words, start it with the lowercase letter followed by an
uppercase letter such as first Name, last Name.
o Avoid using one-character variables such as x, y, z.
Example :-

  class Employee  
{  
//variable  
int id;  
//code snippet  
}  
Package

o It should be a lowercase letter such as java, lang.


o If the name contains multiple words, it should be separated by dots (.) such as
java.util, java.lang.
Example :-

package com.javatpoint; //package  
class Employee  
{  
//code snippet  
}  

Constant

o It should be in uppercase letters such as RED, YELLOW.


o If the name contains multiple words, it should be separated by an underscore(_) such
as MAX_PRIORITY.
o It may contain digits but not as the first letter.
Example :-

class Employee  
{  
//constant  
 static final int MIN_AGE = 18;  
//code snippet  
}  

Multithreading in Java
1. Multithreading
2. Multitasking
3. Process-based multitasking
4. Thread-based multitasking
5. What is Thread

Multithreading in java is a process of executing multiple threads simultaneously.

A thread is a lightweight sub-process, the smallest unit of processing. Multiprocessing and


multithreading, both are used to achieve multitasking.

However, we use multithreading than multiprocessing because threads use a shared memory
area. They don't allocate separate memory area so saves memory, and context-switching
between the threads takes less time than process.
Java Multithreading is mostly used in games, animation, etc.

Advantages of Java Multithreading

1) It doesn't block the user because threads are independent and you can perform multiple
operations at the same time.

2) You can perform many operations together, so it saves time.

3) Threads are independent, so it doesn't affect other threads if an exception occurs in a


single thread.

Multitasking

Multitasking is a process of executing multiple tasks simultaneously. We use multitasking to


utilize the CPU. Multitasking can be achieved in two ways:

o Process-based Multitasking (Multiprocessing)


o Thread-based Multitasking (Multithreading)

1) Process-based Multitasking (Multiprocessing)

o Each process has an address in memory. In other words, each process allocates a
separate memory area.
o A process is heavyweight.
o Cost of communication between the process is high.
o Switching from one process to another requires some time for saving and loading
registers, memory maps, updating lists, etc.

2) Thread-based Multitasking (Multithreading)

o Threads share the same address space.


o A thread is lightweight.
o Cost of communication between the thread is low.

What is Thread in java

A thread is a lightweight sub process, the smallest unit of processing. It is a separate path of
execution.

Threads are independent. If there occurs exception in one thread, it doesn't affect other
threads. It uses a shared memory area.
As shown in the above figure, a thread is executed inside the process. There is context-
switching between the threads. There can be multiple processes inside the OS, and one
process can have multiple threads.

Java Thread class

Java provides Thread class to achieve thread programming. Thread class provides


constructors and methods to create and perform operations on a thread. Thread class extends
Object class and implements Runnable interface.

Java I/O Tutorial

Java I/O (Input and Output) is used to process the input and produce the output.

Java uses the concept of a stream to make I/O operation fast. The java.io package contains all
the classes required for input and output operations.

We can perform file handling in Java by Java I/O API.

Stream

A stream is a sequence of data. In Java, a stream is composed of bytes. It's called a stream
because it is like a stream of water that continues to flow.

In Java, 3 streams are created for us automatically. All these streams are attached with the
console.

1) System.out: standard output stream

2) System.in: standard input stream

3) System.err: standard error stream

Let's see the code to print output and an error message to the console.

1. System.out.println("simple message");  
2. System.err.println("error message");  

Let's see the code to get input from console.

1. int i=System.in.read();//returns ASCII code of 1st character  
2. System.out.println((char)i);//will print the character  
Do You Know?
o How to write a common data to multiple files using a single stream only?
o How can we access multiple files by a single stream?
o How can we improve the performance of Input and Output operation?
o How many ways can we read data from the keyboard?
o What does the console class?
o How to compress and un compress the data of a file?

Output Stream vs Input Stream

The explanation of Output Stream and Input Stream classes are given below:

Output Stream

Java application uses an output stream to write data to a destination; it may be a file, an array,
peripheral device or socket.

Input Stream

Java application uses an input stream to read data from a source; it may be a file, an array,
peripheral device or socket.

Let's understand the working of Java Output Stream and Input Stream by the figure given
below.

Output Stream class

OutputStream class is an abstract class. It is the superclass of all classes representing an


output stream of bytes. An output stream accepts output bytes and sends them to some sink.

Useful methods of OutputStream

Method Description

1) public void write(int)throws IOException is used to write a byte to the current output
stream.
2) public void write(byte[])throws IOException is used to write an array of byte to the current
output stream.

3) public void flush()throws IOException flushes the current output stream.

4) public void close()throws IOException is used to close the current output stream.

Input Stream class

InputStream class is an abstract class. It is the superclass of all classes representing an input
stream of bytes.

Useful methods of InputStream

Method Description

1) public abstract int read()throws reads the next byte of data from the input stream.
IOException It returns -1 at the end of the file.

2) public int available()throws returns an estimate of the number of bytes that can be
IOException
read from the current input stream.

3) public void close()throws IOException is used to close the current input stream.

S.N. Modifier Method Description


and Type

1) void start() It is used to start the execution of the thread.


2) void run() It is used to do an action for a thread.

3) static sleep() It sleeps a thread for the specified amount of time.


void

4) static current It returns a reference to the currently executing thread object.


Thread Thread()

5) void join() It waits for a thread to die.

6) int get Priority() It returns the priority of the thread.

7) void set Priority() It changes the priority of the thread.

8) String get Name() It returns the name of the thread.

9) void set Name() It changes the name of the thread.

10) long get Id() It returns the id of the thread.

11) boolean is Alive() It tests if the thread is alive.

12) static yield() It causes the currently executing thread object to pause and
void allow other threads to execute temporarily.

13) void suspend() It is used to suspend the thread.

14) void resume() It is used to resume the suspended thread.

15) void stop() It is used to stop the thread.

16) void destroy() It is used to destroy the thread group and all of its subgroups.

17) boolean is Daemon() It tests if the thread is a daemon thread.

18) void set It marks the thread as daemon or user thread.


Daemon()

19) void interrupt() It interrupts the thread.

20) boolean is It tests whether the thread has been interrupted.


interrupted()

21) static interrupted() It tests whether the current thread has been interrupted.
boolean

22) static int active It returns the number of active threads in the current thread's
Count() thread group.

23) void check It determines if the currently running thread has permission
Access() to modify the thread.

24) static hold Lock() It returns true if and only if the current thread holds the
boolean monitor lock on the specified object.

25) static dump It is used to print a stack trace of the current thread to the
void Stack() standard error stream.

26) Stack get Stack It returns an array of stack trace elements representing the
Trace Trace() stack dump of the thread.
Element
[]

27) static int enumerate() It is used to copy every active thread's thread group and its
subgroup into the specified array.

28) Thread . get State() It is used to return the state of the thread.
State

29) Thread get Thread It is used to return the thread group to which this thread
Group Group() belongs
30) String to String() It is used to return a string representation of this thread,
including the thread's name, priority, and thread group.

31) void notify() It is used to give the notification for only one thread which is
waiting for a particular object.

32) void notify All() It is used to give the notification to all waiting threads of a
particular object.

33) void set Context It sets the context Class Loader for the Thread.
Class
Loader()

34) Class get Context It returns the context Class Loader for the thread.
Loader Class
Loader()

35) static get Default It returns the default handler invoked when a thread abruptly
Thread. Uncaught terminates due to an uncaught exception.
Un Exception
caught Handler()
Excepti
on
Handler

36) static set Default It sets the default handler invoked when a thread abruptly
void Uncaught terminates due to an uncaught exception.
Exception
Handler()

Java Writer

It is an abstract class for writing to character streams. The methods that a subclass must
implement are write(char[], int, int), flush(), and close(). Most subclasses will override some
of the methods defined here to provide higher efficiency, functionality or both.

import java.io.*;  
public class WriterExample {  
    public static void main(String[] args) {  
        try {  
            Writer w = new FileWriter("output.txt");  
            String content = "I love my country";  
            w.write(content);  
            w.close();  
            System.out.println("Done");  
        } catch (IOException e) {  
            e.printStackTrace();  
        }  
    }  
}  
Java Reader

Java Reader is an abstract class for reading character streams. The only methods that a


subclass must implement are read(char[], int, int) and close(). Most subclasses, however,
will override some of the methods to provide higher efficiency, additional functionality, or
both.

Some of the
implementation class are BufferedReader, CharArrayReader, FilterReader, InputStreamRead
er, PipedReader, StringReader

import java.io.*;  
public class ReaderExample {  
    public static void main(String[] args) {  
        try {  
            Reader reader = new FileReader("file.txt");  
            int data = reader.read();  
            while (data != -1) {  
                System.out.print((char) data);  
                data = reader.read();  
            }  
            reader.close();  
        } catch (Exception ex) {  
            System.out.println(ex.getMessage());  
        }  
    }  
}  
Java Buffered Writer Class

Java Buffered Writer class is used to provide buffering for Writer instances. It makes the
performance fast. It inherits Writer class. The buffering characters are used for providing the
efficient writing of single arrays, characters, and strings.

Java Swing

Java Swing tutorial is a part of Java Foundation Classes (JFC) that is used to create
window-based applications. It is built on the top of AWT (Abstract Windowing Toolkit) API
and entirely written in java.

Unlike AWT, Java Swing provides platform-independent and lightweight components.

The j avax. swing package provides classes for java swing API such as J Button, J Text Field,
J Text Area, J Radio Button, J Check box, J Menu, J Color Chooser etc.

Java JDBC

JDBC stands for Java Database Connectivity. JDBC is a Java API to connect and execute the
query with the database. It is a part of Java SE (Java Standard Edition). JDBC API uses
JDBC drivers to connect with the database. There are four types of JDBC drivers:

o JDBC-ODBC Bridge Driver,


o Native Driver,
o Network Protocol Driver, and
o Thin Driver

We have discussed the above four drivers in the next chapter.

We can use JDBC API to access tabular data stored in any relational database. By the help of
JDBC API, we can save, update, delete and fetch data from the database. It is like Open
Database Connectivity (ODBC) provided by Microsoft.

The current version of JDBC is 4.3. It is the stable release since 21st September, 2017. It is
based on the X/Open SQL Call Level Interface. The java. sql package contains classes and
interfaces for JDBC API.

A list of popular interfaces of JDBC API are given below:


o Driver interface
o Connection interface
o Statement interface
o Prepared Statement interface
o Callable Statement interface
o Result Set interface
o Result Set Meta Data interface
o Data base Meta Data interface
o Row Set interface
o Driver Manager class
o Blob class
o Clob class
o Types class

Why Should We Use JDBC

Before JDBC, ODBC API was the database API to connect and execute the query with the
database. But, ODBC API uses ODBC driver which is written in C language (i.e. platform
dependent and unsecured). That is why Java has defined its own API (JDBC API) that uses
JDBC drivers (written in Java language).
JDBC drivers
JDBC Driver is a software component that enables java application to interact with the
database.
There are 4 types of JDBC drivers
1. JDBC-ODBC bridge driver
2. Native-API driver
3. Network Protocol driver
4. Thin driver
CONCLUSIONS

Practical knowledge means the visualization of the knowledge, which we read in our books. For
this, we perform experiments and get observations. Practical knowledge is very important in every
field. One must be familiar with the problems related to that field so that he may solve them and
become a successful person.
After achieving the proper goal in life, an engineer has to enter in professional life.
According to this life, he has to serve an industry, may be public or private sector or self-own. For
the efficient work in the field, he must be well aware of the practical knowledge as well as
theoretical knowledge.

Due to all above reasons and to bridge the gap between theory and practical, our
Engineering curriculum provides a practical training of 4 Weeks. During this period
a student work in the industry and get well all type of experience and knowledge
about the working of companies and hardware and software tools.

I have undergone my 4 weeks summer training in at Central Tool Room & Training Centre
This report is based on the knowledge, which I acquired during my 4 weeks of summer
training.

You might also like