Object Oriented Systems Lecture 01 First Java Programming Jaeki Song.

Slides:



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

CS0007: Introduction to Computer Programming Console Output, Variables, Literals, and Introduction to Type.
The Web Warrior Guide to Web Design Technologies
University of Palestine software engineering department Introduction to data structures Introduction to java application instructor: Tasneem Darwish.
 2005 Pearson Education, Inc. All rights reserved Introduction.
Chapter 1: Introduction
A Review. a review of lessons learned so far… ( 2 steps forward - 1 step back) Software Development Cycle: design, implement, test, debug, document Large.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 1 Introducing Java.
Object Orientated Programming
Introduction To Computers and Programming Lecture 2: Your first program Professor: Evan Korth New York University.
Slides prepared by Rose Williams, Binghamton University Chapter 1 Getting Started 1.1 Introduction to Java.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Excerpts from Introduction to Java Programming, 4E Author: Y. Daniel Liang (Copyright by Prentice Hall)
Introduction to Java Programming, 4E
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.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Getting Started with Java
Introduction to scripting
CH1 – A 1 st Program Using C#. Program Set of instructions which tell a computer what to do. Machine Language Basic language computers use to control.
Java Software Solutions Lewis and Loftus Chapter 2 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Software Concepts -- Introduction.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
Java Programming, 2E Introductory Concepts and Techniques Chapter 2 Creating a Java Application and Applet.
CSC 111 Java Programming I. Java Programming: From Problem Analysis to Program Design, Second Edition  Instructor – Salwa Hamad Al-Jasser  Office.
© The McGraw-Hill Companies, 2006 Chapter 1 The first step.
S.W. Ma/CIM/LWL41211/2 Prog. IIA Page 1 HKIVE (Lee Wai Lee Campus) Department of CIM Course : Year 2 Module : Programming IIA Textbook : Introduction.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
IT258 Foundation of Programming Using Java
Chapter 1: Creating Java Programs
Android How to Program, 2/e © Copyright by Pearson Education, Inc. All Rights Reserved.
111 © 2002, Cisco Systems, Inc. All rights reserved.
1.  At the end of this slide, student can:  Explore tools, features, properties and interface of the Textpad.  Creating a new project.  Open and run.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
1 Computer Systems -- Introduction  Chapter 1 focuses on:  the structure of a Java application  basic program elements  preparing and executing a program.
The Java Programming Language
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.
Intro and Review Welcome to Java. Introduction Java application programming Use tools from the JDK to compile and run programs. Videos at
Java Programming, Second Edition Chapter One Creating Your First Java Program.
Introduction to Java Programming with Forte Y. Daniel Liang.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Jaeki Song JAVA Lecture 02 Introduction to Java -The First Java Application-
1 CSE1340 Class 4. 2 Objectives Write a simple computer program in Java Use Swing components to build the GUI Use proper naming conventions for classes.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
© 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
Introduction to Java Programming. 2 Chapter 1 Introduction to Java and Forte F What Is Java? F Getting Started With Java Programming –Create, Compile.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. CSC 110 – INTRO TO COMPUTING - PROGRAMMING Overview of Programming.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 1 Introduction to Computers, Programs,
Introducing Java Chapter 3 Review. Why Program in Java? Java, is an object-oriented programming language. OOP languages evolved out of the need to better.
1 CSE1340 Class 4. 2 Objectives Write a simple computer program in Java Use simple Output statements Understand the different types and uses of comments.
Chapter 3 Introducing Java. Objectives and Goals 1. Define terminology associated with object- oriented programming. 2. Explain why Java is a widely used.
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
Java Programming Fifth Edition Chapter 1 Creating Your First Java Classes.
Introduction to Java Programming, 4E Y. Daniel Liang.
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
Chapter 6 JavaScript: Introduction to Scripting
GC101 Introduction to computer and program
Introduction to Scripting
Java programming lecture one
Chapter 1 Introduction to Computers, Programs, and Java
Chapter 1: Computer Systems
Computer Programming-1 CSC 111
Presentation transcript:

Object Oriented Systems Lecture 01 First Java Programming Jaeki Song

2 Objectives Learn about programming Be introduced to object-oriented programming concepts Learn about Java Analyze a Java application that uses console output

3 What is a program? A computer program is a set of instructions that enable the computer to solve a problem or perform a task Display a message on the screen: “How many hours did you work?” A computer’s CPU can only process instructions that are written in machine language A stream of binary numbers

4 What is a Program made of? Language elements Keywords (reserved words) There are words that have a special meaning in the programming language E.g.: public, class, static, etc Operators Symbols or words that perform operation son one or more operands E.g.: “=“, “*”, etc Punctuation Most programming languages require the use of punctuation characters such as the beginning or ending of a statement E.g.: semicolon in Java – similar to a period in English

5 What is a Program made of? Programmer-defined names Unlike key words, these are words or names that are defined by the programmer E.g.: names of variables Syntax Rules that must be followed when writing a program

6 Programming Approaches Procedural programming Divide a problem into smaller sub-problems Each sub-problem is analyzed and a solution for the sub-problem is obtained Also known as top-down design, stepwise refinement and modular programming Object-oriented programming Object-oriented Design (OOD) Identify components called object Specify the relevant data for each object and possible operations to be performed on that data In OOD, the final program is a collection of interacting objects A programming language that implements OOD is called an OOP language

7 Introduction to Object Concepts Object-oriented programming differs from traditional procedural programming Basic concepts Objects Classes Inheritance Polymorphism

8 What is Java? Designed in the early of 1990s by Sun Microsystems Code name “Green” Used in consumer devices such as an intelligent television “set-up” boxes The language was designed to be simple and architecture-neutral, so that it could be executed on a variety of hardware Rewrite the program: architecture- neutral, real-time, reliable, and secure Applets, now called Java provides animation and interactivity on the World Wide Web Web browsers have provided the opportunities to run Java applets The fastest growing language

9 Java Language Standard language used for programming, creating applets, servlets, JavaBeans, and enterprise components Java is simple Java is object-oriented language Java is distributed Java is portable Java is multithreaded

10 Java Environment Java source code Java compiler Java interpreter Computer OS Java virtual machine Source code is stored on a disk In a file with a name ending in.java Compiler creates byte codes that are stored on a disk a file with a name ending in.class JVM (named java.exe) performs security chekcs and translates byte codes to machine language, which executes

11 Java Program Types Applets Programs embedded in Web page Java applications Called Java stand-alone programs Console applications Support character output Windowed applications Menus Toolbars Dialog boxes

12 First Java Application Eclipse Tutorial public class First { public static void main (String [ ] args) { System.out.println (“First Java Application”) }

13 Understanding First Class Literal string Will appear in output exactly as entered Written between double quotation marks Arguments Pieces of information passed to method Method Requires information to perform its task Define Java class using any name or identifier Requirements for identifiers Must begin with: Letter of English alphabet Or non-English letter (such as α or π) Cannot begin with digit

14 Understanding First Class (continued) Requirements for identifiers Can only contain: Letters Digits Underscores Dollar signs Cannot be Java reserved keyword (p. 10) Cannot be true, false, or null Access modifier Defines how class can be accessed

15 Java Naming Conventions Packages The prefix of a unique package name is always written in all-lowercase ASCII letters and should be one of the top-level domain names Use dots to separate the parts E.g.: com.sun.eng, com.objectcentral.javatools Classes Class (and interface) names should be nouns descriptive of the purpose of the class Names are in mixed case, beginning with a capital and with the first letter of each internal word capitalized Use complete words and avoid abbreviations E.g.: Point, Shape, MovieEditor, ClientList

16 Java Naming Conventions (continued) Methods Methods should be verbs descriptive of the purpose of the method Names are mixed case with the first letter lowercase and the first letter of each internal word capitalized There are prefix conventions for general types of methods, such as using get and set for getters and setters E.g.: getOrigin, findSmallest, drawGraph, saveMoney Variables Except when used as constants, all variables are named using mixed case with a lowercase first letter, and with intenral words starting with capital letters Use one-letter variable names only for temporary variables E.g.: myMovie, editedMovie, backgroundColor Constants Names should be all uppercase with words seperated by underscores (“_”) e.g.: MAX_SIZE, TERM_LIMIT

17 main( ) Method Static Reserved keyword Means method accessible and usable Even though no objects of class exist void use in main() method header Does not indicate main() method empty Indicates main() method does not return value when called Doesn’t mean main() doesn’t produce output

18 Adding Comments to a Java Class Types of Java comments Line comments Start with two forward slashes ( // ) Continue to end of current line Do not require ending symbol Block comments Start with forward slash and asterisk ( /* ) End with asterisk and forward slash ( */ )

19 Programming Errors Syntax error Result from errors in cod construction E.g.: mistyping, omitting some necessary punctuation, using an opening brace without a corresponding closing brace Logical error Occur when a program does not perform the way it was intended to Run-time error Cause a program to terminate abnormally E.g. Input error: the user enters an unexpected input value that the program cannot handle Division by zero

20 Using Java Swing Class Refers to the new library of GUI A component set that makes up all the objects of GUI Displays output using windows or dialog boxes Input Dialog and Output Dialog Use packages Predefined classes grouped into categories of related classes called packages (sometimes called java class libraries or java applications programming interface (API)) JOptionPane Defined in a package called javax.swing

21 GUI Output JOptionPane Produce dialog boxes Dialog box GUI object resembling window Messages placed for display Package Group of classes import statement Use to access built-in Java class

22 Output Dialog showMessageDialog ( null, “string”); A method of class JOptionPane Two arguments Syntax JOptionPane.showMessageDialog(null, “string”);

23 Common Errors to Avoid Mismatched braces, quotation marks, or parentheses Misspelling key words Using capital letters in key words Java is a case-sensitive All key words are written in lower case in Java Using a key word as a variable name Using inconsistent spelling Forgetting the semicolon at the end of a statement Not using the required import statement