Chapter 1: Java Fundamentals 1 (c) Gary R. Smith, MS.

Slides:



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

Chapter 1: Computer Systems
INTRODUCTION Chapter 1 1. Java CPSC 1100 University of Tennessee at Chattanooga 2  Difference between Visual Logic & Java  Lots  Visual Logic Flowcharts.
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.
Object Oriented Programming in JAVA
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.
Object Orientated Programming
1 Java Basics. 2 Compiling A “compiler” is a program that translates from one language to another Typically from easy-to-read to fast-to-run e.g. from.
Chapter 2 - Java Programming Fundamentals1 Chapter 2 Java Programming Fundamentals.
Chapter 1 Introduction. © 2004 Pearson Addison-Wesley. All rights reserved1-2 Outline Computer Processing Hardware Components Networks The Java Programming.
Chapter 1 Introduction.
INTRODUCTION TO JAVA PROGRAMMING Chapter 1. What is Computer Programming?
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.
CMSC 341 Introduction to Java Based on tutorial by Rebecca Hasti at
Java Software Solutions Lewis and Loftus Chapter 2 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Software Concepts -- Introduction.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
IT258 Foundation of Programming Using Java
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
Chapter 1: Creating Java Programs
Java Language and SW Dev’t
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.
1 Part I : Chapter 01 Introduction to Java Programming.
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
CSC204 – Programming I Lecture 4 August 28, 2002.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
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.
Java Programming, Second Edition Chapter One Creating Your First Java Program.
Chapter 8: Arrays.
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.
Using Data Within a Program Chapter 2.  Classes  Methods  Statements  Modifiers  Identifiers.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Chapter 1: Introduction Java Programming Language How the Java Virtual Machine Works (compiling, etc…) Update by: Dan Fleck Coming up: The Java Programming.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
1 The JAVA Language Object Oriented Technology Mithani Binjan M.
Developed at Sun Microsystems in 1991 James Gosling, initially named “OAK” Formally announced java in 1995 Object oriented and cant write procedural.
© 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.
CHAPTER 2 PROBLEM SOLVING USING C++ 1 C++ Programming PEG200/Saidatul Rahah.
Chapter 1 Java Programming Review. Introduction Java is platform-independent, meaning that you can write a program once and run it anywhere. Java programs.
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.
© 2011 Pearson Education, publishing as Addison-Wesley Chapter 1: Computer Systems Presentation slides for Java Software Solutions for AP* Computer Science.
SUMMARY OF CHAPTER 2: JAVA FUNDAMENTS STARTING OUT WITH JAVA: OBJECTS Parts of a Java Program.
Java Programming Fifth Edition Chapter 1 Creating Your First Java Classes.
Introduction to Java Programming, 4E Y. Daniel Liang.
SESSION 1 Introduction in Java. Objectives Introduce classes and objects Starting with Java Introduce JDK Writing a simple Java program Using comments.
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
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.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Working with Java.
GC101 Introduction to computer and program
Chapter No. : 1 Introduction to Java.
Yanal Alahmad Java Workshop Yanal Alahmad
Internet and Java Foundations, Programming and Practice
Data types and variables
Java programming lecture one
An Overview of Java.
Chapter 3 Introduction to Classes, Objects Methods and Strings
Chapter 1: Computer Systems
Units with – James tedder
Units with – James tedder
Focus of the Course Object-Oriented Software Development
Chap 2. Identifiers, Keywords, and Types
Computer Programming-1 CSC 111
Presentation transcript:

Chapter 1: Java Fundamentals 1 (c) Gary R. Smith, MS.

 Know the history and philosophy of Java  Understand Java’s contribution to the Internet  Understand the importance of bytecode  Know the Java buzzwords  Understand the foundational principles of object-oriented programming  Create, compile, and run a simple Java program 2 (c) Gary R. Smith, MS.

 Use the if and for control statements  Create blocks of code  Understand how statements are positioned, indented, and terminated  Know the Java keywords  Understand Java identifiers 3 (c) Gary R. Smith, MS.

 Conceived by James Gosling, Patrick Naughton, Chris Warth, Ed Frank and Mike Sheridan at Sun Microsystems in  Originally designed as a platform-independent language to control embedded consumer electronic devices.  Based on C and C++ languages.  The advent of the Internet promoted the change from consumer electronics to the Internet programming. 4 (c) Gary R. Smith, MS.

 Java’s syntax is inherited from C.  Java’s object model is adapted from C++.  Java was developed by programmers for programmers.  Java is not upwardly or downwardly compatible with C++.  Designed to solve a different set of problems.  C#’s syntax and structure are similar to Java.  C# was designed for a different computing platform. 5 (c) Gary R. Smith, MS.

 Java Applets – special type of program that gets automatically executed by a Web browser.  Intended to be small programs.  Is downloaded upon demand.  Use to display data, handle input, and provide simple functions.  Executes locally rather than on a server. 6 (c) Gary R. Smith, MS.

 Security – Applets are confined to the Java execution environment.  Cannot access other parts of the computer.  Reduces the likelihood of malicious code or breaches of security. 7 (c) Gary R. Smith, MS.

 Portability  Java can run on a variety of different platforms using the same code called Bytecode.  Bytecode  Not executable code.  Is interpreted by the Java Virtual Machine run-time environment.  Highly optimized for the interpretive process. 8 (c) Gary R. Smith, MS.

SimpleHas a concise, cohesive set of features that makes it easy to learn and use. SecureProvides a secure means of creating Internet applications. PortablePrograms can execute in any environment for which there is a Java run- time system. Object-orientedEmbodies the modern, object-oriented programming philosophy. RobustEncourages error-free programming by being strictly typed and performing run-time checks. MultithreadedProvides integrated support for multithreaded programming. Architecture-neutralIs not tied to a specific machine or operating system architecture. InterpretedSupports cross-platform code through the use of Java bytecode. High performanceBytecode is highly optimized for speed of execution. DistributedDesigned with the distributed environment of the Internet. DynamicPrograms carry with them substantial amounts of run-time type information that is used to verify and resolved accesses of objects at run time. 9(c) Gary R. Smith, MS.

 Object-Oriented Programming is a programming model that focuses on data and the code that manipulates that data.  Key Features:  Encapsulation – programming mechanism that binds together code and the data it manipulates.  Polymorphism – programming mechanism that allows a single interface to have many forms.  Inheritance – the process by which one object can acquire the properties of another object. 10 (c) Gary R. Smith, MS.

 Class – Java’s basic unit of encapsulation.  Often referred to as a program.  May contain both data members (aka instance fields or instance variables) and code members (aka methods).  A class is the blueprint to construct an object. A class is not the object. Objects are instances of a class.  Data and methods can be private (known only within the class) or public (known to other classes). 11 (c) Gary R. Smith, MS.

// Program: AJavaProgram.java  Inline comment // Author: Gary R. Smith  Inline comment // Date Written: 8/16/2014  Inline comment /* This program displays a message  Block comment (multi-line) on the monitor */ (/* begins comment, */ ends comment) public class AJavaProgram  Class header (name of the class) {  Starts a block of code (class) // This is where the program starts and ends.  Inline comment public static void main(String args[])  Method header {  Starts a block of code (method) // Displays a message on the monitor  Inline comment System.out.println(“Java is fun!”);  Executable statement }  Ends a block of code (method) }  Ends a block of code (class) 12(c) Gary R. Smith, MS.

 // (two slashes) indicates an inline comment.  Not compiled as part of the program  Provides in-program documentation  Comment goes to the end of the line  /* and */ indicates a block comment  Everything between /* and */ are comments  Not compiled as part of the program  Can be as long as you want.  Don’t be stingy on comments! 13 (c) Gary R. Smith, MS.

 Class header (public class AJavaProgram) defines the name of the program.  Public is an access modifier that defines whether or not outside classes can access the class.  Must be the same name as the file name  public class AJavaProgram must have a file name of  AJavaProgram.java 14 (c) Gary R. Smith, MS.

 Curly braces: { }  Denotes a block of code treated as a unit.  Encapsulates classes  Encapsulates methods  Encapsulates program elements supporting multiple statements. 15 (c) Gary R. Smith, MS.

 Method header (public static void main(String args[]) defines a named block of code.  Public is an access modifier.  Static means the method belongs to the class itself and not an instance of the class.  Void (return type) means the method does not return any value.  main() is the name of the method which must include the parenthesis, which hold parameters.  String args[] is the parameter of the main() method.  Methods may have zero or any number of parameters. String args[] is a parameter of the main() method. 16 (c) Gary R. Smith, MS.

 System.out.println(“Java is fun!”); is an executable statement.  System is a predefined class  out is an object of the System class  println() is a method of the System.out object  “Java is fun!” is a parameter that is passed to the println() method. Note it is String data.  The semicolon ‘;’ terminates an executable statement. 17 (c) Gary R. Smith, MS.

 Syntax errors: violations of the language rules.  Caught by the compiler  Incorrect punctuation  Misspelled keywords and identifiers  Not specifying balanced (open and/or closing) parenthesis, curly braces, or square brackets. 18 (c) Gary R. Smith, MS.

 Data types define:  How data is stored in memory  The minimum and maximum values a data item can hold  The amount of memory allocated for the data item.  Each data type is based on a class.  Java primitive data types are:  Integer types: byte, short, int, long  Floating point types: float, double  Boolean type: boolean  Character type: char 19 (c) Gary R. Smith, MS.

 Field - An area of a database record, graphical user interface form, data item, or memory into which a particular item of data is stored.  Can be subdivided into two general categories:  Variables: Those data items which can be programmatically changed.  Constants: Those data items which cannot be programmatically changed.  A field is associated with a data type. (c) Gary R. Smith, MS. 20

abstractassertbooleanbreakbytecase catchcharclassconstcontinuedefault dodoubleelseenumextendsfinal finallyfloatforgotoifimplements importinstanceofintinterfacelongnative newpackageprivateprotectedpublicreturn shortstaticstrictfpsuperswitchsynchronized thisthrowthrowstransienttryvoid volatilewhile* true* false* null Keywords have special meaning to the Java compiler. These keywords cannot be used as names for variables, classes, or methods. * Although not keywords, true, false and null are also reserved words. 21(c) Gary R. Smith, MS.

 Identifiers are names given to classes, objects, methods, variables, and other user-defined items.  Can start with any letter, the underscore character, or dollar sign.  May contain (after the first character) letters, numbers, the underscore character, or dollar sign  Cannot have any embedded spaces.  Are case sensitive. 22 (c) Gary R. Smith, MS.

 Class identifiers  Begin each word with an upper case letter.  All other letter are lower case.  Example: AJavaProgram, Employee  Variable/object/method identifiers  Begin the first word with a lower case letter.  All other words begin with an upper case letter.  Use camel casing/Hungarian notation.  Example: employeeNumber, calculateInvoiceTotal  Note: This is a convention, not a language requirement. 23 (c) Gary R. Smith, MS.

 Java contains hundreds of predefined classes stored in libraries.  System is a class library automatically included in every Java program.  You can create your own class libraries. 24 (c) Gary R. Smith, MS.

25 Java source programs end with a.java extension. Compiled Java programs end with a.class extension.

(c) Gary R. Smith, MS.26 Analyze the requirements Develop an algorithm Code the program Test the program Implement the program Maintain the program

 Analyze the requirements  What is the expected result?  What data is needed to yield the expected result?  What actions are to take place  What output, if any, is to be produced?  Clarify calculations with the user.  What are the objects? (c) Gary R. Smith, MS. 27

 Develop an algorithm (solution to the problem)  Pseudocode  Flowchart  IPO (Input/Process/Output) Diagram  Decision Trees  Truth Tables  Object Dictionaries  Develop testing criteria (c) Gary R. Smith, MS. 28

 Code the program  What standards does the organization have?  Naming conventions  Program structure  Libraries  Internal documentation (c) Gary R. Smith, MS. 29

 Test the program  Unit tests - testing a single method  Program tests – testing the operation of the program  System tests – testing to insure all programs work properly together  Acceptance tests – testing by the user to verify everything works as specified. (c) Gary R. Smith, MS. 30

 Implement the program  File/data conversion  User/system documentation  Performance tuning  Types of implementations  Phased  Pilot  Parallel  Direct cut over (c) Gary R. Smith, MS. 31

 Maintain the program  Changes to programs are inevitable.  Governmental regulations  Changes in business practices  Technological changes  Acquisitions and mergers  Follows the first 5 steps of the program development cycle. (c) Gary R. Smith, MS. 32

 Tutorials:   Java™ Platform, Standard Edition 8 API Specification  tml tml 33 (c) Gary R. Smith, MS.