1 CSC204 – Programming I Lecture 2 Intro to OOP with Java.

Slides:



Advertisements
Similar presentations
CSCE 145: Algorithmic Design I Chapter 1 Intro to Computers and Java Muhammad Nazmus Sakib.
Advertisements

How do we make our Welcome.java program do something? The java in our Welcome.java file won’t do anything by itself. We need to tell the computer to execute.
Object Orientated Programming
Lecture 2: Do you speak Java?. From Problem to Program Last Lecture we looked at modeling with objects! Steps to solving a business problem –Investigate.
How to Create a Java program CS115 Fall George Koutsogiannakis.
How do we make our HelloTester.java program do something? The java in our HelloTester.java file won’t do anything by itself. We need to tell the computer.
Introduction to Java Programming
Introduction to Computer Programming CSC 1401: Introduction to Programming with Java Lecture 2 Wanda M. Kunkle.
1 Programming & Programming Languages Overview l Machine operations and machine language. l Example of machine language. l Different types of processor.
1 Programming Languages Translation  Lecture Objectives:  Be able to list and explain five features of the Java programming language.  Be able to explain.
Lecture 2: Do you speak Java?. From Problem to Program Last Lecture we looked at modeling with objects! Steps to solving a business problem –Investigate.
Introduction to Java.
Java How to Program, 9/e Instructor: José M. Reyes Álamo © by Pearson Education, Inc. All Rights Reserved.
Session-02. Objective In this session you will learn : What is Class Loader ? What is Byte Code Verifier? JIT & JAVA API Features of Java Java Environment.
CSE 1301 J Lecture 2 Intro to Java Programming Richard Gesick.
Java PAL.  Contains the development kit and the runtime environment ( aka the Java Virtual Machine )  Download Link:
COMP Computer Basics Yi Hong May 13, 2015.
IB Computer Science II Paul Bui
Computer Programming-1 CSC 111 Chapter 1 : Introduction.
Lecture 1 Introduction to Java MIT- AITI 2004 What is a Computer Program? For a computer to be able to do anything (multiply, play a song, run a word.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
CSCI 273: Processing An Introduction. Programming Languages –An abstract "human understandable" language for telling the computer what to do –The abstract.
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.
What is a Computer? An, electrical machine, that can be programmed to accept data (input), process it into useful information (output) and store it away.
Chapter 1 What is Programming? Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E.
Lecture 1 Introduction to Java MIT-AITI Ethiopia 2004.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and Server Side Programming Very rich GUI libraries Portability (machine independence) A.
CSC204 – Programming I Lecture 4 August 28, 2002.
Java and C# [this is a bonus – it is not a required lesson] ACO101: Introduction to Computer Science.
POS 406 Java Technology And Beginning Java Code
Java Programming, Second Edition Chapter One Creating Your First Java Program.
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
Lecture 3 January 14, 2002 CSC Programming I Fall 2001.
Lecture 8 February 29, Topics Questions about Exercise 4, due Thursday? Object Based Programming (Chapter 8) –Basic Principles –Methods –Fields.
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
CSC204 – Programming I Lecture 1 August 23, 2006.
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.
Copyright © Mohamed Nuzrath Java Programming :: Syllabus & Chapters :: Prepared & Presented By :: Mohamed Nuzrath [ Major In Programming ] NCC Programme.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and web applications Very rich GUI libraries Portability (machine independence) A real Object.
22-July-2002cse142-13B-Development © 2002 University of Washington1 Development Tools CSE 142, Summer 2002 Computer Programming 1
Chapter 1: An Overview of Computers and Programming Languages
Chapter 4 Software. Chapter 4: Software Generations of Languages Each computer is wired to perform certain operations in response to an instruction. An.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
Introduction to OOP CPS235: Introduction.
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,
Lecture1 Instructor: Amal Hussain ALshardy. Introduce students to the basics of writing software programs including variables, types, arrays, control.
Java How to Program, 9/e Presented by: José M. Reyes Álamo © by Pearson Education, Inc. All Rights Reserved.
1 Introduction Read D&D Sec 1.8; Sec 1.13 THE Java tutorial -
CS 177 Recitation Week 1 – Intro to Java. Questions?
Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
Lecture 1b- Introduction
Visit for more Learning Resources
Before You Begin Nahla Abuel-ola /WIT.
Object-Oriented Programming Using Java
Chapter 1 Introduction to Computers, Programs, and Java
Lecture 1: Introduction to JAVA
Introduction
Text by: Lambert and Osborne
Programming without BlueJ Week 12
Java programming lecture one
2.1. Compilers and Interpreters
Introduction to Java Dept. Business Computing University of Winnipeg
Hands-on Introduction to JAVA
IB Computer Science II Paul Bui
Computer Programming-1 CSC 111
Programming language translators
Presentation transcript:

1 CSC204 – Programming I Lecture 2 Intro to OOP with Java

2 Topics  Ways to compile and execute a program  Java’s approach  Considerations for software design  Object and class  [Running a simple Java program]

3 Automation Starts from Programs  What is a program?  How can the instructions defined in a program be executed? They need to be translated into machine code first public class AutomatedProcess { public static void main(String[] args) { System.out.println("Step #1"); System.out.println("Step #2"); System.out.println("Step #3"); }

4 processor A Simple Computer disk keyboard display printer memory

5 Compilation  The program’s source code is given to a program called a compiler.  The compiler checks that the source code is valid (obeys the rules of the language) and translates it to machine instructions for a particular CPU.  The compiled program (also know as executable) is stored in a file, and it can be run as many times as desired.

6 Compilation & Execution Compiled File (a.out) Source Code (xxx.c) text file saved on disk editor compile edit compiler Instructions in machine language CPU specific saved on disk Memory CPU load Execution Compilation Edition

7 Interpretation  The program’s source code is given to a program known as an interpreter.  The interpreter executes the program without first translating it to machine instructions.  The interpreter itself is normally a compiled program, so it can execute machine instructions corresponding to the source code.

8 Interpretation & Execution Internal file Source Code (xxx.c) text file editor interpret edit interpreter Instructions in machine language CPU specific CPU Interpretation & Execution Memory Edition

9 Problems w/ Networked Computers  Different machines are interconnected to each other in a interconnected farm of machines  Each of them may uses a different machine language  How can a program be executed on these different machines? System ASystem B X How can it run on System B? Compiled program compiled on System A

10 Java’s Approach - illustrated System ASystem BSystem N... JVM-A JVM-BJVM-N Compiled Java byte code (not in any specific machine language) Compiled once and runs everywhere

11 Java’s Approach  Java employs a combination of compilation and interpretation.  The Java compiler translates the original program into bytecode instructions for a computer called the Java Virtual Machine.  The resulting bytecode program is then executed by an interpreter.  One advantage of Java’s approach is that programs don’t need a particular CPU or operating system.

12 Bytecode program (xxx.class) Source Code (xxx.java) text file saved on disk editor compile edit Compiler (javac) Instructions in bytecode saved on disk CPU load Execution Compilation Bytecode and JVM Memory JVM interpret Edition

13 Ways to Handle Complexity  S/W can be considered as virtual machineries that automate some information processes  These systems consist of virtual s/w parts  Ways to handle the complexity Abstraction: consider only the essential aspect of a real world information process Encapsulation: don’t tell us how to make the ice cubes, just let us know which button to press to get them Modularity: I need a car with 4 wheels, two doors,... Hierarchy:  Composition: each book has a number of chapters, each...  Taxonomy: a bird is an animal that can fly, an eagle is...

14 Abstraction

15 Encapsulation

16 Modularity

17 Hierarchy: composition

18 Hierarchy: taxonomy

19 What is an Object?  An object is a s/w entity that can do something for other part of the s/w system (another object)  An object is a runtime entity, it only exists when the s/w system is in execution A class, or the template of objects of the same kind is defined by a program (source code) A class file (executable) is created as a result of compilation. It is loaded into memory when executed Objects can then be instantiated using the class definition

20 How Do Objects Work Each Other?  we can refer to the object that does sth a server, the one that requests the service a client  From the client perspective, how can you get the service (alarm)? Passing a message to the server (clock): clock, please set the alarm to 7 am sharp! Recipient service (or operation) additional info clock.setAlarm(7);  From the server’s perspective, it is responsible for Maintain certain properties: such the due time at which the alarm will ring Be able to perform certain operations: allowing clients to set alarm and starting the alarm at due time

21 Steps for Java Programming  Analysis  Design  Implementation Edit your code Compile your code  Testing Execute your code (using test data) [Debug your code]

22 A Quick Walkthrough  Open your favorite text editor (e.g. NotePad)  Copy the code snippet (on slide #3) into a blank text file  Save it as c:\myname\AutomatedProcess.java Create a folder c:\myname as shown in class  Open a DOS prompt  Change directory to the folder in which you saved the.java file  Type javac AutomatedProcess.java to compile  Type dir to check the bytecode executable you just created: AutomatedProcess.class  Type java AutomatedProcess to execute