CSC 111 Java Programming I. Java Programming: From Problem Analysis to Program Design, Second Edition 2 2-6  Instructor – Salwa Hamad Al-Jasser  Office.

Slides:



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

Chapter 1 An Overview of Computers and Programming Languages.
Chapter 1: An Overview of Computers and Programming Languages
Dale Roberts Introduction to Java - First Program Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and.
University of Palestine software engineering department Introduction to data structures Introduction to java application instructor: Tasneem Darwish.
Chapter 1 Introduction to JAVA. Why Learn JAVA? Java is one of the fastest growing programming language in the world. Java is one of the fastest growing.
 2005 Pearson Education, Inc. All rights reserved Introduction.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Chapter 1: Introduction
© Janice Regan Problem-Solving Process 1. State the Problem (Problem Specification) 2. Analyze the problem: outline solution requirements and design.
Chapter 1: An Overview of Computers and Programming Languages J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program.
 2003 Prentice Hall, Inc. All rights reserved. Customized by Sana Odeh for the use of this class. 1 Introduction to Computers and Programming in JAVA.
Chapter 1: An Overview of Computers and Programming Languages
Introduction to Computer Programming CSC 1401: Introduction to Programming with Java Lecture 2 Wanda M. Kunkle.
Chapter 1: An Overview of Computers and Programming Languages
 2002 Prentice Hall. All rights reserved. Week 1 - Introduction to Object- Oriented Programming Outline 1.1 Machine Languages, Assembly Languages and.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages C++ Programming:
CSE 1301 J Lecture 2 Intro to Java Programming Richard Gesick.
CHAPTER 1: AN OVERVIEW OF PROGRAMMING INSTRUCTOR: MOHAMMAD MOJADDAM How to Program in C++
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 1: An Overview of Computers and Programming Languages Updated by: Dr\Ali-Alnajjar.
BASIC JAVA PROGRAMMING TUTORIAL. History  James Gosling and Sun Microsystems  Oak  Java, May 20, 1995, Sun World  Hot Java –The first Java-enabled.
 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.
Introducing Java.
CSC 142 A 1 CSC 142 Introduction to Java [Reading: chapter 0]
© The McGraw-Hill Companies, 2006 Chapter 1 The first step.
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 An Overview of Computers and Programming Languages.
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.
 2003 Prentice Hall, Inc. All rights reserved. 1 Java Training Course Dr. H.E. Dunsmore Purdue University Java – How to Program, Deitel (5 th Edition)
 2005 Pearson Education, Inc. All rights reserved Introduction to Computers, the Internet and the World Wide Web.
Chapter 1 CSIS-120: Java Intro. What is Programming?  A: It is what makes computer so useful.  The flexibility of a computer is amazing  Write a term.
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.
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.
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.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, D.S. Malik D.S. Malik.
CSC1201: PROGRAMMING LANGUAGE 2 Aseel Al Hadlaq 2nd Term
© 2004 Pearson Addison-Wesley. All rights reserved ComS 207: Programming I Instructor: Alexander Stoytchev
J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition Second Edition D.S. Malik D.S. Malik.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Chapter 1: An Overview of Computers and Programming Languages
Introduction to Java Applications Part I. In this chapter you will learn:  Why Java?  History of Java.  To write simple Java applications. 2.
1 Chapter 1 Programming Languages Evolution of Programming Languages To run a Java program: Java instructions need to be translated into an intermediate.
Creating a Java Application and Applet
Chapter 1 An Overview of Computers and Programming Languages.
1 Chapter 1 Java –Originally for intelligent consumer-electronic devices –Then used for creating Web pages with dynamic content –Now also used for: Develop.
Java Programming Fifth Edition Chapter 1 Creating Your First Java Classes.
Introduction to 1. What is Java ? Sun Microsystems Java is a programming language and computing platform first released by Sun Microsystems in The.
Introduction to Programming By: Prof. Muhammad Abu Baker Siddique 2 nd Lecture 1.
Introduction to Algorithm. What is Algorithm? an algorithm is any well-defined computational procedure that takes some value, or set of values, as input.
Chapter 6 JavaScript: Introduction to Scripting
Introduction to Computers, the Internet and the World Wide Web
GC101 Introduction to computer and program
Chapter 3 GC 101 Java Fundamentals.
Chapter 1: An Overview of Computers and Programming Languages
Introduction to.
Chapter 1: An Overview of Computers and Programming Languages
About the Presentations
Java programming lecture one
C++ Programming: From Problem Analysis to Program Design
PROGRAM STRUCTURE CSC 111.
Introduction CSC 111.
JavaScript: Introduction to Scripting
Computer Programming-1 CSC 111
Presentation transcript:

CSC 111 Java Programming I

Java Programming: From Problem Analysis to Program Design, Second Edition  Instructor – Salwa Hamad Al-Jasser  Office – 54 / 20  Office hours - posted

Java Programming: From Problem Analysis to Program Design, Second Edition 3  3 lectures  1 tutorial  1 lab

Java Programming: From Problem Analysis to Program Design, Second Edition 4 Course grade:  Midterms – 15% each Quizes -- 10% Lab – 20% Lab – 20% Final – 40% Final – 40%

J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition Second Edition D.S. Malik D.S. Malik

Java Programming: From Problem Analysis to Program Design, Second Edition 6 Chapter 1: An Overview of Computers and Programming Languages Chapter 1: An Overview of Computers and Programming Languages

Java Programming: From Problem Analysis to Program Design, Second Edition7 Evolution of Programming Languages  High-level languages make programming easier.  Closer to spoken languages.  Examples:  Basic  FORTRAN  COBOL  C/C++  Java

Java Programming: From Problem Analysis to Program Design, Second Edition8 History Of Java  Developed by Sun Microsystems – a company known for its workstations.  Java is well known for developing internet applications. it is used to :  Create web pages with dynamic and interactive content.  Develop large –scale enterprise applications.  Enhance the functionality of WWW servers.  Provide applications for customer devices ( ex. Cell phones).  Java programs can run from a web browser.

Java Programming: From Problem Analysis to Program Design, Second Edition9 Basics of Java Environment  The environment  The language  Java applications programming Interface API  Various class libraries

Java Programming: From Problem Analysis to Program Design, Second Edition10 Processing a Java Program A Java program undergoes several stages : 1.Editing : use java code and save in a text file named className.java ( source program ). 2. Compiling : the compiler checks the source program for any syntax errors then translates the program into code understood by interpreter called bytecode saved in a file named className.class 3. Loading : the.class file is loaded into computer main memory for execution, and connected to all classes. 4. Verifying : to validate and secure against damage. 5. Interpreting : the Interpreter reads and translates each bytecode instruction into machine language and then executes it, one instrucion at a time.

Java Programming: From Problem Analysis to Program Design, Second Edition11 Processing a Java Program

Java Programming: From Problem Analysis to Program Design, Second Edition12 Processing a Java Program  Java Virtual Machine (JVM): A hypothetical computer developed to make Java programs machine independent ( i.e run on many different types of computer platforms ).  Bytecode is the machine language for the JVM.

Java Programming: From Problem Analysis to Program Design, Second Edition13 Processing a Java Program Two types of Java programs:  applications : standalone programs stored and executed on a local computer.  applets : small programs stored on remote computers that users connect to via a WWW browser. Applets are loaded into the browser, executed then discarded.

Java Programming: From Problem Analysis to Program Design, Second Edition14 Example of a Java Program  A simple java application: an application executes using the java interpreter. Example : // This prints a line of text public class Welcome { public static void main (String args[] ) { System.out.println(“ welcome to java”) ; }

Java Programming: From Problem Analysis to Program Design, Second Edition15 Example of a Java Program  // single line comment  /* */ multiple line comment  Every java program must have at least one class.  Each class begins with a class declaration that defines data and methods for the class.  The class name here is Welcome, and contains a method main ()  Welcome is an identifier.

Java Programming: From Problem Analysis to Program Design, Second Edition16 Java Identifiers  Names of things. Such as methods, class names..  Consists of:  Letters  Digits  The underscore character ( _ )  The dollar sign ( $ )  Must begin with a letter, underscore, or the dollar sign. (i.e does not begin with a digit )  Java is case sensitive. A and a are different.

Java Programming: From Problem Analysis to Program Design, Second Edition17 Java Program- class definiton  Always begin a class name with a capital letter.  The class definition should be saved in a file that contains the class name.( i.e Welcome.java )  A file cannot contain two public classes.  public static void main (String args[]) is a part of every java application program.

Java Programming: From Problem Analysis to Program Design, Second Edition18 Java Program- class definiton  Java applications automatically begin executing at main ().  The parentheses () after main indicate that main is a method.  Class definitions normally contain one ore more methods.  One of those methods must be called main.  The void before main () means that main will not return any info.

Java Programming: From Problem Analysis to Program Design, Second Edition19 A Java Program public class ASimpleJavaProgram { public static void main(String[] args) { System.out.println("My first Java program."); System.out.println("The sum of 2 and 3 = " + 5); System.out.println("7 + 8 = " + (7 + 8)); } Class name Java o/p stmts Body of class Heading of method main

Java Programming: From Problem Analysis to Program Design, Second Edition20 A Java Program  A java output statement causes the program to evaluate whatever is in the parentheses and display the result on screen.  Anything in double quotation marks, called string, evaluates to itself.  + is used to concatenate the strings. The system automatically converts the number 5 into a string,joins that string with the first string,and displays it.

Java Programming: From Problem Analysis to Program Design, Second Edition21 A Java Program  The parentheses around 7+8 causes the system to add the numbers 7 and 8,resulting in 15.  The number 15 is then converted to string 15 and joined with string “7+8”= “. Sample Run: My first Java program. The sum of 2 and 3 = = 15

Java Programming: From Problem Analysis to Program Design, Second Edition22 A Java Program  The basic unit of a java program is a class.  Every class consists of one or more methods.  A method is a set of statements that accomplish something.  A java class must contain one main method if it is an application.  Execution always begins with method main in java application program.

Java Programming: From Problem Analysis to Program Design, Second Edition23 Internet,WWW and Java  Internet : is an interconnection of networks that allows computers around the world to communicate with each other.  In 197o’s, the US DOD developed techniques to interlink networks, i.e communication protocols so that networked computers could communicate  Internet  WWW uses s/w programs that enable users to view documents on any computer over the internet

Java Programming: From Problem Analysis to Program Design, Second Edition24 Internet,WWW and Java  The primary language of web is HTML, a simple language for laying out and linking documents.  HTML is not capable of interacting with users except to collect info via simple forms.  Java applets make the web responsive and interactive

Java Programming: From Problem Analysis to Program Design, Second Edition25 Programming Methodologies Two basic approaches to programming design:  Structured design  Object-oriented design

Java Programming: From Problem Analysis to Program Design, Second Edition26 Structured Design 1.A problem is divided into smaller sub-problems. 2.Each sub-problem is analyzed, solved and a solution for this sub-problem is obtained. 3.The solutions of all sub-problems are combined to solve the overall problem. 4.Is called structured programming, top-down design approach, or modular programming.

Java Programming: From Problem Analysis to Program Design, Second Edition27 Object-Oriented Design (OOD)  In OOD, a program is a collection of interacting objects.  An object consists of data and operations.  Steps in OOD: 1.Identify the objects which form the basis of the solution, then determine how these objects interact with each other. Example : write a program that automates the video rental process for a video store. The two main objects are : 1- video 2- customer

Java Programming: From Problem Analysis to Program Design, Second Edition28 Object-Oriented Design (OOD)  Steps in OOD: 2. Specify the relevant data for each object and the possible operations to be performed on that data. Example : for the video object o the data might be : movie name,Starring actors,and Number of copies in stock. oThe operations on video object might include : checking the name of the movie, reducing the # of copies in stock by 1 after renting a copy.

Java Programming: From Problem Analysis to Program Design, Second Edition29 Object-Oriented Design (OOD)  Each object consists of data and operations on those data  The final program is a collection of interacting objects.

Java Programming: From Problem Analysis to Program Design, Second Edition30 Problem-Analysis-Coding- Execution Cycle  Algorithm: A step-by-step, problem-solving process in which a solution is arrived at in a finite amount of time.

Java Programming: From Problem Analysis to Program Design, Second Edition31 Problem-Solving Process 1.Analyze the problem: Outline solution requirements and design an algorithm. 2.Implement the algorithm in a programming language (Java) and verify that the algorithm works. 3.Maintain the program: Use and modify if the problem domain changes.

Java Programming: From Problem Analysis to Program Design, Second Edition32 Problem-Analysis-Coding-Execution Cycle