An Introduction to Software Development Java Methods A & AB Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin Copyright © 2006.

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

Designing a Program & the Java Programming Language
A Programmer's Introduction to Java - from a S/370 user (c) IDMS/SQL News
In Review JAVA C++ GUIs - Windows Webopedia.com.
Introduction To Java Objectives For Today â Introduction To Java â The Java Platform & The (JVM) Java Virtual Machine â Core Java (API) Application Programming.
Lab#1 (14/3/1431h) Introduction To java programming cs425
Slides prepared by Rose Williams, Binghamton University Chapter 1 Getting Started 1.1 Introduction to Java.
Java Programming, 3e Concepts and Techniques Chapter 1 An Introduction to Java and Program Design.
1. 2 Chapter 1 Introduction to Computers, Programs, and Java.
PHY281Introduction to JavaSlide 1 Introduction to Java In this section we will learn how how to use Java and write our first Java Applet:  The Java Development.
CSE 1301 J Lecture 2 Intro to Java Programming Richard Gesick.
L EC. 01: J AVA FUNDAMENTALS Fall Java Programming.
1 Building Java Programs Chapter 1: Introduction to Java Programming These lecture notes are copyright (C) Marty Stepp and Stuart Reges, They may.
Developing User Interfaces (DUI) Chris North cs3724: HCI.
Your Interactive Guide to the Digital World Discovering Computers 2012.
Java Programming, 2E Introductory Concepts and Techniques Chapter 1 An Introduction to Java and Program Design.
Java Programming, 2E Introductory Concepts and Techniques Chapter 2 Creating a Java Application and Applet.
CSC 142 A 1 CSC 142 Introduction to Java [Reading: chapter 0]
Programming Languages: Telling the Computers What to Do Chapter 16.
From BlueJ to NetBeans SWC 2.semester.
CS413: Java Programming language Applications Applets
Java Workshop for Teachers May 6, 2005 A Brief Look at the Java Programming Language.
COMPUTER PROGRAMMING Source: Computing Concepts (the I-series) by Haag, Cummings, and Rhea, McGraw-Hill/Irwin, 2002.
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.
111 © 2002, Cisco Systems, Inc. All rights reserved.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
An Introduction to Software Development Using JAVA
Jaeki Song ISQS6337 JAVA Lecture 03 Introduction to Java -The First Java Application-
Java Programming, Second Edition Chapter One Creating Your First Java Program.
Programming Concept Chapter I Introduction to Java Programming.
Java Introduction 1. Introduction to Java Programming2 Computers and Computer Languages Computers are everywhere –how many computers do you own? Computers.
Clement Allen, PhD Florida A&M University SUMMER 2006.
1 Programming Fundamentals AITI-GP. 2 Introduction to Programming.
The Joy of Programming (also known as) Introduction to Object-Oriented Programming.
CS 3131 Introduction to Programming in Java Rich Maclin Computer Science Department.
2-1 Hardware CPU Memory - 2 kinds Network Graphics Input and Output Devices.
2-1 Hardware CPU Memory - 2 kinds Network Graphics Input and Output Devices.
Chapter 1 Section 1.1 Introduction to Java Slides prepared by Rose Williams, Binghamton University Kenrick Mock, University of Alaska Anchorage.
Introduction to Java Programming. Introduction Course Objectives Organization of the Book.
Java Applets. 2 Introduction to Java Applet Programs Applications are ___________________ programs –executed with Java interpreter Applet is a small program.
Session 1 Introduction to Java. Objectives Java Simplified / Session 1 / 2 of 32 Explain the history of Java Explain Java in brief List the types of Java.
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
4-Nov-15 Air Force Institute of Technology Electrical and Computer Engineering Object-Oriented Programming Design Topic 1: The Java Environment Maj Joel.
Software Development Programming & Languages. Programming: A Five-Step Procedure Define the problem Design a solution Code the program Test the program.
Object Oriented Programming Examples: C++, Java Advantages: 1. reusibility of code 2. ability to adapt (extend) previously written code.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and web applications Very rich GUI libraries Portability (machine independence) A real Object.
Intro to Applets. Applet Applets run within the Web browser environment Applets bring dynamic interaction and live animation to an otherwise static HTML.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
Creating a Java Application and Applet
AP Computer Science A – Healdsburg High School 1 Unit 2 - Object-Oriented Programming - Example.
ITP 109 Week 2 Trina Gregory Introduction to Java.
Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 15: Java Basics Fundamentals of Web Programming.
An Introduction to Software Development JavaMethods An Introduction to Object-Oriented Programming Maria Litvin Gary Litvin Copyright © 2003 by Maria Litvin,
Programming 2 Intro to Java Machine code Assembly languages Fortran Basic Pascal Scheme CC++ Java LISP Smalltalk Smalltalk-80.
CS 201 Lecture 1 (b) Using an IDE Tarik Booker CS 201: Introduction to Programming California State University, Los Angeles.
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
An Introduction to Software Development
An Introduction to Software Development
UNIT-5.
Java Applets.
Introduction CSC 111.
Computer Programming-1 CSC 111
Presentation transcript:

An Introduction to Software Development Java Methods A & AB Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin Copyright © 2006 by Maria Litvin, Gary Litvin, and Skylight Publishing. All rights reserved. Chapter 2

2-2 Objectives: Understand the software development process, tools, and priorities Understand compilers and interpreters Learn about Java Virtual Machine, bytecodes Learn to set up and run simple console applications, GUI applications, and applets in Java Learn basic facts about OOP

2-3 Software Today: 6,460,000,000

2-4 Software Applications Large business systems Databases Internet, , etc. Military Embedded systems Scientific research AI Word processing and other small business and personal productivity tools Graphics / arts / digital photography Games

2-5 Software Development Emphasis on efficiency  fast algorithms  small program size  limited memory use Often cryptic code Not user-friendly Emphasis on  programmer’s productivity  team development  reusability of code  easier maintenance  portability Better documented User-friendly 's:Now:

2-6 Programming Languages Machine code Assembly languages Fortran Basic Pascal Scheme CC++ Java LISP Smalltalk Smalltalk-80 C# Logo Python

2-7 Software Development Tools Editor  programmer writes source code Compiler  translates the source into object code (instructions specific to a particular CPU) Linker  converts one or several object modules into an executable program Debugger  steps through the program “in slow motion” and helps find logical mistakes (“bugs”)

2-8 The First “Bug” “(moth) in relay” Mark II Aiken Relay Calculator (Harvard University, 1945)

2-9 Compiled Languages: Edit-Compile-Link-Run Editor Source code Compiler Object code Linker Executable program Editor Source code Compiler Object code Editor Source code Compiler Object code

2-10 Interpreted Languages: Edit-Run Editor Source code Interpreter

2-11 Compiler vs. Interpreter Compiler:  checks syntax  generates machine-code instructions  not needed to run the executable program  the executable runs faster Interpreter:  checks syntax  executes appropriate instructions while interpreting the program statements  must remain installed while the program is interpreted  the interpreted program is slower

2-12 Java’s Hybrid Approach: Compiler + Interpreter A Java compiler converts Java source code into instructions for the Java Virtual Machine. These instructions, called bytecodes, are the same for any computer / operating system. A CPU-specific Java interpreter interprets bytecodes on a particular computer.

2-13 Java’s Compiler + Interpreter Editor    Hello.java  Compiler  Hello.class   Interpreter Hello, World !   Interpreter

2-14 Why Bytecodes? Platform-independent Load from the Internet faster than source code Interpreter is faster and smaller than it would be for Java source Source code is not revealed to end users Interpreter performs additional security checks, screens out malicious code

2-15 JDK — Java Development Kit javac  Java compiler java  Java interpreter appletviewer  tests applets without a browser javadoc  generates HTML documentation (“docs”) from source jar  packs classes into jar files (packages) All these are command-line tools, no GUI

2-16 JDK (cont’d) Available free from Sun Microsystems All documentation is online: Many additional Java resources on the Internet

2-17 Java IDE GUI front end for JDK Integrates editor, javac, java, appletviewer, debugger, other tools:  specialized Java editor with syntax highlighting, autoindent, tab setting, etc.  clicking on a compiler error message takes you to the offending source code line Usually JDK is installed separately and an IDE is installed on top of it.

2-18 Types of Programs Console applications GUI applications Applets

2-19 Console Applications C:\javamethods\Ch02> path=%PATH%;C:\Program Files\Java\jdk 1.5.0_07\bin C:\javamethods\Ch02> javac Greetings2.java C:\javamethods\Ch02> java Greetings2 Enter your first name: Josephine Enter your last name: Jaworski Hello, Josephine Jaworski Press any key to continue... Simple text dialog: prompt  input, prompt  input...  result

2-20 Command-Line Arguments C:\javamethods\Ch02> javac Greetings.java C:\javamethods\Ch02> java Greetings Josephine Jaworski Hello, Josephine Jaworski public class Greetings { public static void main(String[ ] args) { String firstName = args[ 0 ] ; String lastName = args[ 1 ] ; System.out.println("Hello, " + firstName + " " + lastName); } Command-line arguments are passed to main as an array of String s.

2-21 Command-Line Args (cont’d) Can be used in GUI applications, too IDEs provide ways to set them (or prompt for them) Josephine Jaworski

2-22 Greetings2.java import java.util.Scanner; public class Greetings2 { public static void main(String[ ] args) { Scanner kboard = new Scanner(System.in); System.out.print("Enter your first name: "); String firstName = kboard.nextLine( ); System.out.print("Enter your last name: "); String lastName = kboard.nextLine( ); System.out.println("Hello, " + firstName + " " + lastName); System.out.println("Welcome to Java!"); } Prompts

2-23 GUI Applications Menus Buttons Clickable panel Slider

2-24 HelloGui.java import java.awt.*; import javax.swing.*; public class HelloGui extends JFrame { public static void main(String[ ] args) { HelloGui window = new HelloGui( ); // Set this window's location and size: // upper-left corner at 300, 300; width 200, height 100 window.setBounds(300, 300, 200, 100); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.setVisible(true); } GUI libraries

2-25 HelloApplet.java import java.awt.*; import javax.swing.*; public class HelloApplet extends JApplet { public void init( ) {... } } No main in applets: the init method is called by JDK’s appletviewer or the browser

2-26 OOP — Object-Oriented Programming An OOP program models a world of active objects. An object may have its own “memory,” which may contain other objects. An object has a set of methods that can process messages of certain types.

2-27 OOP (cont’d) A method can change the object’s state, send messages to other objects, and create new objects. An object belongs to a particular class, and the functionality of each object is determined by its class. A programmer creates an OOP application by defining classes.

2-28 The Main OOP Concepts: Inheritance: a subclass extends a superclass; the objects of a subclass inherit features of the superclass and can redefine them or add new features. Event-driven programs: the program simulates asynchronous handling of events; methods are called automatically in response to events.

2-29 Inheritance A programmer can define hierarchies of classes More general classes are closer to the top Person ChildAdult BabyToddlerTeen

2-30 OOP Benefits Facilitates team development Easier to reuse software components and write reusable software Easier GUI (Graphical User Interface) and multimedia programming

2-31 Review: What are some of the current software development concerns? What are editor, compiler, debugger used for? How is a compiler different from an interpreter? Name some of the benefits of Java’s compiler+interpreter approach. Define IDE.

2-32 Review (cont’d): What is a console application? What are command-line arguments? What is a GUI application? What is the difference between a GUI application and an applet? What is OOP? Define inheritance.