Fall 2006Slides adapted from Java Concepts companion slides1 Introduction Advanced Programming ICOM 4015 Lecture 1 Reading: Java Concepts Chapter 1.

Slides:



Advertisements
Similar presentations
Designing a Program & the Java Programming Language
Advertisements

INTRODUCTION Chapter 1 1. Java CPSC 1100 University of Tennessee at Chattanooga 2  Difference between Visual Logic & Java  Lots  Visual Logic Flowcharts.
Object Oriented Programming in Java George Mason University Fall 2011
JAVA BASICS SYNTAX, ERRORS, AND DEBUGGING. GCOC – A.P. Computer Science A College Board Computer Science A Topics Covered Program Design - Read and understand.
 2005 Pearson Education, Inc. All rights reserved Introduction.
Chapter 1: Introduction
Chapter 1 These slides for CSE 110 Sections are based in part on the textbook-authors’ slides, which are copyright by the authors. The authors state that.
The Java Programming Language  Simple – but abstract  Safe  Platform-independent ("write once, run anywhere")  Has a Rich growing library  Designed.
Slides prepared by Rose Williams, Binghamton University Chapter 1 Getting Started 1.1 Introduction to Java.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design First Edition by Tony Gaddis.
How do we make our HelloTester.java program do something? The java in our HelloTester.java file won’t do anything by itself. We need to tell the computer.
CHAPTER 1 INTRODUCTION GOALS  To understand the activity of programming  To learn about the architecture of computers  To learn about machine code and.
Aalborg Media Lab 21-Jun-15 Software Design Lecture 1 “ Introduction to Java and OOP”
1 Programming Languages Translation  Lecture Objectives:  Be able to list and explain five features of the Java programming language.  Be able to explain.
1 Programming & Programming Languages Overview l Machine operations and machine language. l Example of machine language. l Different types of processor.
1. 2 Chapter 1 Introduction to Computers, Programs, and Java.
CSE 1301 J Lecture 2 Intro to Java Programming Richard Gesick.
Chapter 1 - Introduction. Ch 1Goals To understand the activity of programming To learn about the architecture of computers To learn about machine code.
IB Computer Science II Paul Bui
Computer Programming 12 Mr. Jean March 3 rd, 2014.
Computer Science 1710: Object- Oriented Programming 1 Spring 2007 Instructor: Andrew Vardy.
CHAPTER 4: INTRODUCTION TO COMPUTER ORGANIZATION AND PROGRAMMING DESIGN Lec. Ghader Kurdi.
A First Program Using C#
Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design.
Week 1 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
An intro to programming. The purpose of writing a program is to solve a problem or take advantage of an opportunity Consists of multiple steps:  Understanding.
Big Java by Cay Horstmann Copyright © 2008 by John Wiley & Sons. All rights reserved. Chapter One: Introduction.
Week 1 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
Introduction to Computers and Java Chapter 1.3. A Sip of Java: Outline History of the Java Language Applets A First Java Program Compiling a Java Program.
©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 1 Chapter 1 Introduction.
Chapter 1 Introduction. Goal to learn about computers and programming to compile and run your first Java program to recognize compile-time and run-time.
Session One Introduction. Personal Introduction Role of programmers Robot Examination HUD & HID Uploading Code.
Chapter 1 CSIS-120: Java Intro. What is Programming?  A: It is what makes computer so useful.  The flexibility of a computer is amazing  Write a term.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved. Chapter 1 – Introduction.
Jaeki Song ISQS6337 JAVA Lecture 03 Introduction to Java -The First Java Application-
© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various.
Chapter 1: Introduction to Programs, and Java 1. Objectives To review programs (§ ). To understand the relationship between Java and the World Wide.
ICOM 4015: Advanced Programming Lecture 1 Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved. Reading: Chapter One: Introduction.
Programming Concept Chapter I Introduction to Java Programming.
Big Java by Cay Horstmann Copyright © 2008 by John Wiley & Sons. All rights reserved. Chapter One: Introduction.
Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved. Chapter 1 – Introduction ( ปรับปรุง )
Copyright © 2014 by John Wiley & Sons. All rights reserved.1 Chapter 1 - Introduction.
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
Chapter 1 Section 1.1 Introduction to Java Slides prepared by Rose Williams, Binghamton University Kenrick Mock, University of Alaska Anchorage.
CHAPTER 1 INTRODUCTION. CHAPTER GOALS To understand the activity of programming To understand the activity of programming To learn about the architecture.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Jens Dalsgaard Nielsen Jan Dimon Bendtsen Dept. of Electronic Systems Basic Programming INS-basis GF, PDP and HST.
© 2004 Pearson Addison-Wesley. All rights reserved ComS 207: Programming I Instructor: Alexander Stoytchev
JAVA Practical Creating our first program 2. Source code file 3. Class file 4. Understanding the different parts of our program 5. Escape characters.
INM205 Object Oriented Programming in JAVA Dr. Michael Casey Department of Computing.
Chapter 1 Introduction. Chapter Goals To understand the activity of programming To learn about the architecture of computers To learn about machine code.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
CHAPTER 1 INTRODUCTION. CHAPTER GOALS To understand the activity of programming To learn about the architecture of computers To learn about machine code.
Lecture1 Instructor: Amal Hussain ALshardy. Introduce students to the basics of writing software programs including variables, types, arrays, control.
Chapter 1 - Introduction. Announcements Info Sheet Web Site: Lab Hours NotecardsPictures.
Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design.
ITP 109 Week 2 Trina Gregory Introduction to Java.
CS 201 Lecture 1 (b) Using an IDE Tarik Booker CS 201: Introduction to Programming California State University, Los Angeles.
Chapter 1 – Introduction
Introduction To recognize compile-time and run-time errors
John Woodward A Simple Program – Hello world
GC101 Introduction to computer and program
Chapter 1 Introduction to Computers, Programs, and Java
Chapter Goals To learn about computers and programming
Chapter 1 – Introduction
Java programming lecture one
IB Computer Science II Paul Bui
Computer Programming-1 CSC 111
IS 135 Business Programming
Presentation transcript:

Fall 2006Slides adapted from Java Concepts companion slides1 Introduction Advanced Programming ICOM 4015 Lecture 1 Reading: Java Concepts Chapter 1

Fall 2006Slides adapted from Java Concepts companion slides2 Lecture Goals To understand the activity of programming 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

Fall 2006Slides adapted from Java Concepts companion slides3 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

Fall 2006Slides adapted from Java Concepts companion slides4 Important Characteristics of a Computer Can store large amount of data  Instructions to be executed (programs)  Data to operate with Can execute very simple instructions from a predetermined set of possible instructions  Access particular data in memory (read)  Store data in memory (write)  Operate with data in CPU Perform logical/arithmetic operations  Make data available to an external source  Get data from an external source Executes instructions fast – millions per second… Instructions must be provided in native language (machine language)

Fall 2006Slides adapted from Java Concepts companion slides5 Machine Instructions Need to be coded following a very specific format (machine language)  Very detailed  Each instruction performs a simple task General categories of machine instructions:  Control instructions – tell the computer what to do next  Data handling instructions – operate on data stored, or to be stored, in the computer’s memory Alter data Compute new data Write data to memory Read data from memory Write data to an external device (output) Read data from an external device (input)

Fall 2006Slides adapted from Java Concepts companion slides6 Instruction Execution Instruction is read from memory Instruction is placed in special register in CPU Signals are initiated to activate required computer components to perform a particular task  These correspond to the purpose of the instruction Instructions are execute sequentially (except in parallel architectures)  Only one instruction at a time  When an instruction is finished, the next instruction in the sequence is executed Except in the case of control instructions that may alter the sequence of instructions to execute.

Fall 2006Slides adapted from Java Concepts companion slides7 Machine Code Java Virtual Machine (JVM) – a typical sequence of machine instructions is: 1.Load the contents of memory location Load the value If the first value is greater than the second value, continue with the instruction that is stored in memory location 240. Machine instructions are encoded as numbers: Continued…

Fall 2006Slides adapted from Java Concepts companion slides8 Machine Code Compiler translates high-level language to machine code

Fall 2006Slides adapted from Java Concepts companion slides9 Self Check 1.What is the code for the Java virtual machine instruction "Load the contents of memory location 100"? 2.Does a person who uses a computer for office work ever run a compiler?

Fall 2006Slides adapted from Java Concepts companion slides10 Answers No–a compiler is intended for programmers, to translate high-level programming instructions into machine code.

Fall 2006Slides adapted from Java Concepts companion slides11 Programming Languages Machine/Virtual Machine Assembler iload intRate bipush 100 if_icmpgt intError High-level language if (intRate > 100)...

Fall 2006Slides adapted from Java Concepts companion slides12 Common Approach with High-Level Language Programs Compiling process (if no grammar errors) Machine Code Program P in language L Machine M1Machine M2 Compiler program for L (in M1) Compiler program for L (in M2) Program P in machine language of M1 Program P in machine language of M2 Program P in language L produces same machine dependable

Fall 2006Slides adapted from Java Concepts companion slides13 Program P in language Java Machine M1Machine M2 Compiler program for Java (in M1) Compiler program for Java (in M2) Compiling process Program P in machine language of JVM Program P in machine language of JVM Program P in language Java produces same JVM in M1JVM in M2 Machine dependable Machine dependable (if no grammar errors) Machine Code Can be executed in any JVM Approach Followed by Java System

Fall 2006Slides adapted from Java Concepts companion slides14 The Java Programming Language Simple Safe Platform-independent ("write once, run anywhere") Rich library (packages) Designed for the internet

Fall 2006Slides adapted from Java Concepts companion slides15 Applets on a Web Page Figure 7: Applets on a Web Page

Fall 2006Slides adapted from Java Concepts companion slides16 Self Check 1.What are the two most important benefits of the Java language? 2.How long does it take to learn the entire Java library?

Fall 2006Slides adapted from Java Concepts companion slides17 Answers 1.Safety and portability. 2.No one person can learn the entire library–it is too large.

Fall 2006Slides adapted from Java Concepts companion slides18 Becoming Familiar with your Computer 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 Continued…

Fall 2006Slides adapted from Java Concepts companion slides19 Becoming Familiar with your Computer Write a simple program (later) Save your work  Develop a strategy for keeping backup copies of your work

Fall 2006Slides adapted from Java Concepts companion slides20 A Shell Window Figure 8: A Shell Window

Fall 2006Slides adapted from Java Concepts companion slides21 An Integrated Development Environment Figure 9: An Integrated Development Environment

Fall 2006Slides adapted from Java Concepts companion slides22 Nested Folders Figure 10: Nested Folders

Fall 2006Slides adapted from Java Concepts companion slides23 Self Check 1.How are programming projects stored on a computer? 2.What do you do to protect yourself from data loss when you work on programming projects?

Fall 2006Slides adapted from Java Concepts companion slides24 Answers 1.Programs are stored in files, and files are stored in folders or directories. 2.You back up your files and folders.

Fall 2006Slides adapted from Java Concepts companion slides25 File HelloTester.java 1: public class HelloTester 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!

Fall 2006Slides adapted from Java Concepts companion slides26 HelloTester in a Console Window Figure 11: Running the HelloTester Program in a Console Window

Fall 2006Slides adapted from Java Concepts companion slides27 HelloTester in an IDE Figure 12: Running the HelloTester Program in an Integrated Development Environment

Fall 2006Slides adapted from Java Concepts companion slides28 A Simple Program Figure 13: Calling a Method System Class System.out Object println Method public class ClassName public static void main(String[] args) // comment Method call

Fall 2006Slides adapted from Java Concepts companion slides29 Syntax 1.1: Method Call object.methodName(parameters) Example: System.out.println("Hello, Dave!"); Purpose: To invoke a method of an object and supply any additional parameters

Fall 2006Slides adapted from Java Concepts companion slides30 Self Check 1.How would you modify the HelloTester program to print the words "Hello," and "World!" on two lines? 2.Would the program continue to work if you omitted the line starting with // ? 3.What does the following set of statements print? System.out.print("My lucky number is"); System.out.println( );

Fall 2006Slides adapted from Java Concepts companion slides31 Answers 1. 2.Yes–the line starting with // is a comment, intended for human readers. The compiler ignores comments. 3.The printout is My lucky number is12. It would be a good idea to add a space after the is. System.out.println("Hello,"); System.out.println("World");

Fall 2006Slides adapted from Java Concepts companion slides32 Errors Syntax errors Detected by the compiler Logic errors Detected (hopefully) through testing System.ouch.print("..."); System.out.print("Hello); System.out.print("Hell");

Fall 2006Slides adapted from Java Concepts companion slides33 Self Check 1.Suppose you omit the // characters from the HelloTester.java program but not the remainder of the comment. Will you get a compile-time error or a run-time error? 2.How can you find logic errors in a program?

Fall 2006Slides adapted from Java Concepts companion slides34 Answers 1.A compile-time error. The compiler will not know what to do with the word display. 2.You need to run the program and observe its behavior.

Fall 2006Slides adapted from Java Concepts companion slides35 The Compilation Process Figure 14: From Source Code to Running Program

Fall 2006Slides adapted from Java Concepts companion slides36 The Edit—Compile—Loop Test Figure 15: The Edit—Compile—Loop Test

Fall 2006Slides adapted from Java Concepts companion slides37 Self Check 1.What do you expect to see when you load a class file into your text editor? 2.Why can't you test a program for run-time errors when it has compiler errors?

Fall 2006Slides adapted from Java Concepts companion slides38 Answers 1.A sequence of random characters, some funny-looking. Class files contain virtual machine instructions that are encoded as binary numbers. 2.When a program has compiler errors, no class file is produced, and there is nothing to run.