Lecture 1 An Introduction to Computer, Programming and Java 1.

Slides:



Advertisements
Similar presentations
What is a Computer Program? For a computer to be able to do anything (multiply, play a song, run a word processor), it must be given the instructions.
Advertisements

L1:CSC © Dr. Basheer M. Nasef Lecture #1 By Dr. Basheer M. Nasef.
Introduction To Java Objectives For Today â Introduction To Java â The Java Platform & The (JVM) Java Virtual Machine â Core Java (API) Application Programming.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
Java: History and Introduction (Lecture # 1). History… Java – Based on C and C++ – Developed in 1991 for intelligent consumer electronic devices – Green.
Chapter 1: An Overview of Computers and Programming Languages J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program.
1 Fall 2008ACS-1903 Chapter 1 Topics Java History Java Programs Why Program? Computer Systems: Hardware and Software Programming Languages What Is a Program.
Introduction to Java Programming, 4E
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to Computers,
For more Lectures and Notes Visit
1 Chapter 1 Introduction to Computers, Programs, and Java.
Introduction to Computers, Programs, and Java. Objectives F To review computer basics, programs, and operating systems F To represent numbers in binary,
L EC. 01: J AVA FUNDAMENTALS Fall Java Programming.
01 Introduction to Java Technology. 2 Contents History of Java What is Java? Java Platforms Java Virtual Machine (JVM) Java Development Kit (JDK) Benefits.
Advanced OOP MCS-3 OOP BSCS-3 Lecture # 1
BASIC JAVA PROGRAMMING TUTORIAL. History  James Gosling and Sun Microsystems  Oak  Java, May 20, 1995, Sun World  Hot Java –The first Java-enabled.
Chapter 1 Introduction to Computers, Programs, and Java
Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved. 1 Chapter 1 Introduction to Computers, Programs,
Introduction to Java Programming with JBuilder 4
S.W. Ma/CIM/LWL41211/2 Prog. IIA Page 1 HKIVE (Lee Wai Lee Campus) Department of CIM Course : Year 2 Module : Programming IIA Textbook : Introduction.
Chapter 1 An Overview of Computers and Programming Languages.
Chapter 1 Introduction to Computers, Programs, and Java
Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved. 1 Chapter 1 Introduction to Computers, Programs,
Chapter 1 Introduction to Computers, Programs, and Java 1.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Programming Languages Machine.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to Computers,
CPCS  Problem Solving in Everyday Life  Types of Problems  Problem Solving with Computers  Difficulties with Problem Solving 0-3.
1 Chapter 1 Introduction to Computers, Programs, and Java.
111 © 2002, Cisco Systems, Inc. All rights reserved.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to Programs,
1.  At the end of this slide, student can:  Explore tools, features, properties and interface of the Textpad.  Creating a new project.  Open and run.
1 Chapter 3 Programs and Java. 2 Objectives F To review computer programs, and operating systems. F To represent numbers in binary, decimal, and hexadecimal.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
Chapter 1: Introduction to Programs, and Java 1. Objectives To review programs (§ ). To understand the relationship between Java and the World Wide.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to Programs.
Introduction to Java Programming with Forte Y. Daniel Liang.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
Object Oriented Rabie A. Ramadan, PhD Slides are exerted from different sources.
1 Chapter 3 Introduction to Computers, Programs, and Java.
What Is Java? According to Sun in a white paper: Java: A simple, object-oriented, network-savvy, interpreted, robust, secure, architecture-neutral, portable,
Liang, Introduction to C++ Programming, (c) Chapter 1 Introduction to Computers, Programs, and C++
 Programming Language  Object Oriented Programming  JAVA – An Introduction  JAVA Milestones  JAVA Features.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
Introduction to Java Programming. 2 Chapter 1 Introduction to Java and Forte F What Is Java? F Getting Started With Java Programming –Create, Compile.
1 Introduction to Java. 2 * 10% Assignments/ class participation * 10% Pop Quizzes * 05% Attendance * 25% Mid Term * 50% Final Term.
การเขียนโปรแกรมภาษา จาวา Java Programming อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา Chapter 1.
Chapter 1 An Overview of Computers and Programming Languages.
Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved. 1 Chapter 1 Introduction to Computers, Programs,
1 Chapter 1 Introduction to Computers, Programs, and Java.
CHAPTER 1 COMPUTER SCIENCE II. HISTORY OF COMPUTERS (1.1) Eniac- one of the worlds first computers Used more electricity than an entire city block of.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 1 Introduction.
1 Chapter 1 Background Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to Computers,
Introduction to JAVA Programming
Introduction to Java Programming, 4E Y. Daniel Liang.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to Computers,
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to Computers,
Java Programming: From the Ground Up
Chapter 1 Introduction to Computers, Programs, and Java
Chapter 1 Introduction to Computers, Programs, and Java
Lecture 1: Introduction to JAVA
Java programming lecture one
Chapter 1: An Overview of Computers and Programming Languages
Chapter 1 Introduction to Computers, Programs, and Java
Computer Science I CSC 135.
Chapter 1 Introduction to Computers, Programs, and Java
Chapter 1 Introduction to Computers, Programs, and Java
Outcome of the Lecture Upon completion of this lecture you will be able to understand Fundamentals and Characteristics of Java Language Basic Terminology.
Presentation transcript:

Lecture 1 An Introduction to Computer, Programming and Java 1

What is a Computer? 2 A computer is a machine that performs computations, logical operations, or more generally, data manipulation according to some prescribed sequence of instructions called a computer program. The physical components of a computer are termed hardware and the programs software.

The Hardware 3 The major hardware components:  The central processing unit (CPU) ‏  Primary or random access memory (RAM) ‏  Secondary or long term memory  Input and output devices (I/O devices) ‏

The Central Processing Unit 4 The CPU does:  the computing  the processing  the majority of the work Important components of the CPU:  arithmetic and logic unit (ALU) ‏  control unit (CU) ‏  clock

The Central Processing Unit 5  The ALU performs calculations, billions per second  The CU controls or coordinates which calculations the ALU performs  The CPU clock determines how frequently the computer hardware executes instructions.  A system’s hardware components are synchronized with the clock. Every time the clock ticks, another hardware action occurs.

Primary or Random Access Memory 6 How Data is Stored  binary format  a sequence of 0’s and 1's called bits. ASCII encoding:  ‘a’ is represented by  ‘b’ is encoded as A sequence of eight bits is called a byte.

Where Data is Stored 7  When the CPU executes a program, the program instructions, along with relevant data, are stored in primary memory.  Primary memory is also known as random access memory (RAM) because data may be retrieved or accessed in random, rather than sequential, order.

Where Data Is Stored 8  You can conceptualize RAM as a collection of storage cells or boxes, each capable of holding just a single byte of information.  A unique number, or memory address, identifies each such storage cell.

Secondary Memory 9  Long term  Permanent storage Secondary memory devices:  hard disks  tapes  CDs  flash memory sticks.

Secondary Memory 10  The programs that you use every day such as word processors, spreadsheets, and games are permanently stored on secondary storage devices.  Compared to RAM, secondary memory is, in general, cheaper (per bit), slower, larger, electromechanical rather than electronic, and persistent: secondary memory devices do not lose their values when you turn off the computer.

Input/Output Devices 11 Standard input devices:  keyboards  mouses  joysticks  stylus pens  cameras  microphones Output devices:  monitors  printers  speakers

The Software 12  The programs that run on a computer are collectively known as software. Word processors, internet browsers, editors, database management systems, computer games, and spreadsheets are all part of your computer's software library.  When you turn on or boot your computer, a program called the operating system automatically runs. This special program provides an interface between you and your computer.

Programming Languages 13 Machine Language  Assembly Language  High-Level Language Machine language is a set of primitive instructions built into every computer. The instructions are in the form of binary code, so you have to enter binary codes for various instructions. Program with native machine language is a tedious process. Moreover the programs are highly difficult to read and modify. For example, to add two numbers, you might write an instruction in binary like this:

Programming Languages 14 Assembly languages were developed to make programming easy. Since the computer cannot understand assembly language, however, a program called assembler is used to convert assembly language programs into machine code. For example, to add two numbers, you might write an instruction in assembly code like this: ADDF3 R1, R2, R3

Programming Languages 15 The high-level languages are English-like and easy to learn and program. For example, the following is a high-level language statement that adds two numbers: total = 3 + 4;

Popular High-Level Languages 16  COBOL (COmmon Business Oriented Language)  FORTRAN (FORmula TRANslation)  BASIC (Beginner All-purpose Symbolic Instructional Code)  Pascal (named for Blaise Pascal)  Ada (named for Ada Lovelace)  C (whose developer designed B first)  Visual Basic (Basic-like visual language developed by Microsoft)  Delphi (Pascal-like visual language developed by Borland)  C++ (an object-oriented language, based on C)  C# (a Java-like language developed by Microsoft)  Java (We use it in the book)

Programming and Algorithms 17  An algorithm is a finite, step-by-step procedure for accomplishing some task or solving a problem.  The study of algorithms is a basis of computer science.  A programming language is your tool, a tool that you can use to investigate and implement algorithms.

Compiling Source Code 18 A program written in a high-level language is called a source program. A computer cannot understand a source program. Program called a compiler is used to translate the source program into a machine language program called an object program. The object program is often then linked with other supporting library code before the object can be executed on the machine.

The Compiler  The program must be translated into the machine language of that computer.  Accepts a program written in a high-level language and produces a translation into the target machine language.

Java 20  General-purpose language developed by Sun Microsystems in the early 1990s, which became part of Oracle Corporation in Three main goals for their new language:  Platform Independence - Java programs should be capable of running on any computer.  Security - Java programs should not be susceptible/open to hackers' code and dangerous viruses.  Reliability - Java programs should not "crash.”

The Java Virtual Machine 21  In order to make Java a cross-platform programming language, Java's creative team designed an abstract computer implemented in software called the Java Virtual Machine (JVM). You install software on your computer that simulates a JVM computer. The machine language of the JVM is called bytecode. Java programs are first compiled into bytecode, and then executed.

The Java Virtual Machine  The Java interpreter, which is part of the JVM, executes each bytecode instruction, one by one. Once a Java program is translated into bytecode, the bytecode can run on any computer that has installed the JVM. A Java program needs to be compiled into bytecode just once.

Java, Web, and Beyond 23  Java can be used to develop any applications.  Java Applets  Java Web Applications  Java can also be used to develop applications for hand-held devices such as Palm, cell phones, PC Tablets, etc.

PDA and Cell Phone 24

Java’s History 25  James Gosling and Sun Microsystems  Oak  HotJava  The first Java-enabled Web browser  Bought by Oracle Corporation in January 2010  Java History Website:

Characteristics of Java 26  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

Characteristics of Java 27  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 Java is partially modeled on C++, but greatly simplified and improved. Some people refer to Java as "C++--" because it is like C++ but with more functionality and fewer negative aspects.

Characteristics of Java 28  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 Java is inherently object-oriented. Although many object-oriented languages began strictly as procedural languages, Java was designed from the start to be object-oriented. Object-oriented programming (OOP) is a popular programming approach that is replacing traditional procedural programming techniques. One of the central issues in software development is how to reuse code. Object- oriented programming provides great flexibility, modularity, clarity, and reusability through encapsulation, inheritance, and polymorphism.

Characteristics of Java 29  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 Distributed computing involves several computers working together on a network. Java is designed to make distributed computing easy. Since networking capability is inherently integrated into Java, writing network programs is like sending and receiving data to and from a file.

Characteristics of Java 30  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 You need an interpreter to run Java programs. The programs are compiled into the Java Virtual Machine code called bytecode. The bytecode is machine- independent and can run on any machine that has a Java interpreter, which is part of the Java Virtual Machine (JVM).

Characteristics of Java 31  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 Java compilers can detect many problems that would first show up at execution time in other languages. Java has eliminated certain types of error- prone programming constructs found in other languages. Java has a runtime exception-handling feature to provide programming support for robustness.

Characteristics of Java 32  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 Java implements several security mechanisms to protect your system against harm caused by stray programs.

Characteristics of Java 33  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 Write once, run anywhere With a Java Virtual Machine (JVM), you can write one program that will run on any platform.

Characteristics of Java 34  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 Because Java is architecture neutral, Java programs are portable. They can be run on any platform without being recompiled.

Characteristics of Java 35  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 Because Java is interpreted, the bytecode is not directly executed by the system, but is run through the interpreter. However, its speed is more than adequate for most interactive applications, where the CPU is often idle, waiting for input or for data from other sources.

Characteristics of Java 36  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 Multithread programming is smoothly integrated in Java, whereas in other languages you have to call procedures specific to the operating system to enable multithreading.

Characteristics of Java 37  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 Java was designed to adapt to an evolving environment. New code can be loaded on the fly without recompilation. There is no need for developers to create, and for users to install, major new software versions. New features can be incorporated transparently as needed.

JDK Versions 38  JDK 1.02 (1995)  JDK 1.1 (1996)  JDK 1.2 (1998)  JDK 1.3 (2000)  JDK 1.4 (2002)  JDK 1.5 (2004) a. k. a. JDK 5 or Java 5  JDK 1.6 (2006) a. k. a. JDK 6 or Java 6  JDK 1.7 (2010) a. k. a. JDK 7 or Java 7

JDK Editions 39  Java Standard Edition (J2SE)  J2SE can be used to develop client-side standalone 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.

A Simple Java Program 40 //This program prints Welcome to Java! public class Welcome { public static void main(String[] args) { System.out.println("Welcome to Java!"); } Listing 1.1

Creating and Editing Using NotePad 41 To use NotePad, type notepad Welcome.java from the command prompt.

Creating and Editing Using WordPad 42 To use WordPad, type write Welcome.java from the command prompt.

Creating, Compiling, and Running Programs 43

Compiling and Running Java from the Command Window 44  Set path to JDK bin directory  set path=c:\Program Files\java\jdk1.7.0\bin  Set classpath to include the current directory  set classpath=.  Compile  javac Welcome.java  Run  java Welcome

Acknowledgement 45  The lecture notes for this course include slides from:  Daniel Liang – Introduction to Java Programming, 2011  Antonio Martinez – Java Programming: From the Ground Up, 2010