Chapter 1 Introduction to Computers, Programs, and Java. What is a Computer? A Bit of History

Similar documents
Chapter 1 Introduction to Computers, Programs, and Java

Chapter 1 Introduction to Computers, Programs, and Java

Objectives. Chapter 1 Introduction to Computers, Programs, and Java. What is a Computer?

Chapter 1 Introduction to Java

Lecture 1: Introduction to Java

Networks Programming Engr. Abdul-Rahman Mahmood MS, PMP, MCP, QMR(ISO9001:2000)

Chapter 1 Introduction to Computers, Programs, and Java

Java Language. Programs. Computer programs, known as software, are instructions to the computer. You tell a computer what to do through programs.

Chapter 1 Introduction to Computers, Programs, and Java

Chapter 1 Introduction to Computers, Programs, and Java

Introduction to Computers, Programs, and Java. CSE 114, Computer Science 1 Stony Brook University

Chapter 1 Introduction to Computers, Programs, and Java

Chapter 1: Introduction to Computers, Programs, and Java

Introduction to Java. Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved.

Module 1: Introduction to Computers, Programs, and Java

Chapter 1 Introduction to Computers, Programs, and Java

II. Compiling and launching from Command-Line, IDE A simple JAVA program

Getting Started. Chapter 1. Java Programming FROM THE BEGINNING. Chapter 1: Getting Started

Chapter 1 Introduction to Computers, Programs, and Java

CHAPTER 1 INTRODUCTION TO COMPUTERS, PROGRAMS, AND JAVA. Objectives

Introduction to Java Programming CPIT 202. WEWwwbvxnvbxmnhsgfkdjfcn

History Introduction to Java Characteristics of Java Data types

Chapter 1: Introduction to Computers and Java

8/23/2014. Chapter Topics. Introduction. Java History. Why Program? Java Applications and Applets. Chapter 1: Introduction to Computers and Java

Programming: detailed instructions which tell the computer hardware what to do aka software Computer Science: the study NOT of computers, but of what

Lesson 01 Introduction

Introduction to JAVA Programming Language

Outline. Introduction to Java. What Is Java? History. Java 2 Platform. Java 2 Platform Standard Edition. Introduction Java 2 Platform

Introduction. Introduction to OOP with Java. Lecture 01: Introduction to OOP with Java - AKF Sep AbuKhleiF -

CHAPTER 1 Introduction to Computers and Java

IQTIDAR ALI Lecturer IBMS Agriculture University Peshawar

Introduction to OOP with Java. Instructor: AbuKhleif, Mohammad Noor Sep 2017

Elements of Computers and Programming Dr. William C. Bulko. What is a Computer?

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson

Introduction to Computers and Java. Objectives. Outline. Harald Gall, Prof. Dr. Institut für Informatik Universität Zürich.

Introduction to Computers and Java

Introduction to Computers and Java

Introduction to Computers and Java. Objectives. Outline. Harald Gall, Prof. Dr. Institut für Informatik Universität Zürich.

Chapter. Focus of the Course. Object-Oriented Software Development. program design, implementation, and testing

9/11/08 (c) 2008 Matthew J. Rutherford Class (c) 2008 Matthew J. Rutherford Class

Introduction to Computers and Java

Introduction to Java. Nihar Ranjan Roy.

Introduction to Java Programming

Computer Basics 1/24/13. Computer Organization. Computer systems consist of hardware and software.

Computer Basics 1/6/16. Computer Organization. Computer systems consist of hardware and software.

CHAPTER 1. Introduction to JAVA Programming

Eng. Mohammed S. Abdualal

Introduction to OOP Using Java Pearson Education, Inc. All rights reserved.

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.

COMP Computer Basics. Yi Hong May 13, 2015

Part I: Fundamentals of Programming

Certified Core Java Developer VS-1036

History of Java. Java was originally developed by Sun Microsystems star:ng in This language was ini:ally called Oak Renamed Java in 1995

The Computer System. Hardware = Physical Computer. Software = Computer Programs. People = End Users & Programmers. people

Introduction to Computers and Java

Java Programming Language Mr.Rungrote Phonkam

BASICS.

From High Level to Machine Code. Compilation Overview. Computer Programs

Java is a high-level programming language originally developed by Sun Microsystems and released in Java runs on a variety of

Chapter 1: An Overview of Computers and Programming Languages. Objectives. Objectives (cont d.) Introduction

This lecture will take you through simple and practical approach while learning Java Programming language.

Introduction to Java

Eng. Mohammed Alokshiya

Programming 1. Lecture 1 COP 3014 Fall August 28, 2017

1. Introduction. Java. Fall 2009 Instructor: Dr. Masoud Yaghini

Learning objectives. The Java Environment. Java timeline (cont d) Java timeline. Understand the basic features of Java

Chapter 1. Introduction to Computers and Java Objects. Background information. » important regardless of programming language. Introduction to Java

Introduction to Computers and Java

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Chapter 1: Introduction to Computers and Programming

Class List. Java Must Have. Class Goals. Class Goals. Schedule

Course Outline. Introduction to java

Objectives. Problem Solving. Introduction. An overview of object-oriented concepts. Programming and programming languages An introduction to Java

Getting Started with Java. Atul Prakash

Eclipse Tutorial. For Introduction to Java Programming By Y. Daniel Liang

Chapter 1 INTRODUCTION

An Introduction to Software Engineering. David Greenstein Monta Vista High School

Introduction to Computers and Java

COMP163. Introduction to Computer Programming. Introduction and Overview of the Hardware

CT 229. CT229 Lecture Notes. Labs. Tutorials. Lecture Notes. Programming II CT229. Objectives for CT229. IT Department NUI Galway

Programming. Syntax and Semantics

Lecture 1: Overview of Java

CHAPTER INTRODUCTION. Final Draft Oct. 15, Slides by Donald W. Smith TechNeTrain.com. Copyright 2013 by John Wiley & Sons. All rights reserved.

Chapter Goals. Contents. 1.1 Computer Programs

CompSci 125 Lecture 02

Programming 1 - Honors

Computer Principles and Components 1

CS11 Java. Fall Lecture 1

CS335 Graphics and Multimedia

Week 2: Data and Output

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Computer Fundamentals

Chapter 1. Introduction

Advanced Object-Oriented Programming Introduction to OOP and Java

Chapter 1: Why Program? Main Hardware Component Categories 8/23/2014. Main Hardware Component Categories: Why Program?

Pace University. Fundamental Concepts of CS121 1

CSE 421 Course Overview and Introduction to Java

Operating Systems CS3502 Spring 2018

CS 177 Recitation. Week 1 Intro to Java

C++ Spring Break Packet 11 The Java Programming Language

Transcription:

Chapter 1 Introduction to Computers, Programs, and Java CS170 Introduction to Computer Science 1 What is a Computer? A machine that manipulates data according to a list of instructions Consists of hardware and software Many physical forms 2 A Bit of History 1801 first programmable device 1930s and 1940s digital computers

What is a Computer? Computer components: CPU, memory, hard disk, floppy disk, monitor, printer, and communication devices. 4 CPU Stands for central processing unit Retrieves instructions from memory and executes them Speed measured in GHz (gigahertz) (1GHz=1billion of pulses per second) Modern CPU can have few cores 5 Memory (RAM) Stores data and program instructions for CPU Memory unit: byte (a sequence of 8 bits) What is a bit? It s a binary digit taking value 0 or 1 Memory is a volatile storage Programs and data need to be loaded to main memory before execution by CPU 6

How Data is Stored in Memory? Everything is coded as a series of bits Why computers use only 0/1? Programmers need not to be concerned about the encoding and decoding of data Performed automatically 7 Storage Devices Reminder: main memory is volatile Programs and data are permanently stored on storage devices or secondary memory Storage device types: Disk drive CD 8 Input and Output Devices I/O is the means by which a computer receives information from the outside world and sends result back. Output devices: monitor, printer Input devices: keyboard, mouse, joystick 9

Getting rid of your keyboard and mouse? The Mac Wheel Computer Programs Computer program is a set of instructions Operating systems: core software of a computer Windows (XP, Vista), Unix, Linux, MacOS, Application software: any software other than operating systems Web browsers, word processors, games, 11 Operating Systems (OS) A program that manages and controls a computer s activities Any other program (internet browser, word processor) is managed by OS The programs you write are also managed by OS 1. Controlling and monitoring system activities 2. Allocating and assigning system resources What are the tasks of OS? 3. Scheduling operations 12

Program Languages Instructions are specified using a computer programming language Three types of programming languages: Machine language Assembly language High-level language 13 Machine Language Set of primitive instructions built into every computer Instructions are in the form of binary code Why don t we use those languages? I wrote this awesome program: 10001110 No, no, no. It should be: 10000110 OK, hmm, sure, I ll just Geek 1 Geek 2 Just a human being 14 Assembly Language Developed to make programming easy The computer cannot understand assembly language Need to convert assembly code to machine code ADDF3 R1, R2, R3 15

High-Level Language English-like and easy to learn and program Can be understood by just looking at the code area = 5 * 5 * 3.1415; Required steps to produce byte code? 16 Compiling Source Code Source code A program written in a high-level language Compiler Used to translate the source program into a machine language program called an object program Linker Used to link your object program with supporting libraries 17 Some Popular High-Level Languages 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 will use this one!!!) 18

Java s History James Gosling and Sun Microsystems Java presented on May 20, 1995 during Sun World HotJava The first Java-enabled Web browser Why the name Java? Silk Lyric Pepper NetProse Neon Java DNA WebDancer WebSpinner WRL (WebRunner Languages) 19 Why Java? Applications for: Internet services (Java Applets, Java Web Applications) Desktop computers Hand-held devices Well-established and popular language Langpop.com 20 Characteristics of Java Java Is Object-Oriented Java Is Distributed Java Is Robust Java Is Architecture-Neutral Java Is Portable Java Is Secure Java Is Multithreaded 21

Characteristics of Java Java Is Object-Oriented Java Is Distributed Java Is Robust Java Is Architecture-Neutral Java Is Portable Java Is Secure Java Is Multithreaded Designed to be Object- Oriented Object-Oriented programming provides great flexibility, modularity, clarity, and reusability 22 Characteristics of Java Java Is Object-Oriented Java Is Distributed Java Is Robust Java Is Architecture-Neutral Java Is Portable Java Is Secure Java Is Multithreaded Distributed computing involves several computers working together on a network Designed to make distributed computing easy 23 Characteristics of Java Java Is Object-Oriented Java Is Distributed Java Is Robust Java Is Architecture-Neutral Java Is Portable Java Is Secure Java Is Multithreaded Compilers can detect many problems that would first show up at execution time in other languages A runtime exceptionhandling feature 24

Characteristics of Java Java Is Object-Oriented Java Is Distributed Java Is Robust Java Is Architecture-Neutral Java Is Portable Java Is Secure Java Is Multithreaded Write once, run anywhere 25 Characteristics of Java Java Is Object-Oriented Java Is Distributed Java Is Robust Java Is Architecture-Neutral Java Is Portable Java Is Secure Java Is Multithreaded Implements several security mechanisms to protect your system against harm caused by stray programs 26 Characteristics of Java Java Is Object-Oriented Java Is Distributed Java Is Robust Java Is Architecture-Neutral Java Is Portable Java Is Secure Java Is Multithreaded What is multithreading? Multithread programming is smoothly integrated 27

Review Questions what is a computer 1 is the physical aspect of the computer that can be seen. A. Hardware B. Software C. Operating system D. Application program 2 is the brain of a computer. A. Hardware B. CPU C. Memory D. Disk 3 Which of the following are input and output devices? A. Keyboard and mouse B. CPU C. flash stick D. Software Review questions computer programs 1 are instructions to the computer. A. Hardware B. Software C. Mouse D. Keyboards 2 Computer can execute the code in. A. machine language B. assembly language C. high-level language D. none of the above Java standard Language specification Syntax and semantics of Java language API (Application Program Interface) Predefined classes for developing java programs

JDK Editions 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. We will be using J2SE 31 JDK Versions 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 32 Creating, Compiling, and Running Programs Create/Modify Source Code Source code (developed by the programmer) public class Welcome { public static void main(string[] args) { System.out.println("Welcome to Java!"); Saved on the disk Source Code Byte code (generated by the compiler for JVM to read and interpret, not for you to understand) Method Welcome() 0 aload_0 Method void main(java.lang.string[]) 0 getstatic #2 3 ldc #3 <String "Welcome to Java!"> 5 invokevirtual #4 8return Compile Source Code i.e., javac Welcome.java If compilation errors stored on the disk Bytecode Run Byteode i.e., java Welcome Result If runtime errors or incorrect result 33

Programming Environment in Unix Unix operating system Command line interface (CLI) through shell window GNOME desktop environment Unix editors vi or Vim gedit Java compiler javac included in JDK Java Virtual Machine (JVM) java Understand Files and Folders Java source code are saved as.java files Files: a collection of items of information that are kept together Files have names, and the rules for legal names differ from one system to another Files are stored in folders or directories; these file containers can be nested Integrated Development Environment (IDE) IDE is a software application that provides comprehensive facilities for software development Source code editor Compiler and/or interpreter Debugger Popular IDEs Eclipse Open Source by IBM NetBeans Open Source by Sun Borland JBuilder 2007 36

Companion Website Programming environment in Windows See Supplement I.B for installing and configuring JDK See Supplement I.C for compiling and running Java from the command window for details www.cs.armstrong.edu/liang/intro7e A Simple Java Program Listing 1.1 //This program prints Welcome to Java! public class Welcome { public static void main(string[] args) { System.out.println("Welcome to Java!"); 38 Demo Create a source program with an editor gedit Welcome.java Save the program to hard disk Compile the program with a compiler javac Welcome.java Execute the program with java JVM java Welcome

Creating and Editing Using gedit To use gedit, type gedit Welcome.java from the shell 40 Trace a Program Execution Enter main method //This program prints Welcome to Java! public class Welcome { public static void main(string[] args) { System.out.println("Welcome to Java!"); 41 Trace a Program Execution Execute statement //This program prints Welcome to Java! public class Welcome { public static void main(string[] args) { System.out.println("Welcome to Java!"); 42

Trace a Program Execution //This program prints Welcome to Java! public class Welcome { public static void main(string[] args) { System.out.println("Welcome to Java!"); print a message to the console 43 Anatomy of a Java Program White spaces Comments Package Reserved words Modifiers Statements Blocks Classes Methods The main method 44 Comments Three types of comments Line comment //This is an example of line comment Paragraph comment /* This is an example of paragraph comment. It can have few lines */ Javadoc comment /** This is a Javadoc comment. */ 45

Package Packages help to organize code Package is always declared at the beginning of the code 46 Reserved Words Also known as keywords Words that have a specific meaning to the compiler Cannot be used for other purposes in the program 47 Modifiers Certain reserved words are called modifiers They specify the properties of the data, methods, and classes Examples of modifiers are public and static, private, final, abstract, and protected 48

Statements A statement represents an action or a sequence of actions Other statement: area = r * r *3.14 49 Blocks A pair of braces in a program forms a block that groups components of a program public class Test { public static void main(string[] args) { System.out.println("Welcome to Java!"); Method block Class block 50 Classes The class is the essential Java construct A class is a template or blueprint for objects We will learn a lot about classes later in the course class 51

Methods Method is a collection of statements Methods perform a sequences of operations Used by invoking a statement with a string argument The arguments are enclosed within parentheses and separated by commas 52 main Method The main method provides the control of program flow The Java interpreter executes the application by invoking the main method 53 Another example public class Welcome1 { public static void main(string[] args) { System.out.println( Programming is fun!"); System.out.println( Fundamentals first ); System.out.println( Problem driven ); 54

Class Exercise Write a Java program that displays a smiley face. //////////// 0 0 ^ U Displaying Text in a Message Dialog Box Java can be used to rapid application development For instance, you can create message dialog boxes very fast Simply use the showmessagedialog method in the JOptionPane class JOptionPane is one of the many predefined classes in the Java system 56 The showmessagedialog Method JOptionPane.showMessageDialog(null, "Welcome to Java!", "Display Message", JOptionPane.INFORMATION_MESSAGE); 57

Summary Computer architecture and components Programs and Programming languages Operating System Java advantages Programming environment The first Java program Binary and decimal number system (readings) 58