OOP-Lec21-Java Introduction
OOP-Lec21-Java Introduction
(CS-112)
• 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 Write once, run anywhere
Architecture-Neutral
With a Java Virtual Machine (JVM),
• Java Is Portable you can write one program that will
• Java's Performance 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 Because Java is architecture neutral,
• Java Is Portable Java programs are portable. They can
be run on any platform without being
• Java's Performance recompiled.
• 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’s performance Because Java is
• Java Is Portable architecture neutral, Java programs are
portable. They can be run on any
• Java's Performance platform without being recompiled.
• 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
Multithread programming is smoothly
• Java's Performance integrated in Java, whereas in other
• Java Is Multithreaded languages you have to call procedures
specific to the operating system to enable
• Java Is Dynamic 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
environment. New code can be loaded on the
• Java's Performance fly without recompilation. There is no need for
developers to create, and for users to install,
• Java Is Multithreaded major new software versions. New features can
• Java Is Dynamic be incorporated transparently as needed.
Java Architecture
✅ Java Virtual Machine (JVM)
• Full development suite: includes JRE + compiler + debugger + tools like javac,
javadoc, jar
JDK Editions
• Java Standard Edition (J2SE)
• J2SE can be used to develop client-side standalone
applications or applets.
• Software tools can be used to help with all parts of this process
Programming Languages
• Each type of CPU executes only a particular machine language
• A program must be translated into machine language before it can be
executed
• A compiler is a software tool that translates source code into a specific
target language
• Often, that target language is the machine language for a particular CPU
type
• The Java approach is somewhat different
Java Translation
• The Java compiler translates Java source code into a special
representation called bytecode
• Java bytecode is not the machine language for any traditional CPU
• Another software tool, called an interpreter, translates bytecode into
machine language and executes it
• Therefore, the Java compiler is not tied to any particular machine
Creating, Compiling, and
Running Programs
What is Eclipse?
• Best known as an Integrated Development Environment (IDE)
• Provides tools for coding, building, running, and debugging applications
• Open Source
• It is a general purpose open platform that facilitates and encourages the development of
third-party plug-ins
• A workspace is nothing more than a location where we will store our source code and
where Eclipse will write out our preferences
• Choose a location where you want to store your files, then click OK
Eclipse Environment
Eclipse
Environment
Eclipse Environment
Eclipse Environment
Eclipse Environment
Eclipse Environment
HelloWorld Program
HelloWorld Program
HelloWorld Program
Font Size
Outline
Warning
1 // Fig. 2.1: Welcome1.java Outline
2 // A first program in Java.
3
4 public class Welcome1 {
5 Welcome1.java
6 // main method begins execution of Java application
7 public static void main( String args[] )
8 {
9 System.out.println( "Welcome to Java Programming!" );
10
11 } // end method main
12
13 } // end class Welcome1
Program Output
• double x = 63;
double y = 35;
System.out.println(x / y);
Ouput: 1.8
– Arithmetic operators
– Assignment operator
– Increment/Decrement operators
– Relational operators
– Conditional operators