Java Programming Unit I-Lecture - 002
Java Programming Unit I-Lecture - 002
C Programming 2
UNIT I-Java Fundamentals and Classes
Java Fundamentals: Introduction – Overview of Java virtual
machine- Data types, variable, arrays, expressions, operators,
and control structures. Classes and Objects: Classes – Objects –
Abstract classes- Static classes- Inner classes- Method
Overloading- Inheritance, Constructors and Method Overriding.
C Programming 3
Outline
• Characteristics of Java
• Versions
• Editions
• Anatomy
C Programming 4
Java, Web, and Beyond
• Java can be used to develop Web
applications.
• Java Applets
• Java Servlets and JavaServer Pages
• Java can also be used to develop
applications for hand-held devices such as
Palm and cell phones
Characteristics of Java
• Java Is Simple
• Java Is Object-Oriented
• Java Is Distributed
• Java Is Interpreted
• Java Is Robust
• Java Is Secure
• Java Is Architecture-Neutral
• Java Is Portable
• Java's Performance
• Java Is Multithreaded
Java Is Dynamic
•www.cs.armstrong.edu/liang/intro6e/JavaCharacteristics.pdf
Characteristics of Java
• Java Is Simple Java is partially modeled on C++, but
greatly simplified and improved. Some
• Java Is Object-Oriented people refer to Java as "C++--" because it
• Java Is Distributed is like C++ but with more functionality and
fewer negative aspects.
• Java Is Interpreted
• Java Is Robust
• Java Is Secure
• Java Is Architecture-Neutral
• Java Is Portable
• Java's Performance
• Java Is Multithreaded
• Java Is Dynamic
Characteristics of Java
• Java Is Simple Java is inherently object-oriented.
Although many object-oriented
• Java Is Object-Oriented languages began strictly as procedural
• Java Is Distributed languages, Java was designed from
the start to be object-oriented. Object-
• Java Is Interpreted oriented programming (OOP) is a
• Java Is Robust popular programming approach that is
replacing traditional procedural
• Java Is Secure programming techniques.
• Java Is Architecture-Neutral
One of the central issues in software
• Java Is Portable development is how to reuse code.
• Java's Performance Object-oriented programming provides
great flexibility, modularity, clarity, and
• Java Is Multithreaded reusability through encapsulation,
• Java Is Dynamic inheritance, and polymorphism.
Characteristics of Java
• Java Is Simple Distributed computing involves several
computers working together on a
• Java Is Object-Oriented network. Java is designed to make
• Java Is Distributed distributed computing (e.g. Web
Services) easy. Since networking
• Java Is Interpreted capability is inherently integrated into
• Java Is Robust Java, writing network programs is like
sending and receiving data to and from
• Java Is Secure a file.
• Java Is Architecture-Neutral
• Java Is Portable
• Java's Performance
• Java Is Multithreaded
• Java Is Dynamic
Characteristics of Java
• Java Is Simple You need an interpreter to run Java
programs. The programs are compiled
• Java Is Object-Oriented into the Java Virtual Machine code
• Java Is Distributed called bytecode. The bytecode is
machine-independent and can run on
• Java Is Interpreted any machine that has a Java
• Java Is Robust interpreter, which is part of the Java
Virtual Machine (JVM).
• Java Is Secure
• Java Is Architecture-Neutral
• Java Is Portable
• Java's Performance
• Java Is Multithreaded
• Java Is Dynamic
Characteristics of Java
• Java Is Simple Java compilers can detect many
problems that would first show up at
• Java Is Object-Oriented execution time in other languages.
• Java Is Distributed
Java has eliminated certain types of
• Java Is Interpreted error-prone programming constructs
• Java Is Robust found in other languages.
• Java Is Secure Java has a runtime exception-handling
• Java Is Architecture-Neutral feature to provide programming
support for robustness.
• Java Is Portable
• Java's Performance
• Java Is Multithreaded
• Java Is Dynamic
Characteristics of Java
• Java Is Simple
• Java Is Object-Oriented
• Java Is Distributed
• Java Is Interpreted
Java implements several security
• Java Is Robust mechanisms to protect your system
• Java Is Secure against harm caused by stray
programs.
• Java Is Architecture-Neutral
• Java Is Portable
• Java's Performance
• Java Is Multithreaded
• Java Is Dynamic
Characteristics of Java
• Java Is Simple
• Java Is Object-Oriented
• Java Is Distributed
• Java Is Interpreted
• Java Is Robust
• Java Is Secure
• Java Is Architecture-Neutral Write once, run anywhere
• Java Is Portable With a Java Virtual Machine (JVM),
• Java's Performance you can write one program that will
run on any platform.
• Java Is Multithreaded
• Java Is Dynamic
Characteristics of Java
• Java Is Simple
• Java Is Object-Oriented
• Java Is Distributed
• Java Is Interpreted
• Java Is Robust
• Java Is Secure
• Java Is Architecture-Neutral
• Java Is Portable Because Java is architecture neutral,
Java programs are portable. They can
• Java's Performance be run on any platform without being
• Java Is Multithreaded recompiled.
• Java Is Dynamic
Characteristics of Java
• Java Is Simple
• Java Is Object-Oriented
• Java Is Distributed
• Java Is Interpreted
• Java Is Robust
• Java Is Secure
• Java Is Architecture-Neutral
• Java Is Portable Because Java is architecture neutral,
Java programs are portable
• Java's Performance (moveable). They can be run on any
• Java Is Multithreaded platform without being recompiled.
• Java Is Dynamic
Characteristics of Java
• Java Is Simple
• Java Is Object-Oriented
• Java Is Distributed
• Java Is Interpreted
• Java Is Robust
• Java Is Secure
• Java Is Architecture-Neutral
• Java Is Portable
• Java's Performance Multithread programming is smoothly
• Java Is Multithreaded integrated in Java, whereas in other
languages you have to call procedures
• Java Is Dynamic specific to the operating system to enable
multithreading.
Characteristics of Java
• Java Is Simple
• Java Is Object-Oriented
• Java Is Distributed
• Java Is Interpreted
• Java Is Robust
• Java Is Secure
• Java Is Architecture-Neutral
• Java Is Portable
Java was designed to adapt to an evolving
• Java's Performance environment. New code can be loaded on the
• Java Is Multithreaded fly without recompilation. There is no need for
developers to create, and for users to install,
• Java Is Dynamic major new software versions. New features can
be incorporated transparently as needed.
JDK Versions
JDK Beta 1995
C Programming 19
JDK Editions
• Java Standard Edition (J2SE)
• J2SE can be used to develop client-side standalone
(independant) applications or applets.
• Java Enterprise Edition (J2EE)
• J2EE can be used to develop server-side
applications such as Java servlets and Java
ServerPages.
• Java Micro Edition (J2ME).
• J2ME can be used to develop applications for
mobile devices such as cell phones.
Java IDE Tools
• Borland JBuilder
• NetBeans Open Source by Sun
• Sun ONE Studio by Sun MicroSystems
• Eclipse Open Source by IBM
Anatomy of a Java Program
• Comments
• Package
• Reserved words
• Modifiers
• Statements
• Blocks
• Classes
• Methods
• The main method
Comments
In Java, comments are preceded by two slashes
(//) in a line, or enclosed between /* and */ in
one or multiple lines. When the compiler sees
//, it ignores all text after // in the same line.
When it sees /*, it scans for the next */ and
ignores any text between /* and */.
Package
The second line in the program specifies a
package name, for the class Welcome. Javac
command compiles the source code
Welcome.java, then, generates Welcome.class
and store it under a directory which is called as
name of the package.
Reserved Words
Reserved words or keywords are words that have a
specific meaning to the compiler and cannot be used
for other purposes in the program. For example,
public, static, void etc.
(Visibility or Access+)
Modifiers
Java uses certain reserved words called
modifiers that specify the properties of the
data, methods, and classes and how they can
be used. Examples of modifiers are public and
static. Other modifiers are private, final,
abstract, and protected.
• Characteristics of Java
• Versions
• Editions
• Anatomy
C Programming 32
Thank You
C Programming 33