Uploaded by Abhishek Kumar

hardikgupta 00finalreportjava

advertisement
IN-HOUSE TRAINING REPORT
ON
“JAVA PROGRAMMING LANGUAGE”
Submitted in partial fulfillment of the requirements
for the award of the degree of
Bachelor of Technology
In
Electronics & Communication Engineering
Submitted To: Ms. Khushboo Verma
Assistant Professor
ECE Department
Submitted By : - Hardik Gupta
Enrollment No.02696202818
T-14
Dr. Akhilesh Das Gupta Institute of Technology & Management
FC-26, Shastri Park, New Delhi-110053.
Affiliated to Guru Gobind Singh Indraprastha University Dwarka,
New Delhi-110078.
JAN-JULY, 2021
i
CERTIFICATE
ii
TABLE OF CONTENTS
Page no.
ii
Ошибка! Закладка не определена.
Ошибка! Закладка не определена.
iii
Certificate
Acknowledgement
Abstract
Table of Contents
List of Figure
v Company profile
vi
CHAPTER 1: INTRODUCTION
1.1
1.2
Introduction to Java
The Java Platform
1.3
Installation of Java
1.4
History of Java
6
4
1
3
CHAPTER 2: ALL YOU NEED TO GET STARTED
2.1
2.2
2.3
2.4
Features of Java
Eclipse IDE for Java Developer
Debugging an Application
Most Basic Program
9
10
15
18
CHAPTER 3: LETS DIVE DEEPER
3.1
3.2
3.3
Object and Class
Data structure in java
Overview to Dynamic Programming
19
21
25
CHAPTER 4: MERITS, DEMERITS AND APPLICATIONS
4.1
4.2
4.3
CONCLUSION
REFERENCES
APPENDIX
Merits of Java
Demerits of Java
Applications in Java
27
29
30
31
32
33
iii
LIST OF FIGURES
Figure No.
Title of figure
Page No.
1.1
Java
2
1.2
Brief History of Java
8
2.1
Workspace Launcher
11
2.2
Create a Project
12
2.3
New Project For Java
13
2.4
Java Class
14
2.4
Debugging 1
15
2.6
Debugging 2
16
2.7
Debugging 3
17
2.8
Simplest Program
18
2.9
Program output
18
3.1
Flow Graph
21
3.2
Data Structure Flow Graph
24
iv
v
Chapter 1
INTRODUCTION TO JAVA
1.1 Introduction to Java
Introduction to Java With the invention of microprocessors, the world is scientifically
developed with sophisticated equipment, systems, and devices. Microprocessors are used in
computers, televisions, and fax machines. Even the hand-held devices such as pagers, PDAs
(Personal Digital Assistant), and cell phones make use of microprocessors. All these
electronic devices are helpful because of their communication capabilities. With the
increasing capabilities and decreasing cost of information processing and networking
technologies, the network is growing rapidly for transmitting information through electronic
systems.
Internet is the network of networks between different types of computers
located at different places to transmit information. Information can reach to any place in the
world quickly at a cheaper rate through the Internet. Thus, the Internet has made the world a
global village for information exchange. The emerging infrastructure of electronic devices
and interconnected computer networks create an environment that presents new challenges
to software industries. for this emerging computing environment, Java process to be a well –
suited programming language. it is found suitable for networked environments involving a
great variety of computer and devices.
Java has many characteristics that have contributed to its popularity:
Platform independence - Many languages are compatible with only one platform. Java
was specifically designed so that it would run on any computer, regardless if it was
running Windows, Linux, Mac, Unix or any of the other operating systems.
Simple and easy to use - Java's creators tried to design it so code could be written
efficiently and easily.
Multi-functional - Java can produce many applications from command-line programs
to applets to Swing windows (basically, sophisticated graphical user interfaces).
Java does have some drawbacks. Since it has automated garbage collection, it can tend to use
more memory than other similar languages. There are often implementation differences on
different platforms, which have led to Java being described as a "write once, test everywhere"
system. Lastly, since it uses an abstract "virtual machine", a generic Java program doesn't
have access to the Native API's on a system directly. None of these issues are fatal, but it can
mean that Java isn't an appropriate choice for a particular piece of software.
1
1.2 The Java Platform
2
The Java Platform 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
seperately for each new operating system/processor combination.Java is different in that it
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 f4 73 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 runs 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 it a lot
easier for programmers doing software development.
Java and Open Source:(GPL). Oracle continues this project called OpenJDK.
Java Virtual machine :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.
Java Runtime Environment vs. Java Development Kit
A Java distribution comes typically in two flavors, the Java Runtime Environment
(JRE) and the Java Development Kit (JDK).
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.
3
1.3 Installation of Java
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.
Before installing the Java Development Kit (JDK), you should probably know what it
is. It is distributed by Oracle. It contains the core libraries and compiler required to
develop Java. The JDK should not be confused with the JRE (Java Runtime
Environment). The JRE is a JVM for running, as opposed to compiling, Java programs.
Downloading and Installing
http://www.oracle.com/technetwork/java/javase/downloads/index.html. Click on
"JDK with NetBeans Bundle". Follow the instructions for downloading the JDK
installation file.
Windows: If you are running Windows, simply run the executable file and follow the
installation instructions.
Unix, Solaris, or Linux: For Linux and Unix, download the "jdk1 6.0" for Linux
systems. Save the downloaded file in any drive. Once you have saved the file, extract
it to a place that you can remember, by using Terminal or by double clicking on the
file. When you have finished extracting the file, copy the JDK 1.6.0 folder and paste
it in the usr/local(To paste to the usr/local directory, you have to be in root) so that
every user can use the java files. You can delete the downloaded zip file so that it
doesn't take up space on your drive.
Macintosh: The latest available JDK is automatically installed by the operating
system. Because Java for Macintosh is developed and maintained by Apple, in
coordination with Sun, the current version on the Macintosh may not be the current
version that is available.
Note on 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.
4
Java Micro Edition (JME) – This edition is primarily for developing programs to run
on consumer applicances, such as PDAs and cell phones.
Configuring Variables
system so you can compile your code more easily.
From the Control Panel, double click "System" (System and Maintenance in
Vista)
For Windows 7 or Vista, click on "System," "Advanced System Settings" on
the left, and then on "Environment Variables."
For XP and 2000, click on the "Advanced" tab and click on "Environment
Variables" For NT, click on the "Environment" tab.
Select the Path variable and click "Edit"
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 it during installation.
Click OK
For Linux and UNIX
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,
export PATH=$PATH:/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
Apple sets everything up for you. Sit back and relax.
The only drawback is that because Apple handles development and
maintenance of Java on the Mac, there is usually a delay from the time that a
new version is released by Sun and the time that the new version is released
on the Mac. Also, getting the latest version sometimes requires an operating
system upgrade.
Oh well, you can't have everything.
5
1.4 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 by 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.
In November 1992, the Green Project was incorporated under the name Firstperson. In 1993. Time-Warner was demanding for proposals for set-top box operating
systems and videoon-demand technology with an objective of sending the data to consumer
all over the country for display on the television sets. At the same time (1993(, NCSA released
the first graphical web browser Mosaic 1.0, an easy-to-use front end to the World Wide Web.
When FirstPerson was bidding on the Time-Warner TV trial based on videoondemand technology, Time-Warner chose Silicon Graphics, Inc. (SGI) over Sun. Hence,
half of the members of FirstPerson left for SGI and the remaining members continued to work
at Sun.
6
Mosaic web browser revolutionized people’s perceptions. The remaining member
of FirstPerson returned to work on Java (Oak was renamed Java) to develop Java-based web
browser. FirstPerson was dissolved gradually. Naughton and Jonathan Payne developed
WebRunner (named after the movie Blade Runner). Later WevRunner was officially
announced as the HotJavaTM 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
fullfeatured 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. The different forms of Java versions are discussed in the next section.
7
Figure 1.2 – Brief history of Java
8
CHAPTER 2
ALL YOU NEED TO GET STARTED
2.1 Features of Java
According to Sun, Java is defined as a simple, object-oriented, distributed, interpreted,
robust, secure, architecture –neutral, portable, high performance, multithreaded, and
dynamic programming language and platform.
Java is simple because the syntax of well-known languages such as C and C++ are used
with modifications meant for simplification and improvement. It is easy to read and write
Java code if the reader is familiar with C/C++.
Almost everything in Java is centered on creating objects, manipulating the objects and
making objects work together. Only the primitive operations and data types are at the subobject level. Hence Java is an object-oriented programming language.
An application can be distributed in many systems which are connected together. Since
networking capability is incorporated in Java, the data/file can be sent across many systems
to run the application.
Java is robust because it is more reliable. It ensures the reliability by providing early checking
for possible errors. It eliminates error-prone constructs such as pointer. It eliminates
errorprone constructs such as pointer. It also supports runtime error handling.
Java programs are compiled to a byte code format that can be read and run by interpreters on
many platforms including Windows, Linux, etc. Hence, it is architecture neutral. Because of
this feature it is portable to new hardware and operating systems.
Although the speed of execution of Java programs is slower compared to C/C++ programs,
Java is meant for distributed applications. Whenever the file/data is transmitted from one
system to another, the performance is not affected. Hence, it is having high performance.
Java supports multithreaded programming to perform several tasks simultaneously. Any code
can be loaded without recompilation at runtime. Hence it is dynamic.
2.2 Eclipse IDE For Java Developers
9
Eclipse IDE is written in Java. It mainly consists of a base ‘Workspace’ and a plug-in system
so that we can add more features to it through plugins and extend the functionality of the IDE.
Eclipse works on all the major platforms including Windows, Mac OS, Linux, etc. and boasts
of powerful features that can be used to develop full-fledged projects.
Development Environment for Eclipse includes:
• Eclipse Java Development Tools (JDT) for Java and Scala.
• Eclipse C/C++ Development Tools (CDT) for C/C++.
• Eclipse PHP Development Tools (PDT) for PHP.
In this tutorial, we will explore the features of Eclipse IDE with respect to Java development
and also discuss all the steps to setup eclipse on our computer to begin development.
Features Of Eclipse IDE
•
•
•
•
•
•
Almost everything in Eclipse is a plugin.
We can extend the functionality of Eclipse IDE by adding plugins to the IDE,
maybe for additional programming language or version control system or
UML. Supports various source knowledge tools like folding and hyperlink
navigation, grading, macro definition browser, code editing with syntax
highlighting.
Provides excellent visual code debugging tool to debug the code.
Eclipse has a wonderful user interface with drag and drop facility for UI
designing.
Supports project development and administered framework for different
toolchains, classic make framework, and source navigation.
Java Eclipse IDE has a JavaDoc facility using which we can automatically
create documentation for classes in our application.
Install and Configure Eclipse Java IDE
In order to install and configure Eclipse Ide for Java development, first, we need to make sure
that we have an appropriate JDK version on our machine.
Please follow the below steps to install and configure Eclipse Ide for Java Development.
Step 1: Install JDK
For Eclipse to function properly, our system should have JDK installed. Eclipse makes use
of JDK for Java development.
Note: We have already covered a topic on JDK installation in our tutorial “Java Download &
Install”. Please refer to it to know more about the JDK installation.
10
Once the applications we build using Eclipse IDE are built and executed successfully, we
should have values set for two environment variables on our system i.e. “PATH” and
“CLASSPATH” which are set as a result of JDK installation.
Step 2: Download Eclipse
Download the Eclipse installable from Eclipse Packages. Click on “Eclipse IDE for Java
Developers” for “Windows 64-bit” which is a 201 MB file.
Step 3: Unzip
There is no installation sequence as such for Eclipse, you just have to unzip the contents of
the downloaded package and then run “Eclipse.exe” and you are ready for Java development
using Eclipse IDE.
Development Using Eclipse IDE
#1) Launch Eclipse
• Eclipse can be launched by running “eclipse.exe” from the Eclipse installed
directory.
Figure 2.1 - The window to choose workspace is as shown below:
•
•
Choose an appropriate directory for your workspace, i.e., where you would
like to save your files (For Example, c:\Users\Username\workspace for
Windows). Click Ok.
If the “Welcome” screen shows up, close it by clicking the “close” button next
to the “Welcome” title.
#2) Create a New project
Click File -> New-> Java Project.
11
Figure 2.2 - The following dialog box is presented to the user.
Specify the project name. Select the option “Use default JRE (currently ‘JRE’) and
then click NEXT by keeping the other options unchanged.
12
Figure 2.3 - The below dialog box is presented to the user.
You are shown the summary of the just created project. In this dialog, you can also
specify a default output folder path. Click Finish and the project is created.
#3) Create a New Class
To start Java coding, we need to create different classes. Let us create our first class .
For this right-click Project name in the Package Explorer pane (on the left side). Select
New -> Class. The following screen will be displayed.
13
Figure 2.4 - Fill in the details as per your requirements and click Finish. A new class
will be created.
#4) Write a “Hello, world” program.
Once the class is created, a corresponding source file is created for this class in the
‘src’ folder of the project and it opens in the editor. In this case, as we created a class
named “HelloWorld”, a file named “HelloWorld.java” is created.
Provide the following code in the ‘HelloJava.java” file.
public static void main(String[] args) {
System.out.println("Hello, world!");
}
Now our first program is ready and we can move on to the “Build and execute” step.
14
2.3 Debugging An Application In Eclipse
If you get the desired output when you run the project, then you can say that the project is
successful. But if you don’t get the desired results, you might have to debug your application.
To debug a project, we have to perform the following steps:
#1) Set a Breakpoint
By setting up a breakpoint, you can suspend the execution of the program. This will allow
you to examine the program step by step and also watch the intermediate values of variables
and flow of execution so that you can find out the problem in your code.
It is normally a good practice to set the breakpoint in the main function as it’s the starting
point for a Java program. To set a breakpoint, you can double click on the left panel of the
code file against the line of code for which you want a breakpoint.
Another way is to click “Ctrl+Shift+B” by placing the cursor on the line of code for which
the breakpoint is required.
Figure 2.5 – Debugging 1
The red arrow shows the line for which the breakpoint is set. It is denoted by a circle on the
left-hand pane. A red circle in the above screenshot shows the debug option in the toolbar.
#2) Start Eclipse Debugger
Once the breakpoint is set, you can start debugger by right-clicking (or Run option in the
menu) the project name and select “Debug As=>Java Application”.
On doing this your execution will pause at the line at which the breakpoint is set.
#3) Step Over and Watch Variables & Output
15
After starting the debug, you can “Step Over” each line of code and examine the variable
values by hovering your mouse over that variable.
This process of stepping through each line of code is the ultimate method to debug your
program.
#4) Debug Operations -> Run-to-line resume, Terminate
These are all the operations that you can perform with debugging. Run-to-line will continue
the program execution up to the line where the cursor is placed. Resume continues the
program execution up to the next breakpoint or till the end of the program. Terminate
terminates the debugging session.
The following screenshot shows the entire debug window of Eclipse IDE along with the
operations we discussed.
Figure 2.6 – Debugging 2
The debug toolbar is encircled in a red outline in the screenshot and shows icons for all the
operations.
16
#5) Switch Back to the Development Perspective
Figure 2.7 – Debugging 3
Click the Java icon shown in the above screenshot (pointed by the red arrow) to switch back
to the project for further programming.
Readers can explore the other debugger features like step-into (wherein we can go inside any
function and debug it); modify the value of the variable being watched, etc.
17
2.4 Most Basic Program of the Java
Program:-
Figure 2.8: - Simplest program
output:-
Figure 2.9: - Output
CHAPTER 3
LET’S DIVE DEEPER
18
3.1 Object and Class
Object is the physical as well as logical entity where as class is the only logical entity.Class:
Class is a blue print which is containing only list of variables and method and no memory is
allocated for them. A class is a group of objects that has common properties.
A class in java contains:
•
•
•
•
•
Data Member
Method
Constructor
Block
Class and Interface
3.1.1 Object: Object is a instance of class, object has state and behaviors.
An Object in java has three characteristics:
• State
• Behavior
• Identity
State: Represents data (value) of an object.
Behavior: Represents the behavior (functionality) of an object such as deposit, withdraw
etc.
Identity: Object identity is typically implemented via a unique ID. The value of the ID is not
visible to the external user. But it is used internally by the JVM to identify each object
uniquely. Class is also can be used to achieve user defined data types.
3.1.2 Data Types
Datatype is a special keyword used to allocate sufficient memory space for the data, in other
words Data type is used for representing the data in main memory (RAM) of the computer.
In general every programming language is containing three categories of data types. They are
• Fundamental or primitive data types
• Derived data types
• User defined data types.
19
3.1.3 Variable
Variable is an identifier which holds data or another one variable is an identifier whose
value can be changed at the execution time of program. Variable is an identifier which can
be used to identify input data in a program.
3.1.4 Operators And Its Types
Operator is a special symbol that tells the compiler to perform specific mathematical or
logical Operation. Java supports following lists of operators.
• Arithmetic Operators
• Relational Operators
•
• Assignment Operators
• Ternary or Conditional Operators.
20
3.2 What is Data Structure?
The data structure name indicates itself that organizing the data in memory. There are many
ways of organizing the data in the memory as we have already seen one of the data structures,
i.e., array in C language. Array is a collection of memory elements in which data is stored
sequentially, i.e., one after another. In other words, we can say that array stores the elements
in a continuous manner. This organization of data is done with the help of an array of data
structures. There are also other ways to organize the data in memory. Let's see the different
types of data structures.
The data structure is not any programming language like C, C++, java, etc. It is a set of
algorithms that we can use in any programming language to structure the data in the memory.
To structure the data in memory, 'n' number of algorithms were proposed, and all these
algorithms are known as Abstract data types. These abstract data types are the set of rules.
Figure 3.1: - Data Structure Flowchart
3.2.1 Types of Data Structures
There are two types of data structures:
o
Primitive data structure
o
Non-primitive data structure
21
Primitive Data structure
The primitive data structures are primitive data types. The int, char, float, double, and pointer
are the primitive data structures that can hold a single value.
Non-Primitive Data structure
The non-primitive data structure is divided into two types:
o
Linear data structure o Non-linear data structure
Linear Data Structure
The arrangement of data in a sequential manner is known as a linear data structure. The data
structures used for this purpose are Arrays, Linked list, Stacks, and Queues. In these data
structures, one element is connected to only one another element in a linear form.
When one element is connected to the 'n' number of elements known as a non-linear data
structure. The best example is trees and graphs. In this case, the elements are arranged in a
random manner.
We will discuss the above data structures in brief in the coming topics. Now, we will see the
common operations that we can perform on these data structures.
Data structures can also be classified as:
o
Static data structure: It is a type of data structure where the size is allocated at the
compile time. Therefore, the maximum size is fixed.
o
Dynamic data structure: It is a type of data structure where the size is allocated at the
run time. Therefore, the maximum size is flexible.
3.2.2 Major Operations
The major or the common operations that can be performed on the data structures are:
o
Searching: We can search for any element in a data structure.
o
Sorting: We can sort the elements of a data structure either in an ascending or
descending order.
o
Insertion: We can also insert the new element in a data structure.
o
Updation: We can also update the element, i.e., we can replace the element with
another element.
o
Deletion: We can also perform the delete operation to remove the element from the
data structure.
22
3.2.3Which Data Structure?
A data structure is a way of organizing the data so that it can be used efficiently. Here, we
have used the word efficiently, which in terms of both the space and time. For example, a
stack is an ADT (Abstract data type) which uses either arrays or linked list data structure for
the implementation. Therefore, we conclude that we require some data structure to implement
a particular ADT.
An ADT tells what is to be done and data structure tells how it is to be done. In other words,
we can say that ADT gives us the blueprint while data structure provides the implementation
part. Now the question arises: how can one get to know which data structure to be used for a
particular ADT?.
As the different data structures can be implemented in a particular ADT, but the different
implementations are compared for time and space. For example, the Stack ADT can be
implemented by both Arrays and linked list. Suppose the array is providing time efficiency
while the linked list is providing space efficiency, so the one which is the best suited for the
current user's requirements will be selected.
3.2.4 Advantages of Data structures
The following are the advantages of a data structure:
o
Efficiency: If the choice of a data structure for implementing a particular ADT is
proper, it makes the program very efficient in terms of time and space.
o
Reusability: he data structures provide reusability means that multiple client programs
can use the data structure.
o
Abstraction: The data structure specified by an ADT also provides the level of
abstraction. The client cannot see the internal working of the data structure, so it does
not have to worry about the implementation part. The client can only see the interface.
3.2.5 List of Data Structures using Java
•
Array
•
Linked List
• Stack
•
•
•
•
•
Queue
Binary Tree
Binary Search Tree
Heap
Hashing
23
•
Graph
Figure 3.2 :- Data Structure Classification
3.3 Overview to Dynamic Programming: Java
What is Dynamic Programming?
Dynamic programming is a programming technique used to solve recursive problems more
efficiently. Specifically, it adds time efficiency, and it does so by taking advantage of data
structures to store reusable solutions to intermediate steps, thus saving redundant
computations. It’s a way of solving problems with recursive relationships by solving smaller
problems and building up to the solution to the original problem.
Let’s take a look at a simple algorithm that can get computationally complex very quickly,
and then let’s use dynamic programming to increase its efficiency.
Fibonacci
24
The Fibonacci series is a classic mathematical series in which each number is equal to the
sum of the two numbers before it, always starting with 0 and 1:
0, 1, 1, 2, 3, 5, 8, 13, 21, etc.
The 0th Fibonacci number is always 0 and first Fibonacci number is always 1. So the second
Fibonacci number is 0 + 1 = 1, third Fibonacci number is 1 + 1 = 2, and so on. You could
calculate the nth number iteratively this way, but you could also calculate it recursively
fib(n) if n is 0 or 1 return
n else return fib(n - 1) +
fib(n - 2)
This technique breaks up calculating the nth number into many smaller problems, calculating
each step as the sum of calculating the previous two numbers.
Although this technique will certainly work to find the correct number, n
grows,
the
as
number
of recursive calls grows very quickly. Let’s visualize all the function calls if we were to
calculate the fourth Fibonacci
number:
fib(4) -> fib(3) + fib(2)
fib(3) -> fib(2) + fib(1)
fib(2) -> fib(1) + fib(0)
fib(2) -> fib(1) + fib(0)
As you can see
is called twice, fib(1) is called three times. If n were larger than
,
fib(2)
you’d
see these numbers of calls get high very quickly. For instance, to calculate the 10th number,
we’d make 34 calls to fib(2) and 177 total function calls! Why do we need to call the same
function multiple times with the same input?
We don’t! We can use a dynamic programming technique called memoization to cut down
greatly on the number of function calls necessary to calculate the correct number.
25
CHAPTER 4
MERITS, DEMERITS AND APPLICATIONS
4.1 Merits of Java: Java is the most widely used programming language in the world. Therefore,
learning Java means learning a language which will be useful in developer life.
Java is easy to learn. It is one of the easiest languages to learn among languages
which are truly useful.
Java is supported by high quality tools. These tools will make the job of learning
the language easier and a lot more fun.
It targets a wide variety of platforms. It is really motivating to know that the
programs that you write after you have mastered the language will find audiences
from a wide array of backgrounds (Android, server-side, desktop).
You can easily get help. There are hundreds of thousands of people programming
in Java on a daily basis who are willing to help newcomers. They are present on
websites which allow newbies to talk to them.
Java is a proper language. There are languages better than Java (Kotlin, Swift
etc). However, compared with languages such as JavaScript and PHP which are
nothing more than collections of constructs with little forethought, Java is still a
properly thought-out language. Unlike Basic which encourages bad coding
practices, Java promotes craftsmanship which is the art of producing disciplined
code.
Java is statically typed. This promotes cognitive growth. Developers who are
proficient in statically typed languages are forced to anticipate the uses of storage
structures before they actually use them. From my experience as a teacher of
programming, this truly enhances the thinking ability of learners. Static typing
also helps when you actually write huge programs in real life.
Java opens doors to the learning of other programming languages. There are lots
of programming languages which are similar in construct to Java. Java
programmers can migrate to C#, C++ and Objective-C without big efforts.
Several languages (such as Kotlin, Scala and Closure) are targeted for the JVM
allowing for library
26
reuse. Therefore, barrier to the mastery of these languages since their APIs will
feel familiar.
There are millions of good examples available free of charge. You can read lines
of superbly written Java programs available free of charge online and your
journey as a student is enriched by those noble programmers who choose to open
their code for the world to see. In contrast, there are other languages loved by the
open source community but it’s easy to find badly written code in them.
Mind-blowing APIs. The standard library that is shipped with Java is a very good
example of good code. You learn good engineering practices just by using it.
27
4.2 Demerits of Java: Performance
Java programs take much longer time to run compared to C/C++.
Memory
Since Java Programs run on top of Java Virtual Machine, it consumes more
memory.
Cost
Since memory and processing requirements higher, hardware cost increases.
Low level programming
There is no support for low level programming in Java, like pointers are
missing.
Garbage collection
There is no control over garbage collection in Java. That is programmer does
not have any right to control the garbage collection. Java does not provide
functions like delete(), free().
No Unsigned Types Unlike C/C++, Java does not support unsigned int, unsigned
char, … etc. However in Java 8, API for unsigned long and unsigned int is
introduced .
4.3 Applications of Java
Technology is constantly going through an evolution and so are the languages that are used
to develop them. Java is one of the popular programming language having n number of
applications. I will be listing down the top applications of Java.
• Mobile Applications
• Desktop GUI Applications
• Web-based Applications
28
• Enterprise Applications
• Scientific Applications
• Gaming Applications
• Big Data technologies
• Business Applications
• Distributed Applications
Conclusion: The report has been successfully completed by having a good grasp of java programming
language with Data Structures and Algorithm. This will help me in my future years and
especially in my 4th year at the time of the placements these skills which I learned during this
period will help me to go through a lot. The report is a very good and a crux explanation on
the java language and anyone can go through it to understand the basic concepts.
And lastly, beside all the exceptions, Java is one of the most used language in the
software industry due to its maintainability and platform independent features.
29
References: [1.] www.edureka.co
[2.] www.tutorialspoint.com
[3.] www.programiz.com
[4.] www.Hackr.io
[5.] www.geeksforgeeks.com
[6.] www.wikipedia.com
[7.] www.udemy.com
30
Appendix
Company profiles(appendix)
With a mission to improve lives through learning, Udemy is the largest online learning
destination that helps students, businesses, and governments gain the skills they need to
compete in today’s economy. More than 50 million students are mastering new skills from
expert instructors teaching over 150,000 online courses in topics from programming and data
science to leadership and team building. For companies, Udemy for Business offers an
employee training and development platform with subscription access to 4,000+ courses,
learning analytics, as well as the ability to host and distribute their own content. Udemy for
Government is designed to upskill workers and prepare them for the jobs of tomorrow.
Udemy is privately owned and headquartered in San Francisco with offices in Denver, Brazil,
India, Ireland, and Turkey.
Website: -http://www.udemy.com
Industries: - E-Learning
Company size: -501-1000 employees
Headquarters: -San Francisco, CA
Type: - Privately Held
Founded: - 2010
Specialties: - e-learning, education, skills, technology, internet, and marketplace Locations
Primary
600 Harrison St
Floor 3
San Francisco, CA 94107, US
Get directions
Overview
Udemy is a platform that allows instructors to build online courses on their preferred topics.
Using Udemy's course development tools, they can upload videos, PowerPoint presentations,
PDFs, audio, ZIP files and live classes to create courses. Instructors can also engage and
interact with users via online discussion boards.
Courses are offered across a breadth of categories, including business and entrepreneurship,
academics, the arts, health and fitness, language, music, and technology.] Most classes are in
practical subjects such as Excel software or using an iPhone camera. Udemy also offers
Udemy for Business, enabling businesses access to a targeted suite of over 7,000 training
courses[23] on topics from digital marketing tactics to office productivity, design,
management, programming, and more. With Udemy for Business, organizations can also
create custom learning portals for corporate training.
Courses on Udemy can be paid or free, depending on the instructor. In 2015, the top 10
instructors made more than $17 million in total revenue.
Massive open online course (MOOC)
Udemy is part of the growing MOOC movement available outside the traditional university
system, and has been noted for the variety of courses offered.
31
32
Download