Chapter 1 Introduction To Java
Chapter 1 Introduction To Java
Programming Language II
Chapter1
Lecture Note
Introduction to Java
Introduction to Programming
Programming Languages are important for software technologies. It is a basic one, without it programming
could not do anything about application software. It is a key factor to every application software since
a programming language is a formal language comprising a set of instructions that produce various kinds
of output. Programming languages are used in computer programming to implement algorithms.
A programming language defines a set of instructions that are compiled together to perform a specific task
by the CPU (Central Processing Unit). Each programming language contains a unique set of keywords and
syntax, which are used to create a set of instructions.
Thousands of programming languages have been developed till now, but each language has its specific
purpose. These languages vary in the level of abstraction they provide from the hardware. Mostly
programming language can be classified into two categories: Low-level language and High-level language
Page 1
Java Programming Language
Encapsulation- The implementation and state of each object are privately held inside a defined
boundary, or class. Other objects do not have access to this class or the authority to make changes but
are only able to call a list of public functions, or methods. This characteristic of data hiding provides
greater program security and avoids unintended data corruption.
Abstraction- Objects only reveal internal mechanisms that are relevant for the use of other objects,
hiding any unnecessary implementation code. This concept helps developers make changes and
additions over time more easily.
Inheritance- Relationships and subclasses between objects, it allows developers to reuse a common logic
while still maintaining a unique hierarchy. This property of OOP forces a more thorough data analysis,
reduces development time and ensures a higher level of accuracy.
Page 2
Java Programming Language
Polymorphism- Objects are allowed to take on more than one form depending on the context. The
program will determine which meaning or usage is necessary for each execution of that object, cutting
down on the need to duplicate code.
Java is a computer programming language that enables programmers to write computer instructions using
English-based commands instead of having to write in numeric codes.
Java is one of a high-level language because it can be read and written easily by humans.
Java was originally designed for use on digital mobile devices, such as cellphones for Android applications
and is also among the most favored for the development of edge devices and the internet of things.
Java Applets
Java’s History
Originally called oak (1991) for use in embedded consumer electronic applications.
Java programs can be embedded in HTML pages and downloaded by Web browsers to bring live
animation and interaction to web clients.
Characteristics of Java
Page 3
Java Programming Language
Java is Simple
Java is Object-Oriented
Java is Distributed
Java is interpreted
You need an interpreter to run Java programs. The programs into the Java Virtual Machine code called
bytecode. The bytecode is machine-independent and can run on any machine that has a Java interpreter.
Java is robust
Java is secure
The Java platform is designed with security features built into the language and runtime system such as static
type-checking at compile time and runtime checking (security manager), which let you creating applications
that can’t be invaded from outside. You never hear about viruses attacking Java applications.
If you download a Java applet and run it on your computer, it will not damage your system b/c Java
implements several security mechanisms to protect your system against harm caused by stray programs.
“Nothing should be trusted.”
Java is Portable
Java programs can be run on any platform without being recompiled. There are no platform-specific features
in the Java language.
In Java, the range of the integer is the same on every platform, as the behavior of arithmetic.
Java is a multithreaded language that can run more than one thread at the same time. A thread is the
smallest unit of a process. Multithreading helps us to gain the maximum utilization of CPU. Multiple
threads share a common memory area and increase the efficiency and performance of the
application. These threads run independently of each other without affecting each other.
Page 4
Java Programming Language
Why Use Java?
Java works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc.)
It is one of the most popular programming language in the world
It is easy to learn and simple to use
It is open-source and free
It is secure, fast and powerful
It has a huge community support (tens of millions of developers)
Java is an object oriented language which gives a clear structure to programs and allows code to be
reused, lowering development costs
As Java is close to C++ and C#, it makes it easy for programmers to switch to Java or vice versa
Comments
Package
Reserved words
Modifiers
Statements
Blocks
Classes
Methods
The main method
Unfortunately, like any technology, Java has not only advantages but also a bunch of disadvantages. The
several significant cons of Java are:
Costs for the commercial license.
Java compiler is not well optimized yet compared to C++.
There is no separation of specification from implementation.
Memory management, with Java, is a little expensive.
One can find some bugs in browsers and example programs.
Page 5