Arslanali Sip Roll No.15
Arslanali Sip Roll No.15
Arslanali Sip Roll No.15
(Session 2020-2024)
UTTARANCHAL UNIVERSITY
PREMNAGAR, DEHRADUN
UTTARAKHAND 248007
Submitted to Submitted by
Dr. RB Singh Arslan Ali
Assistant Professor Enroll no.- 20210101015
Acknowledgement
The completion of this training work could have been possible with continued & dedicated
efforts & guidance of large number of faculty & staff members of the institute I acknowledge
our gratitude to all of them. The acknowledgement however will be incomplete without
specific mention as follows:
I wish to acknowledge my deep gratitude to our trainer at Ensino Research and Development
Private Limited for his Cooperation and guidance. I am also thankful to director Mr. Ashok
Kumar that provided staunch support Throughout this training and helped me to complete
the training successfully
Furthermore I would also like to acknowledge with much appreciation the crucial role of our
HOD Dr. Sumit Chaudhary for this encouragement & providing all the facilities in the
department
Finally, I would like to say that I am indebted to my parents for everything that they have
done for me. All of this would have been impossible without their constant support.
Without their support and suggestions, this industrial training report would not have been
completed
Arslan Ali
Certificate
DECLARATION
Arslan Ali
2001010033
INDEX
1. Company Profile 6
2. Introduction to Java 7
3. Basics of Java 11
5. Installation of Java 12
6. Configuring Variables 14
9. Inheritance 18
14. IDE 26
16. Conclusion 33
Company profile
Ensino Research & Development is the place where students are mastering
new skills and achieving their goals by learning from an extensive list of
courses. Every course is designed to meet the specific industry requirement.
Content includes hardware as well as software. Hours of topic-wise
engaging tutorials covering all concepts with multiple problem solutions by
some of India’s best experts. Practical training always finds the better place
over classroom training but now we have implemented the classroom
training and practical training together. Hardware description with live
components creates the difference. Even students can ask for their doubts.
Complex concepts explained visually and contextually to help students
create a strong foundation.
INTRODUCTION TO JAVA
BASICS OF JAVA
Overview Of Java
Java is a platform independent, more powerful, secure, high performance, multithreaded
programming language. Here we discuss some points related to java.
Define JRE
The Java Runtime Environment (JRE) is part of the Java Development Kit (JDK). It contains
set of libraries and tools for developing java application. The Java Runtime Environment
provides the minimum requirements for executing a Java application.
Define JVM
JVM is set of programs developed by sun Micro System and supplied as a part of jdk for
reading line by line of byte code and it converts into native understanding form of operating
system. Java language is one of the compiled and interpreted programming language.
Garbage Collector
Garbage Collector is the system Java program which runs in the background along with
regular Java program to collect un-Referenced (unused) memory space for improving the
performance of our applications.
Define an API
An API (Application Programming Interface) is a collection of packages, a package is the
collection of classes, interfaces and sub-packages. A sub-package is a collection of classes
interfaces and sub sub packages etc. Java programming is containing user friendly syntax so
that we can develop effective application s. in other words if any language is providing user
friendly syntax, we can develop error free applications.
Definition of JIT
JIT is the set of programs developed by SUN Micro System and added as a part of JVM, to
speed up the interpretation phase
Features OF JAVA
Features of a language are nothing but the set of services or facilities provided by the
language vendors to the industry programmers. Some important features are,
Java Classpath Setting
Path Variable
Path variable is set for providing path for all java tools like java, javac, javap, javah, jar,
applet viewer which are use in java programming. These all tools are available in bin folders
so we set path up to bin folders.
Classpath Variable
Classpath variable is set for providing path for predefined java classes which is used in our
application. All classes are available in lib/rt.jar so we set classpath upto lib/rt.jar.
One thing that distinguished Java from some other languages is its ability to run the same
compiled code across multiple operating systems. In other languages, the source code (code
that is written by the programmer), is compiled by a compiler into an executable file. This file
is in machine language, and is intended for a single operating system/processor combination,
so the programmer would have to re-compile the program separately for each new operating
system processor combination. Java is different in that is does not compile the code directly
into machine language code. Compilation creates bytecode out of the source code. Bytecode
generally looks something like this:
a7 f3 5a 1b 92 7d
When the code is run by the user, it is processed by something called the Java Virtual
Machine (JVM). The JVM is essentially an interpreter for the bytecode. It goes through the
bytecode and nans it. There are different versions of the JVM that are compatible with each
OS and can run the same code. There is virtually no difference for the end-user, but this
makes à a lot easier for programmers doing software development.
Installation of Java
Check installation
Java might already be installed on your machine. You can test this by opening a
console (if you are using Windows: Win+R, enter cmd and press Enter) and by typing
in the following command:
Java -version
If Java is correctly installed, you should see some information about your Java
installation. If the command line returns the information that the program could not be
found, you have to install Java .
Note on Editions
o The JDK comes in three editions :
Java Standard Edition (JSE)This version is the basic platform for Java. The
course will focus on this edition.
Java Enterprise Edition (JEE) This edition is mainly for developing and
running distributed multitier architecture Java applications, based largely on
modular software components running on an application server. We will not be
covering this version in the course.
Java Micro Edition (JME) This edition is primarily for developing programs to
run on consumer appliances, such as PDAs and cell phones.
Configuring Variables
Before writing code, it is recommended that you set the Path variable on your
system so you can compile your code more easily.
From the Control Panel, double click System" (System and Maintenance in
Vista)
For XP and 2000, click on the "Advanced" tab and click on "Environment
Variables For NT. click on the "Environment" tab.
Add the path to the bin directory of where Java is installed on your hard drive.
It should probably be: C:Program Files Java/jdk1.6.0 20 bin unless you
changed during installation.
Click OK
One way to set your path in Linux/Unix is to add a path export to your bash
profile.
In order to do this, first open your bash profile in a text editor. For example,
pico-bash profile
export PATH-SPATH/usr/local/jdk/bin
Note that the path to the java directory "usr/local/jdk/bin" may be different on
your machine.
Restart your shell
For Macintosh
Validate installation
Switch again to the command line and run the following command.
Java -version
The output should be similar to the following output.
Java version “1.7.0 25”
OpenJDK Runtime Environment (Iced Tea 2.3.10) (7u25-2.3.10-1ubuntu0.13.04.2)
OpenJDK 64-Bè Server VM (build 23.7-b01, mixed mode)
Garbage collector
The JVM automatically re-collects the memory which is not referred to by other
objects. The java garbage collector checks all object references and find the objects
which can be automatically released.
While the garbage collector releases the programmer from the need to explicitly
manage memory the programmer still need to ensure that he does not keep unneeded
object references otherwise the garbage collector cannot release the associated
memory. Keeping unneeded object references are typically called memory leaks.
Write, compile and run a Java program
Write source code
The following Java program is developed under Linux using a test editor and the
command line. The process on other operating system should be similar and but is not
covered in this description.
Select or create a new directory which will be used for your Java development. In this
description the path \home\vogella\javastarter is used. On Microsoft Windows your
might want to use c:\temp\javastarter. This path is called javadir in the following
description. Open a text editor which supports plain text, e.g. gedit under Linux or
Notepad under windows and write the following source code .
Save the source code in your javadir directory with the HelloWorld.java filename. The name
of a Java source file must always equal the class name (within the source code) and end with
the .java extension. In this example the filename must be HelloWorld.java, because the class
is called HelloWorld.
first Java source code into bytecode. You can now start your compiled Java program. Ensure
that you are still in the jardir directory and enter the following command to start your Java
program. The system should write “Hello World” on the command line.
Class
Def : A class is a template that describes the data and behavior associated with an
instance of that class.
A class is defined by the class keyword and must start with a capital letter. The body
of a class is surrounded by {}.
package test;
class Myclass {}
The data associated with a class is stored in variables ; the behavior associated to a class or
object is implemented with methods. A class is contained in a text file with the same name as
the class plus the .java extension. It is also possible to define inner classes, these are classes
defined within another class, in this case you do not need a separate file for this class.
Object
Def : An object is an instance of a class.
The object is the real element which has data and can perform actions. Each object is created
based on the class definition. The class can be seen as the blueprint of an object, i.e., it
describes how an object is created.
Package
Def : Java groups classes into functional packages.
Packages are typically used to group classes into logical units. For example, all graphical
views of an application might be placed in the same package called
com.vogella.webapplication.views..
It is common practice to use the reverse domain name of the company as top level package.
For example, the company might own the domain, vogella.com and in this example the Java
packages of this company starts with com.vogella. Other main reason for the usage of
packages is to avoid name collisions of classes. A name collision occurs if two programmers
give the same fully qualified name to a class. The fully qualified name of a class in Java
consists of the package name followed by a dot (.) and the class name.. Without packages, a
programmer may create a Java class called Test. Another programmer may create a class with
the same name. With the usage of packages you can tell the system which class to call. For
example, if the first programmer puts the Test class into package report and the second
programmer puts his class into package xmlreader you can distinguish between these classes
by using the fully qualified name, e.g, xmlreader.Test or report.Test.
Inheritance
A class can be derived from another class. In this case this class is called a subclass. Another
common phrase is that a class extends another class. The class from which the subclass is
derived is called a superclass. Inheritance allows a class to inherit the behavior and data
definitions of another class.
The following codes demonstrates how a class can extend another class. In Java a class can
only extend a maximum of one class.
package com.vogella.javaintro.base;
class MyBaseClass {
public void hello() {
System.out.println(“Hello from MyBaseClass”);
}}
package com.vogella.javaintro.base;
class MyExtensionClass extends MyBaseClass {}
Object as superclass
Every object in Java implicitly extends the Object class. The class defines the following
methods for every Java object:
equals(o1) allows checking if the current object is equal to o1
getClass() returns the class of the object
hashCode() returns an identifier of the current object
toString() gives a string representation of the current object
Variables and methods
Variable
Variables allow the Java programmer to store values during the runtime of the
program.
Variables allow the Java program to store values during the runtime of the program. A
variable can either be a: * primitive variable * reference variable. A primitive variable
contains the value. A reference variable contains a reference (pointer) to the object.
Hence, if you compare two reference variables, you compare if both point to the same
object. To identify if objects contain the same data, use the object1.equals(object2)
method calls.
Instance variable
Instance variable is associated with an instance of the class (also called object). Access
works over these objects. Instance variables can have any access control and can be
marked final or transient. Instance variables marked as final cannot be changed after a
value has been assigned to them.
Local variable
Local (stack) variable declarations cannot have access modifiers.
Local variables do not get default values, so they must be initialized before they can
be used.
final is the only modifier available to local variables. This modifier defines that the
variable cannot be changed after the first assignment.
Methods
A method is a block of code with parameters and a return value. It can be called on
the object.
package com.vogella.javaintro.base;
public class MyMethodExample {
void tester(String s) {
System.out.println(“Hello World”);
}
}
Methods can be declared with var-args. In this case the method declares a parameter
which accepts everything from zero to many arguments (syntax: type … name;) A
method can only have one var-args parameter and this must be the last parameter in
the method.
Overwrite of a superclass method: A method must be of the exact same return
parameter and the same arguments. Also the return parameter must be the same.
Overload methods: An overloaded method is a method with the same name, but
different arguments. The return type can not be used to overload a method.
Main method
A public static method with the following signature can be used to start a Java
application. Such a method is typically called main method.
public static void main(String[] args) {}
Constructor
A class contains constructors that are invoked by the Java runtime to create objects based on
the class definition.
Constructor declarations look like method declarations except that they use the name of the
class and have no return type. In the following example the constructor of the class expects a
parameter.
package com.vogella.javaintro.base;
public class MyConstructorExample2 {
String s;
public MyConstructorExample2(String s) {
this.s = s; }
}
Each class must define at least one constructor. If no explicit constructor is defined in the
Java source file, the compiler implicitly adds a constructor. If the class is sub-classed, then
the constructor of the super class is always called implicitly in this case.
In the following example the definition of the constructor without parameters (also known as
the empty constructor) is unnecessary. If not specified, the compiler would create one.
package com.vogella.javaintro.base;
public class MyConstructorExample {
// unnecessary: would be created by the compiler if left out
public MyConstructorExample() {
}}
The naming convention for creating a constructor is the following: classname (Parameter p1,
…) { }. Every object is created based on a constructor. This constructor method is the first
statement called before anything else can be done with the object.
Modifiers
Access modifiers
There are three access modifiers keywords available in Java: public, protected, private. There
are four access levels: public, protected, default and private. They define how the
corresponding element is visible to other components. If something is declared public, e.g.,
classes or methods can be freely created or called by other Java objects. If something is
declared private, e.g., a method, it can only be accessed within the class in which it is
declared. The following table describes the visibility :
Table 1. Access level
Modifier Class Package Subclass World
public Y Y Y Y
Other modifiers
final methods: cannot be overwritten in a subclass abstract method: no method body
Synchronized method: thread safe, can be final and have any access control
Native methods: platform dependent code, apply only to methods
Strictfp: class or method
Import statements
Usage of import statements
You have to access a Java class always via its full-qualified name, i.e., the package
name followed by the class name. You can add import statements into your class file.
These allow you to use the related classes in your code without the package qualifier.
Static imports
Static import allows public static members (fields and methods) of another class to be
used in Java code without a class reference. The feature provides a typesafe
mechanism to include constants into code. It also improves code readability and
allows Java API designers to write a concise API.
Interface
Interfaces are contracts for what a class can do but they say nothing about the way in which
the class must do it. An interface is a type similar to a class. Like a class an interface defines
methods. An interface can have only abstract methods, no concrete methods are allowed.
Methods defined in interfaces are by default public and abstract- explicit declaration of these
modifiers is optional. Interfaces can have constants which are always implicitly public, static
and final. A class can implement an interface. In this case it must provide concrete
implementations of the interface methods. If you override a method defined by an interface
you can also use the @override annotation. The following code shows an example
implementation of an interface and its usage within a class.
package com.vogella.javaintro.base:
public interface MyDefinition {
String URL-http://www.vogelia.com // constant definition
// define several method stubs
void test ();
void write(String s) }
package com.vogella.javaintro.basez
public class MyClassImplementation implementa MyDefinition |
@override
public void test() {
// TODO Auto-generated method stun
@override
public void write(String s){// TODO Auto-generated methad atu}
}
Use constructor
package com.vogella.javastarter.exercises1;
class Person {
String firstName;
String lastName;
int age;
public Person(String a, String b, int value) {
firstName = a;
lastName = b;
age=value;
}
public String toString() {
return firstName + “ “ + lastName;
}}
package com.vogella.javastarter.exercises1;
public class Main {
public static void main(String[] args) {
Person p1 = new Person(“Jim”, “Knopf” , 12 );
System.out.println(p1);
Person p2 = new Person(“Henry”, “Ford”, 104);
System.out.println(p2);
}}
HISTORY OF JAVA
It is quite interesting to know the development of Java technology, which is widely accepted
in the area of networked/distributed computing Java evolved from a project developing a
language for programming consumer electronic devices at Sun Microsystems, USA.
Sun’s Stealth Project in 1990 was aimed to do research in the area of application of
computers in the consumer electronics market. Bill Joy, James Gosling, Mike Sheridan,
Patrick Naughton (formerly the project leader of Sun’s Open Windows user environment),
and several other individuals discussed the ideas for the Stealth Project in January 1991. The
vision of this project was to develop smart consumer electronic devices that could all be
centrally controlled and programmed from a handheld-remote-control-like device. The
Stealth group began to work to achieve this goal. It was realized that a platform-independent
development-environment was needed. Green Project was initiated by Patrick Naughton,
Mike Sheridan, and James Gosling of Sun Microsystems in 1991 (Members of the Stealth
Project, which later became known as the Green Project) The tasks of the project were
divided amongst the members of Green Project. Mike Sheridan concentrated on business
development, Patrick Naughton worked on the graphics system, and James Gosling was to
identify the appropriate programming language for the Green Project. Even though creating a
new language was not the aim of Green Project, a new language was created as a
programming tool in this project since C++ was found unsuitable for the project.
An intelligent remote control called *7 (Star Seven) was delivered as the first product of
Green Project in 1992. It is a PDA- like device comprising of a new language oak, an
operating system called GreenOS, user interface, and hardware. This device was quite
impressive to Sun Executives. But no customer was interested in this project. The market was
not conducive to this type of device in the consumer electronics industry.
The new language Oak was created b” James Gosling, a Green Team member, specifically for
7. Gosling named the new language Oak because that name was struck while looking at an
oak three outside of his office window. The name Oak was later renamed to Java in order to
avoid legal issues since Oak was the name of an existing language.
WebRunner (named after the movie Blade Runner). Later WevRunner was officially
announced as the HotJava browser in 1994. This was the turning point for Java. At that time
the World Wide Web changed the face of Internet and it was winning the race on Internet.
Arthur Ban Hoff implemented the Java compiler in Java itself whereas Gosling implemented
it in C. The Java compiler, written in Java made the people to accept Java as a full- featured
language.
Sun Microsystems officially announced Java environment at Sun World’95 on May 23, 1995.
Java entered into the mainstream of the Internet after a struggle for about four years.
Netscape Communications incorporated Java into its web browser Netscape Navigator.
Within a decade, Java was destined to be the most overreaching technology in the Internet.
Java was not restricted to the Internet alone. The initial goal of Sun was also achieved by
using Java. Technology in interactive set-top boxes, hand-held devices and other consumer
electronics products. Sun released the first version 1.0 of Java in 1996. Java is an object-
oriented programming language which evolved from C++. It is also a high-level
programming language.
Table 4
Year Java – Versions and features
1990 Sun Microsystems started Stealth project supporting application of computers in the
consumer electronics market.
1991 The Green project started with the members of Stealth project such as James Gosling.
Patrick Naughton, and Mike Sheridan. A new programming language, called Oak
wasCreated by Gosling.
1992 An intelligent remote control called StarSeven was delivered. The Green Project was
Incorporated was incorporated under the name FirstPerson.
1995 Oak was renamed as Java. Sun officially announced Java technology.
1996 Sun released the first version 1.0 of Java. Core Language features supporting: 10
facility, Utilities, Network Programming. User Interface Multithreading. AWT,
Applets, and multithreading.
1997 Sun released JDK1.1 by including new features such as addition of inner classes to
the language and capabilities such as JavaBeans, JDBC(Java Data Base
Connectivity), and RMI (Remote Method Invocation).
1998 Java 2 Platform, Standard Edition (J2SE)1.2, code named as Playground, was
released. It replaced JDK and distinguished the base platform from j2ee (Java 2
Platform, Enterprose Edition) and J2ME (Java 2Platform, Micro Edition). The key
features include Swing graphical API, Java IDL (Interface Definition Language) to
support CORBA interoperability. They also added Collections framework to support
various data structures. For the first time, JVM was equipped with a JIT (Just-in-
Time) compiler
2000 J2SE 1.3, code named as Kestrel, was released with key features such as JavaSound
API to support audio operations (e.g., audio playback and capture/recording, mixing,
sequencing, and synthesis), Java Naming and Directory Interface (JNDI), and Java
Platform Debugger Architecture (JPDA).
2002 H2SE 1.4, code named as Merlin, was released with key features such as (a) image
I/O API for manipulating images in formats like JPEG and PNG, (b) integrated XML.
Parser and XSLT processor (JAXP), integrated security and cryptography extensions,
(c) Java Web Start supporting deployment of Java software applications over the
network.
2004 J2SE 5.0, code named as Tiger, was released with enhancement of Java platform and
inclusion of a number of significant new language features such as Generics,
Enhanced for Loop, Autoboxing/Unboxing, Typesafe Enums, Varags, Static Import,
and Metadata supporting declarative style programming annotation of source code
2006 Java SE 6.0, code named as Mustang, was released with enhancement of performance
in Swing, JDBC 4.0 support, Java Compiler API, Upgrade of JAXB to version 2.0,
including integration of a StAX parser, support for pluggable annotations, and many
GUI improvements.
2008 Java SE 7.0, code named as Dolphin, with native support for XML recognizing its
foundation for Web services
CONCLUSION
In concluding the industrial Java training program, it's evident that this intensive and
comprehensive learning experience has been invaluable for all participants. Throughout the
duration of this program, we have delved deep into the intricacies of Java programming,
exploring its applications in industrial contexts and honing our skills to meet industry
standards.
The program has provided a robust foundation in Java development, covering key concepts
such as object-oriented programming, data structures, multithreading, GUI development, and
more. The hands-on approach through practical exercises, projects, and industry-relevant case
studies has significantly enhanced our understanding and proficiency in Java programming.
Moving forward, the onus is on us to continue building upon the foundation laid during this
training. We must remain updated with the evolving Java ecosystem, embrace continuous
learning, and apply the acquired skills creatively in solving real-world problems.
We extend our gratitude to the trainers, mentors, and the organizing team for their
unwavering support, guidance, and expertise throughout this journey. Their dedication has
been pivotal in making this training program a resounding success.
In conclusion, this industrial Java training program has been a transformative experience,
empowering us with the necessary tools and knowledge to excel in the dynamic field of Java
development within industrial settings.