You are on page 1of 24

College of Science

Department of Computer
Programing Fundamentals (Java)
First Stage

Prepared by:
Ari M. Saeed
2018 - 2019
JAVA
Outline
 What is a computer?
 Computer system
 Computer Languages.
 Java programming language
 Java Development Process
 The Java Platform
 Creating Application in Microsoft Windows
 Exercises
 References.

3
What is a computer?
A programmable electronic device that perform
mathematical and logical operations at high speed.

4
Computer system
Computer system: consists of both hardware and software.

1- Hardware: Is the physical parts of computer which it can


physically touch or see such as monitor, case, disk drives,
microprocessor and other physical parts.

5
Computer Hardware
Hardware includes the..
• Input: keyboard, mouse, scanner, microphone.
• Processing: CPU executes the computer program.
• Output: monitor, printer and fax machine.
• Storage: hard drive, optical media and diskettes.

6
Computer system
2- Software: Is a collection of instructions that enable the
user to interact with a computer hardware, or perform tasks,
for example Java, Microsoft Word, and Media Player.

7
Computer Software
Computer systems divide software into two major groups:

• System software: Is a platform comprised of Operating


System (OS) programs and services such as Windows 7
and utility programs.

• Application software: Is a program or group of programs


designed for end users such as web browsers.

8
Computer system

9
Computer Languages
Computer language: Is a series of words used to give
instructions to the computer, telling it what to do, how to do it
and when to do it.

10
Computer Languages
Two Basic Types of Computer Language:
1. Low-Level Languages.
2. High-Level Languages.

Low-Level Languages: A language that is closer to machine


language than to human language.
Machine language and assembly languages are Low level
language.

High-level language: Is a programming language that uses


English and mathematical symbols, like +, -, % and many
others.

11
Low-Level Languages
Machine language: Is the only language that is directly
understood by the computer and it does not need to be
translated.

All instructions use binary notation and are written as a string


of 1s and 0s. Example: 111100010101010.

Assembly language: Consists of a set of symbols and letters,


A translator is required to translate the assembly language to
machine language.

12
Translator
Is a program that translates a set of code written in one
programming language into a functional equivalent of the
code in another programming language.

Translator software:
• Assembler: Translates assembly language programs into
machine code (A binary code that a machine can
understand).
• Compiler: Translates high level language code into object
code. Example: C, C++.
• Interpreter: Analyses and executes a high-level language
program a line at a time. Execution will be slower than for
the equivalent compiled code as the source code is
analyzed line by line. Example: Python, Matlab.
13
Java programming language
It was originally developed by Sun Microsystems which was
initiated by James Gosling and released in 1995 as core
component of Sun Microsystems' Java platform (Java 1.0
[J2SE]).
The latest release of the Java Standard Edition is Java SE 8.

The Java programming language is a high-level language that


can be characterized by all of the following buzzwords:

• Simple: syntax is based on C++ and  removed many


confusing instructions.
• Portable: We may carry the java bytecode to any
platform.
14
Java programming language
• Object oriented: It means we organize our software as a
combination of different types of objects that incorporates
both data and behavior.
• Secured: No explicit pointer and programs run inside
virtual machine sandbox.

• Robust: Simply means strong. Java uses strong memory


management.

• Platform Independent: A platform is the hardware or


software environment in which a program runs. There are
two types of platforms software-based and hardware-
based. Java provides software-based platform.
15
Java Development Process
• All source code is first written in plain text files ending
with the .java extension.
• Those source files are then compiled into .class files by
the javac compiler.
• A .class file does not contain code that is native to your
processor, it instead contains bytecodes the machine
language of the Java Virtual Machine (Java VM).
• The java launcher tool then runs your application with an
instance of the Java Virtual Machine.

16
Java Development Process
• Java VM is available on many different operating systems.
•  .class files are capable of running on Microsoft Windows,
the Solaris Operating System (Solaris OS), Linux, or Mac
OS.

17
The Java Platform
A platform is the hardware or software environment in which
a program runs. The Java platform differs from most other
platforms in that it's a software-only platform that runs on top
of other hardware-based platforms.

The Java platform has two components:


• JVM (Java Virtual Machine): It is a specification that
provides runtime environment in which java bytecode can
be executed.
• The Java Application Programming Interface (API): Is
a collection of prewritten packages, classes, and interfaces.

18
The Java Platform

The API and Java Virtual Machine insulate the program from
the underlying hardware.

19
Creating Application in Microsoft Windows
To write java program, it needs:
• The Java SE Development Kit 8 (JDK 8)
• A text editor
Textpad is simple editor included with the Windows
platforms.

Creating Java Application


• Create a source file: It contains code, written in the Java,
Text pad is an example to create a source file.
• Compile the source file into a .class file: (ctrl + 1) takes
your source file and translates its text into  bytecodes.
• Run the program:  (ctrl + 2) uses the Java virtual
machine to run your application.
20
Create a Source File
In a new document in Textpad, type in the following code:

class StudentApp {
public static void main(String[] args) {
System.out.println("First Application");//Display the string.
}
}

Tips: Every statement in Java must end with a semi-colon.

Save the code in a file with the name  StudentApp.java


 Compile and run the file.

21
StudentApp application
The StudentApp application consists of three primary
components:

/**The StudentApp class displays " First Application"


1-comment to the
standard output. */

2-class
class StudentApp { 3-main method
public static void main(String[] args) {

System.out.println(" First Application");


    
}
}
22
Exercises
• Write a program to display weekend days.

• Write a Java program to print the pyramids in java.


#
##
###
####
#####
• Write a Java program to display the following pattern.

23
References

Java in a Nutshell, 6th Edition, By David Flanagan,2015

Introduction to programing with java, John S.Dean,2008

http://java.sun.com/docs/books/tutorial

http://www.vogella.com

http://journals.ecs.soton.ac.uk/java/tutorial

24

You might also like