Chapter Goals. Chapter One: Introduction. Prerequisites. What Is Programming?

Similar documents
2/9/2012. Chapter One: Introduction. Chapter Goals

ICOM 4015: Advanced Programming

Chapter 1 - Introduction. Copyright 2014 by John Wiley & Sons. All rights reserved. 1

From Algorithms to Architecture....a lightning introduction to computer architecture

Introduction. Chapter CHAPTER GOALS. To understand the activity of programming. To learn about the architecture of computers

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

Chapter Goals. Contents INTRODUCTION

Which statement regarding computer programs is correct? Which statement best describes a computer program?

CSc 2010 Principles of Computer Science, Fall 2013 Practice Problems for Midterm 3* * 3 17 % 9-20 % (26 / 7) "2"

Week 2: Data and Output

COSC 123 Computer Creativity. Introduction to Java. Dr. Ramon Lawrence University of British Columbia Okanagan

CHAPTER INTRODUCTION

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

Introduction. Chapter1

Java: Comment Text. Introduction. Concepts

SDKs - Eclipse. SENG 403, Tutorial 2

Introduction to Computers and Java

! Learn how to think like a computer scientist. ! Learn problem solving. ! Read and write code. ! Understand object oriented programming

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

13 th Windsor Regional Secondary School Computer Programming Competition

Introduction to Computers and Java

Introduction to Java

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

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 Software Development (ISD) David Weston and Igor Razgon

Tutorial 1 CSC 201. Java Programming Concepts عؾادئماظربجمةمبادؿكدامماجلاصا

5/3/2006. Today! HelloWorld in BlueJ. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont.

Interpreted vs Compiled. Java Compile. Classes, Objects, and Methods. Hello World 10/6/2016. Python Interpreted. Java Compiled

Java Programming Fundamentals - Day Instructor: Jason Yoon Website:

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

Computer Hardware and Software Introduction. Mr. Smith AP Computer Science A

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

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

Project 1. Java Control Structures 1/17/2014. Project 1 and Java Intro. Project 1 (2) To familiarize with

Introduction To Java. Chapter 1. Origins of the Java Language. Origins of the Java Language. Objects and Methods. Origins of the Java Language

Chapter 1 Introduction to Computers, Programs, and Java

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

Java Programming Constructs Java Programming 2 Lesson 1

A PROGRAM IS A SEQUENCE of instructions that a computer can execute to

CS 11 java track: lecture 1

Lecture 2. COMP1406/1006 (the Java course) Fall M. Jason Hinek Carleton University

CompSci 125 Lecture 02

Introduction to Computers and Java

Course Outline. Introduction to java

Read Me First! Start Here. Read Me First! Start Here.

CSCI 161: Introduction to Programming I Lab 1b: Hello, World (Eclipse, Java)

3 CREATING YOUR FIRST JAVA APPLICATION (USING WINDOWS)

Introduction to Computers and Java

CS106A, Stanford Handout #25. Methods 2

Lesson 01 Introduction

You should see something like this, called the prompt :

First Java Program - Output to the Screen

Creating a Program in JCreator. JCreator is then used to create our program. But the first step is to create a new file.

Java Basics Lecture: January 26, 2012 (On-line Lecture 1)

CHAPTER 1 Introduction to Computers and Java

Introduction Basic elements of Java

COMP-202: Foundations of Programming. Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2016

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

Code Ninjas: Introduction to Computer Science. Macomb Science Olympiad Presented by Swati Dharia

CPS109 Lab 1. i. To become familiar with the Ryerson Computer Science laboratory environment.

What did we talk about last time? Examples switch statements

Introduction to Java. Java Programs Classes, Methods, and Statements Comments Strings Escape Sequences Identifiers Keywords

Just Enough Eclipse What is Eclipse(TM)? Why is it important? What is this tutorial about?

Introduction to Computers and Java

Chapter 1 Introduction to java

Chapter 1 Introduction to Computers, Programs, and Java

How to make a "hello world" program in Java with Eclipse *

1. Java is the fastest growing programming language in the world.

CS 152: Data Structures with Java Hello World with the IntelliJ IDE

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG

These two items are all you'll need to write your first application reading instructions in English.

Software Practice 1 Basic Grammar

Welcome to CSSE 220. We are excited that you are here:

Instructions PLEASE READ (notice bold and underlined phrases)

CS125 : Introduction to Computer Science. Lecture Notes #4 Type Checking, Input/Output, and Programming Style

1. A folder inside a folder is called. a) Mini Directory b) Sub Directory c) Root Folder d) Child Folder e) None of these

Lab5. Wooseok Kim

Topics. Hardware and Software. Introduction. Main Memory. The CPU 9/21/2014. Introduction to Computers and Programming

Pace University. Fundamental Concepts of CS121 1

Do this by creating on the m: drive (Accessed via start menu link Computer [The m: drive has your login id as name]) the subdirectory CI101.

Chapter 1 INTRODUCTION

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

Introduction to Object Oriented Systems Development. Practical Session (Week 2)

Chapter 2: Programming Concepts

Programming in Java Prof. Debasis Samanta Department of Computer Science Engineering Indian Institute of Technology, Kharagpur

AP Computer Science A: Java Programming

S8352: Java From the Very Beginning Part I - Exercises

Chapter 1 Introduction to Java

double float char In a method: final typename variablename = expression ;

Darrell Bethea May 10, MTWRF 9:45-11:15 AM Sitterson 011

C02: Overview of Software Development and Java

CMSC 150 LECTURE 1 INTRODUCTION TO COURSE COMPUTER SCIENCE HELLO WORLD

Certified Core Java Developer VS-1036

Java Programming Fundamentals

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I

Building Java Programs

ECE 161 WEEK 4 Introduction to Programing in Java

Transcription:

Chapter Goals To understand the activity of programming To learn about the architecture of computers To learn about machine code and high level programming languages To become familiar with your computing environment and your compiler To compile and run your first Java program To recognize syntax and logic errors Chapter One: Introduction Prerequisites Computer savvy (file management, text editing) Problem solving skills Time management High school math (algebra, trigonometry) No prior programming background required What Is Programming? Computers are programmed to perform tasks Different tasks = different programs Program Sequence of basic operations executed in succession Contains instruction sequences for all tasks it can execute Sophisticated programs require teams of highly skilled programmers and other professionals Self Check 1.1 What is required to play a music CD on a computer? Answer: A program that reads the data on the CD and sends output to the speakers and the screen. Self Check 1.2 Why is a CD player less flexible than a computer? Answer: A CD player can do one thing play music CDs. It cannot execute programs. 1

Self Check 1.3 Can a computer program develop the initiative to execute tasks in a better way than its programmers envisioned? Answer: No the program simply executes the instruction sequences that the programmers have prepared in advance. The Anatomy of a Computer Central processing unit Chip Transistors Storage Primary storage: Random-access memory (RAM) Secondary storage: e.g. hard disk Removable storage devices: e.g.: floppy disks, tapes, CDs Peripherals Executes very simple instructions Executes instructions very rapidly General purpose device Central Processing Unit A Memory Module with Memory Chips A Hard Disk A Motherboard 2

Schematic Diagram of a Computer The ENIAC Self Check 1.4 Where is a program stored when it is not currently running? Answer: In secondary storage, typically a hard disk. Self Check 1.5 Which part of the computer carries out arithmetic operations, such as addition and multiplication? Answer: The central processing unit. Machine Code Java Virtual Machine (JVM) a typical sequence of machine instructions is: 1. Load the contents of memory location 40. 2. Load the value 100. 3. If the first value is greater than the second value, continue with the instruction that is stored in memory location 240. Self Check 1.6 What is the code for the Java virtual machine instruction "Load the contents of memory location 100"? Answer: 21 100 Machine instructions are encoded as numbers: 21 40 16 100 163 240 Compiler translates high-level language to machine code 3

Self Check 1.7 Does a person who uses a computer for office work ever run a compiler? Answer: No a compiler is intended for programmers, to translate high-level programming instructions into machine code. The Java Programming Language Simple Safe Platform-independent ("write once, run anywhere") Rich library (packages) Designed for the internet Applets on a Web Page Java Versions Version 1.0 1.1 1.2 1.3 1.4 5 6 Year 1996 1997 1998 2000 2002 2004 2006 Important New Features Inner classes Swing, Collections Performance enhancements Assertions, XML Generic classes, enhanced for loop, auto-boxing, enumerations Library improvements Self Check 1.8 What are the two most important benefits of the Java language? Answer: Safety and portability. Self Check 1.9 How long does it take to learn the entire Java library? Answer: No one person can learn the entire library it is too large. 4

Becoming Familiar with your Computer A Shell Window Log in Locate the Java compiler Understand files and folders Programs are kept in files File: 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 Write a simple program (later) Save your work Develop a strategy for keeping backup copies of your work An Integrated Development Environment Nested Folders Self Check 1.10 How are programming projects stored on a computer? Answer: Programs are stored in files, and files are stored in folders or directories. Self Check 1.11 What do you do to protect yourself from data loss when you work on programming projects? Answer: You back up your files and folders. 5

ch01/hello/helloprinter.java HelloPrinter in a Console Window 1: public class HelloPrinter 2: { 3: public static void main(string[] args) 4: { 5: // Display a greeting in the console window 6: 7: System.out.println("Hello, World!"); 8: } 9: } Output: Hello, World! HelloPrinter in an IDE A Simple Program public class ClassName public static void main(string[] args) // comment Method call System class System.out object println method Syntax 1.1 Method Call object.methodname(parameters) Example: System.out.println("Hello, Dave!"); Purpose: Self Check 1.12 How would you modify the HelloPrinter program to print the words "Hello," and "World!" on two lines? Answer: System.out.println("Hello,"); System.out.println("World!"); To invoke a method of an object and supply any additional parameters. 6

Self Check 1.13 Would the program continue to work if you omitted the line starting with //? Answer: Yes the line starting with // is a comment, intended for human readers. The compiler ignores comments. Self Check 1.14 What does the following set of statements print? System.out.print("My lucky number is"); System.out.println(3 + 4 + 5); Answer: The printout is My lucky number is12 It would be a good idea to add a space after the is. Errors Syntax errors System.ouch.print("..."); System.out.print("Hello); Detected by the compiler Logic errors System.out.print("Hell"); Self Check 1.15 Suppose you omit the // characters from the HelloPrinter.java program but not the remainder of the comment. Will you get a compile-time error or a run-time error? Answer: A compile-time error. The compiler will not know what to do with the word Display. Detected (hopefully) through testing Self Check 1.16 The Compilation Process How can you find logic errors in a program? Answer: You need to run the program and observe its behavior. 7

The Edit-Compile-Test Loop Self Check 1.17 What do you expect to see when you load a class file into your text editor? Answer: A sequence of random characters, some funnylooking. Class files contain virtual machine instructions that are encoded as binary numbers. Self Check 1.18 Why can't you test a program for run-time errors when it has compiler errors? Answer: When a program has compiler errors, no class file is produced, and there is nothing to run. 8