L01 - Intro to Java
L01 - Intro to Java
program
compiler compiler
compiler
Unix
Win
MAC
Java Interpreter
• Java is a little different.
• Java compiler produces bytecode not
machine code.
• Bytecode can be run on any computer
Win
with the Java interpreter installed.
compiler Interpreter
Unix
Advantages and Disadvantages of Java
Advantages:
• Java is platform independent. Once it's compiled, you can run
the bytecode on any machine with a Java interpreter. You do not
have to recompile for each platform.
• Java is safe. Certain common programming bugs and dangerous
operations are prevented by the language and compiler.
• Java standardizes many useful operations like managing
network connections and providing graphical user interfaces.
Disadvantages:
• Running bytecode through the interpreter is not as fast as
running machine code, which is specific to that platform.
• Because it is platform independent, it is difficult to use platform
specific features (e.g., Windows taskbar, quick launch) in Java.
• Java interpreter must be installed on the computer in order to run
Java programs.
Object-Oriented Programming
• Java is an object-oriented
programming language
• Example 1: Dogs
– States: name, color and “is hungry?”
– Behaviors: bark, run, and wag tail
• Example 2: Cars
– States: color, model…
– Behaviors: accelerate, turn, change gears
Class
• Definition: A class is a blueprint that defines the
states and the behaviors common to all objects of
a certain kind.
This paradigm is straight forward and to the point while writing the
program code.
Types of programming paradigm
Types of programming paradigm
1. Procedural Programming Paradigm
The program consist of set of procedures.
The function once defined can be called many time in the program to
repeat the same operation.
Types of programming paradigm
2. Structured Programming Paradigm
The structured programming intends to optimize the code by using
the program control flow constructs, decision making constructs and
the iteration constructs, blocks and the functions.