Java Programming Fifth Edition Chapter 1 Creating Your First Java Classes.

Slides:



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

CHAPTER 1: AN OVERVIEW OF COMPUTERS AND LOGIC. Objectives 2  Understand computer components and operations  Describe the steps involved in the programming.
IT151: Introduction to Programming
Dale Roberts Introduction to Java - First Program Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and.
Objectives You should be able to describe: Introduction to Programming
Lecture 2 Introduction to C Programming
MC697 Object-Oriented Programming Using Java. In this class, we will cover: How the class will be structured Difference between object-oriented programming.
 2005 Pearson Education, Inc. All rights reserved Introduction.
Chapter 1: Introduction
Introduction To Computers and Programming Lecture 2: Your first program Professor: Evan Korth New York University.
©2004 Brooks/Cole Chapter 1: Getting Started Sections Covered: 1.1Introduction to Programming 1.2Constructing a Java Program 1.3The print() and println()
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
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
Chapter 1 - Introduction. Ch 1Goals To understand the activity of programming To learn about the architecture of computers To learn about machine code.
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.
1 Chapter One A First Program Using C#. 2 Objectives Learn about programming tasks Learn object-oriented programming concepts Learn about the C# programming.
Introducing Java.
Java Programming, 2E Introductory Concepts and Techniques Chapter 2 Creating a Java Application and Applet.
+ Java vs. Javascript Jessi Style. + Java Compiled Can stand on its own Written once, run anywhere Two-stage debugging Java is an Object Oriented Programming.
A First Program Using C#
IT258 Foundation of Programming Using Java
Java Programming, 3e Concepts and Techniques Chapter 2 - Part 2 Creating a Java Application and Applet.
Object Oriented Systems Lecture 01 First Java Programming Jaeki Song.
Chapter 1: Creating Java Programs
1Object-Oriented Program Development Using C++ Computer Science and Programming Languages Computers are ubiquitous Computer literacy is essential Computer.
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
111 © 2002, Cisco Systems, Inc. All rights reserved.
Chapter 1: A First Program Using C#. Programming Computer program – A set of instructions that tells a computer what to do – Also called software Software.
Chapter 3: Completing the Problem- Solving Process and Getting Started with C++ Introduction to Programming with C++ Fourth Edition.
Computer Programming A program is a set of instructions a computer follows in order to perform a task. solve a problem Collectively, these instructions.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
The Java Programming Language
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
Jaeki Song ISQS6337 JAVA Lecture 03 Introduction to Java -The First Java Application-
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.
Board Activity Find your seat on the seating chart Login – Remember your login is your first initial your last name and the last three numbers of your.
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.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
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.
JAVA Practical Creating our first program 2. Source code file 3. Class file 4. Understanding the different parts of our program 5. Escape characters.
Creating a Java Application and Applet
Java FilesOops - Mistake Java lingoSyntax
Objective You will be able to define the basic concepts of object-oriented programming with emphasis on objects and classes by taking notes, seeing examples,
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 1 Introduction to Computers, Programs,
Lecture1 Instructor: Amal Hussain ALshardy. Introduce students to the basics of writing software programs including variables, types, arrays, control.
Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design.
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.
Principles of Programming CSEB134 : BS/ CHAPTER Fundamentals of the C Programming Language.
ITP 109 Week 2 Trina Gregory Introduction to Java.
1/16: Intro to Java, Languages, and Environments Types of programming languages –machine languages –assembly languages –high-level languages Java environment.
Chapter 3 Introducing Java. Objectives and Goals 1. Define terminology associated with object- oriented programming. 2. Explain why Java is a widely used.
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
CHAPTER 3 COMPLETING THE PROBLEM- SOLVING PROCESS AND GETTING STARTED WITH C++ An Introduction to Programming with C++ Fifth Edition.
Chapter 4.  Variables – named memory location that stores a value.  Variables allows the use of meaningful names which makes the code easier to read.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
1 Problem Solving  The purpose of writing a program is to solve a problem  The general steps in problem solving are: Understand the problem Dissect the.
Working with Java.
CS170 – Week 1 Lecture 3: Foundation Ismail abumuhfouz.
GC101 Introduction to computer and program
Data types and variables
Java programming lecture one
Computer Programming-1 CSC 111
Presentation transcript:

Java Programming Fifth Edition Chapter 1 Creating Your First Java Classes

Java Programming, Fifth Edition2 Learning About Programming Program –Set of written instructions that tells computer what to do Machine language –Most basic circuitry-level language –Low-level programming language High-level programming language –Allows you to use vocabulary of reasonable terms Syntax –Rules of language Program statements –Similar to English sentences –Carry out tasks of program

Java Programming, Fifth Edition3 Learning About Programming (continued) Compiler or interpreter –Translates language statements into machine code Syntax error –Misuse of language –Misspelled programming language word Debugging –Freeing program of all errors Logic errors –Also called semantic errors –Incorrect order or procedure

Java Programming, Fifth Edition4 Introducing Object-Oriented Programming Concepts Procedural programming –Sets of operations executed in sequence –Variables Named computer memory locations that hold values – Procedures Individual operations grouped into logical units Object-oriented programs –Create classes –Create objects from classes –Create applications

Java Programming, Fifth Edition5 Understanding Objects and Classes Objects –Made up of attributes and methods Attributes –Characteristics that define object –Differentiate objects of same class –Value of attributes is object’s state Class –Describes objects with common properties –Definition –Instance

Understanding Objects and Classes (continued) Java Programming, Fifth Edition6

7 Learning About Java Java –Developed by Sun Microsystems –Object-oriented language –General-purpose –Advantages Security features Architecturally neutral Java (continued) –Can be run on wide variety of computers –Does not execute instructions on computer directly –Runs on hypothetical computer known as Java virtual machine (JVM) Source code –Programming statements written in high-level programming langua

Java Programming, Fifth Edition8 Learning About Java (continued) Bytecode –Statements saved in file –Java compiler converts source code into binary program Java interpreter –Checks bytecode and communicates with operating system –Executes bytecode instructions line by line within Java virtual machine

Java Programming, Fifth Edition9 Learning About Java (continued)

Java Programming, Fifth Edition10 Analyzing a Java Application That Uses Console Output (continued)

Understanding the Statement That Prints the Output (continued) Java Programming, Fifth Edition11

Java Programming, Fifth Edition12 Understanding the First Class Everything used within Java program must be part of a class 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 –Can only contain: Letters Digits Underscores Dollar signs –Cannot be Java reserved keyword –Cannot be true, false, or null

Java Programming, Fifth Edition13 Understanding the First Class (continued)

Understanding the First Class Java Programming, Fifth Edition14

Understanding the First Class (continued) Java Programming, Fifth Edition15

Java Programming, Fifth Edition16 Understanding the 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

Shell Code Java Programming, Fifth Edition17

Java Programming, Fifth Edition18 Adding Comments to a Java Class Program comments –Nonexecuting statements added to program for documentation –Use to leave notes for yourself or others –Include author, date, class’s name or function Comment out a statement –Compiler does not translate 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 ( */ )

Java Programming, Fifth Edition19 Adding Comments to a Java Class (continued) Types of Java comments (continued) –Javadoc comments Special case of block comments Begin with slash and two asterisks ( /** ) End with asterisk and forward slash ( */ ) Use to generate documentation

Java Programming, Fifth Edition20 Creating a Java Application Using 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

Java Programming, Fifth Edition21 Creating a Java Application Using GUI Output (continued)

Java Programming, Fifth Edition22 Correcting Errors and Finding Help (continued) Parsing –Process compiler uses to divide source code into meaningful portions Logic error –Syntax correct but produces incorrect results when executed –Usually more difficult to find and resolve Java API –Also called the Java class library –Prewritten Java classes

Don’t Do It File’s name must match name of class Don’t confuse names parentheses, braces, brackets, curly braces, square brackets, and angle brackets Don’t forget to end a block comment Don’t forget that Java is case sensitive End every statement with semicolon –Do not end class or method headers with semicolon Recompile when making changes Java Programming, Fifth Edition23