111 © 2002, Cisco Systems, Inc. All rights reserved.

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

1 G54PRG Programming Lecture 1 Amadeo Ascó Adam Moore G54PRG Programming Lecture 1 Amadeo Ascó 3 Java Programming Language.
Introduction To Java Objectives For Today â Introduction To Java â The Java Platform & The (JVM) Java Virtual Machine â Core Java (API) Application Programming.
Copyright © 2002 W. A. Tucker1 Chapter 1 Lecture Notes Bill Tucker Austin Community College COSC 1315.
Chapter 1: An Overview of Computers and Programming Languages J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design First Edition by Tony Gaddis.
1 Fall 2008ACS-1903 Chapter 1 Topics Java History Java Programs Why Program? Computer Systems: Hardware and Software Programming Languages What Is a Program.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Sixth Edition by Tony Gaddis, Judy Walters,
Java Programming, 3e Concepts and Techniques Chapter 1 An Introduction to Java and Program Design.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 1 Introduction.
1. 2 Chapter 1 Introduction to Computers, Programs, and Java.
Java How to Program, 9/e Instructor: José M. Reyes Álamo © by Pearson Education, Inc. All Rights Reserved.
1 CHAPTER 4 LANGUAGE/SOFTWARE Hardware Hardware is the machine itself and its various individual equipment. It includes all mechanical, electronic.
CSE 1301 J Lecture 2 Intro to Java Programming Richard Gesick.
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
CS102 Introduction to Computer Programming
 2003 Prentice Hall, Inc. All rights reserved. Chapter 1 – Introduction to Computers, the Internet, and the Web Outline 1.1 Introduction 1.2 What Is a.
Computer Programming-1 CSC 111 Chapter 1 : Introduction.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
Chapter Introduction to Computers and Programming 1.
CHAPTER 4: INTRODUCTION TO COMPUTER ORGANIZATION AND PROGRAMMING DESIGN Lec. Ghader Kurdi.
Java Programming, 2E Introductory Concepts and Techniques Chapter 1 An Introduction to Java and Program Design.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
CSC 142 A 1 CSC 142 Introduction to Java [Reading: chapter 0]
Chapter 1 Coding Introduction.
Programming Languages: Telling the Computers What to Do Chapter 16.
Chapter 1 An Overview of Computers and Programming Languages.
CSCI 224 Introduction to Java Programming. Course Objectives  Learn the Java programming language: Syntax, Idioms Patterns, Styles  Become comfortable.
COMPUTER SOFTWARE Section 2 “System Software: Computer System Management ” CHAPTER 4 Lecture-6/ T. Nouf Almujally 1.
Topics Introduction Hardware and Software How Computers Store Data
Chapter 1: Creating Java Programs
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.
Chapter 1.4 Programming languages Homework Due: Monday, August 11, 2014.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming 1.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Programming Languages Machine.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
What is a Computer? An, electrical machine, that can be programmed to accept data (input), process it into useful information (output) and store it away.
Computer Programming A program is a set of instructions a computer follows in order to perform a task. solve a problem Collectively, these instructions.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
1.8History of Java Java –Based on C and C++ –Originally developed in early 1991 for intelligent consumer electronic devices Market did not develop, project.
Java Programming, Second Edition Chapter One Creating Your First Java Program.
Visual C++ Programming: Concepts and Projects
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Chapter 1 Section 1.1 Introduction to Java Slides prepared by Rose Williams, Binghamton University Kenrick Mock, University of Alaska Anchorage.
Mrs. Ulshafer August, 2013 Java Programming Chapter 1.
School of Computer Science & Information Technology G6DICP Introduction to Computer Programming Milena Radenkovic.
What Is Java? According to Sun in a white paper: Java: A simple, object-oriented, network-savvy, interpreted, robust, secure, architecture-neutral, portable,
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. CSC 110 – INTRO TO COMPUTING - PROGRAMMING Overview of Programming.
Brief Version of Starting Out with C++ Chapter 1 Introduction to Computers and Programming.
Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design.
Chapter 1 An Overview of Computers and Programming Languages.
Chapter 1: Introduction to Computers and Programming.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 1 Introduction.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Java Programming Fifth Edition Chapter 1 Creating Your First Java Classes.
Programming Logic and Design Seventh Edition Chapter 1 An Overview of Computers and Programming.
Chapter 1 Coding Introduction.
Java Programming: From the Ground Up
CSCI-235 Micro-Computer Applications
Chapter 1 Introduction to Computers, Programs, and Java
Lecture 1: Introduction to JAVA
Java programming lecture one
Chapter 1 Coding Introduction.
CSC 142 Introduction to Java [Reading: chapters 1 & 2]
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:

111 © 2002, Cisco Systems, Inc. All rights reserved.

2 What Is Java? Chapter 1

333 © 2002, Cisco Systems, Inc. All rights reserved. Learning Objectives Computer basics What is a programming language? What is Java? The Java environment basics A Java program Entering data at runtime for the Java program Programming error messages Integrated development environments (IDEs)

444 © 2002, Cisco Systems, Inc. All rights reserved. Overview An introduction to the Java programming language How a computer operates Different programming techniques The history of Java and its popularity The elements of a Java program Creating and running a Java program

555 © 2002, Cisco Systems, Inc. All rights reserved. Overview (continued) Java is a dynamic and popular programming language. Java use has increased over the past 5 years. This course teaches the Java programming skills needed to create powerful applications and web-enabled programs. Students create a virtual bank, the JBANK, and its banking program.

666 © 2002, Cisco Systems, Inc. All rights reserved. Key Terms Hardware Software, programs, applications Procedural programming languages Object-oriented programming languages Compiler Interpreter Java Programming Language Java Virtual Machine (JVM) Source code

777 © 2002, Cisco Systems, Inc. All rights reserved. Key Terms (continued) Compile Runtime Bytecode javac Java keywords and symbols Java syntax Java 2 Software Development Toolkit (Java 2 SDK) Integrated development environment (IDE) BlueJ (a specific IDE)

888 © 2002, Cisco Systems, Inc. All rights reserved. Mechanical Computers

999 © 2002, Cisco Systems, Inc. All rights reserved. Computer Hardware All computers consist of three basic parts: –Central processing unit (CPU) –Memory –Electronic components and subassemblies: Keyboard Mouse Monitor Printer

10 © 2002, Cisco Systems, Inc. All rights reserved. Software Software is a collection of instructions that tell the hardware how to behave. Types of software: Operating system software Application software

11 © 2002, Cisco Systems, Inc. All rights reserved. Ways to Obtain Software Buy software Modify pre-existing software (if the license permits) Write individual software

12 © 2002, Cisco Systems, Inc. All rights reserved. Applications A collection of computer programs Examples: Word processors, Internet browsers, and computer games Contain programs that instruct a computer how to process data into meaningful information Receive messages from the user to perform some task and send messages to the user with the results of that task

13 © 2002, Cisco Systems, Inc. All rights reserved. Operating Systems A collection of programs that directly control the hardware. Developed to separate the tasks of controlling the hardware from the tasks specifically associated with the application. Building blocks for applications. Windowing operating systems were developed to simplify the ways people interact with a computer.

14 © 2002, Cisco Systems, Inc. All rights reserved. Programming Language Programming language is the language used to write computer programs. There are many computer languages. Choosing which computer language to use for a particular program depends on the following: –Programmer’s knowledge of that language –Development tools available –Computer hardware –Type of problem being solved

15 © 2002, Cisco Systems, Inc. All rights reserved. Switches, 1s, and 0s Programming languages must be understood by the computer. At the hardware level, the computer is nothing more than thousands of switches quickly flipping on and off: A computer understands only the states of switches, represented as 0s and 1s.

16 © 2002, Cisco Systems, Inc. All rights reserved. Early Programming Languages Writing instructions in binary was very tedious. Programming languages are a bridge between the binary language of the computer and the written word of humans. Early languages used mnemonics, one or more symbols representing a set of binary instructions Early languages were called machine language or assembler language and are now referred to as low-level languages.

17 © 2002, Cisco Systems, Inc. All rights reserved. M nemonics Communications A special software program was needed to translate the assembly language programs into the binary language of the computer. These translation programs became known as assemblers.

18 © 2002, Cisco Systems, Inc. All rights reserved. High-Level Programming Languages Need for high-level languages to quickly and efficiently write computer programs for complex applications Included words or abbreviations that were recognizable by English speakers Required translator programs to convert the high-level instructions into binary instructions Used a linear approach problem solving called procedural programming Developed libraries known as application program interfaces (APIs)

19 © 2002, Cisco Systems, Inc. All rights reserved. Object-Oriented Programming Most business problems are multifaceted and do not lend themselves well to procedural programming. Object-oriented programming (OOP) more closely reflects the problem-solving approach used by people. OOP breaks the problem into parts, defined as objects, which perform specific functions. Objects interact by sending and receiving messages. OOP advances software reuse and maintainability. and working objects and program.

20 © 2002, Cisco Systems, Inc. All rights reserved. Basic Language Elements All programming languages have five common elements: –Vocabulary –Punctuation –Identifiers –Operators –Syntax Programs are saved on the hard disk in a file called the source file, which contains the source code of the program. Source code must follow all the rules of spelling, syntax, and punctuation of the programming language.

21 © 2002, Cisco Systems, Inc. All rights reserved. Compiled Languages A compiler is a program that converts the entire source code file into the binary language of a particular computer. Each compiler is specifically designed to translate source code to meet the native language specifications of a particular computer. The file containing the compiled code is also known as an executable file. The program runs only after every instruction has been compiled correctly.

22 © 2002, Cisco Systems, Inc. All rights reserved. Interpreted Languages The computer analyzes each instruction in the source code file as the program runs (or is executed) on the computer. The language interpreter converts instructions in the source file to native code for that computer and executes them individually. The interpreter must re-analyze and convert repeated instructions into native code before executing them—a disadvantage. Examples include JavaScript, VBScript, and HTML.

23 © 2002, Cisco Systems, Inc. All rights reserved. Historical Background of Java Java was developed at Sun Microsystems by Patrick Naughton and James Gosling. Design goals included the following: –Able to run on many different processors –Create programs that were small and efficient –Easy to program Java 1.0 was released in “A simple, object-oriented, network-savvy, interpreted, robust, secure, architecture-neutral, portable, high-performance, multithreaded, dynamic language". Java is a dynamic and evolving language.

24 © 2002, Cisco Systems, Inc. All rights reserved. Java Terms Simple Object oriented Distributed Robust Secure Architecture neutral and portable Interpreted Multithreaded Dynamic

25 © 2002, Cisco Systems, Inc. All rights reserved. Java Development and Runtime Environment

26 © 2002, Cisco Systems, Inc. All rights reserved. Java Virtual Machine (JVM) The JVM is a program that handles the communication between the Java application and the hardware and operating system. The Java programmer writes programs that are understood by the JVM. This code is translated by the JVM into code that is understood by the specific hardware and operating system. Prior to virtual machines, programmers had to rewrite their programs for each specific type of CPU and operating system. Today there are JVMs for most operating systems, including Solaris, Windows, Linux, and MacOS.

27 © 2002, Cisco Systems, Inc. All rights reserved. Understanding the Java Virtual Machine A Java programmer writes a source code file of Java code and compiles the code using a Java compiler. The Java compiler translates the program into bytecode that is understood by the JVM, not native code that is understood by a specific computer. The JVM translates bytecode into binary code (native code or processor code) for the specific CPU that is used to run the program. The JVM is an interpreter for the bytecode, not a compiler for the bytecode.

28 © 2002, Cisco Systems, Inc. All rights reserved. Understanding the Java Virtual Machine The Java compiler converts source code to bytecode:

29 © 2002, Cisco Systems, Inc. All rights reserved. Understanding the Java Virtual Machine The JVM converts bytecode to machine code (processor code) for the specific CPU:

30 © 2002, Cisco Systems, Inc. All rights reserved. Running a Java Program Three steps are needed to create and run a Java program: 1.Create a source file. 2.Compile the source file into bytecode; for instance: 3.Run the program.

31 © 2002, Cisco Systems, Inc. All rights reserved. Resources to Create a Java Program Editor - can be a program as simple as the Notepad program, or an integrated development environment (IDE) software program such as BlueJ. Compiler and JVM - Sun Microsystems provides a rich set of tools for developing and running Java programs, including a compiler and JVM. These resources form the Java Development Toolkit (JDK).

32 © 2002, Cisco Systems, Inc. All rights reserved. Java Development Toolkit (JDK) The JDK provides all the tools (such as programs) that are needed to develop a Java program. All the tools supplied in the JDK only run in a command-line window. The two tools to become familiar with are javac, the Java Compiler, and java, the JVM.

33 © 2002, Cisco Systems, Inc. All rights reserved. Elements of a simple Java program

34 © 2002, Cisco Systems, Inc. All rights reserved. Three Steps to Create and Execute a Java Program - SayHello 1.Create the source code using an editor. The source code is stored in the SayHello.java file. 2.Compile the source code to create the bytecode using the program javac ( javac SayHello.java ). The bytecode is stored in the SayHello.class file. 3.Run the program by typing the command java SayHello. The results of the program display.

35 © 2002, Cisco Systems, Inc. All rights reserved. Modifying Input a Runtime The console program takes all the text on the command line and interprets the first word as the name of a program and the rest of the words as input parameters for that program.

36 © 2002, Cisco Systems, Inc. All rights reserved. Programming Errors Compiler errors - Detected by the compiler and prevent the compiler from creating the class file. Runtime errors - Occur when the program is executed, after all the compiler errors have been corrected. Logic errors - Not detected by the compiler. The program functions, but does not produce the intended result.

37 © 2002, Cisco Systems, Inc. All rights reserved. Compiler Errors Common compiler errors: –Java keywords or class names misspelled –Inconsistently referencing identifiers –Forgetting to close braces {}, brackets [], or parentheses ( ) –Missing the dot operator (.) –Missing semicolons (;)

38 © 2002, Cisco Systems, Inc. All rights reserved. Integrated Development Environment (IDE) IDEs may integrate: – A word processor. – A Software Development Kit (SDK). – A window to display results. – Tools to create graphical user interfaces (GUIs). – Many IDEs enable the programmer to plan the application using simple symbols and a graphical interface. – Unified Modeling Language (UML) is a language to model object-oriented programs.

39 © 2002, Cisco Systems, Inc. All rights reserved. The BlueJ IDE

40 © 2002, Cisco Systems, Inc. All rights reserved. The BlueJ Tutorial

41 © 2002, Cisco Systems, Inc. All rights reserved. Summary A computer program is a set of instructions for a computer to perform. Procedural programming languages, such as Fortran and COBOL, are coded with linear logic. Object-oriented languages, such as Java, break the program into objects, each of which performs a specific function within the program. Java is both compiled and interpreted. The javac command is used to compile the code. The java command is then used to interpret and execute the code.

42 © 2002, Cisco Systems, Inc. All rights reserved. Summary (continued) BlueJ is an effective IDE to create Java programs and learn the Java language. Java language elements include vocabulary, punctuation, identifiers, operators, and a syntax. The Java programming language includes a rich library of classes that form the Java language API. Errors identified by the compiler are compiler errors. Runtime errors are caused by exceptions that occur in the normal flow of the program. Logic errors occur if the program does not perform correctly. Correcting errors is a programmer's responsibility.

43 © 2002, Cisco Systems, Inc. All rights reserved.