Lecture 8 February 29, 2000. Topics Questions about Exercise 4, due Thursday? Object Based Programming (Chapter 8) –Basic Principles –Methods –Fields.

Slides:



Advertisements
Similar presentations
Chapter 16 Java Virtual Machine. To compile a java program in Simple.java, enter javac Simple.java javac outputs Simple.class, a file that contains bytecode.
Advertisements

Chapter 2 Machine Language.
Khaled A. Al-Utaibi  Computers are Every Where  What is Computer Engineering?  Design Levels  Computer Engineering Fields  What.
 Computer hardware components are the physical pieces of the computer.  The major hardware components of a computer are: – The central processing.
CSCE 145: Algorithmic Design I Chapter 1 Intro to Computers and Java Muhammad Nazmus Sakib.
CMPT 300: Operating Systems I Dr. Mohamed Hefeeda
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
Chapter 2 Machine Language. Machine language The only language a computer can understand directly. Each type of computer has its own unique machine language.
CHAPTER 4 COMPUTER SYSTEM – Von Neumann Model
1 Fall 2008ACS-1903 Chapter 1 Topics Java History Java Programs Why Program? Computer Systems: Hardware and Software Programming Languages What Is a Program.
1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming.
Chapter 2: Impact of Machine Architectures What is the Relationship Between Programs, Programming Languages, and Computers.
Elements of the Computer (How a processor works)
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 Memory Model of A Program, Methods Overview l Memory Model of JVM »Method Area »Heap »Stack.
Processor Types And Instruction Sets Barak Perelman CS147 Prof. Lee.
Software Development and Software Loading in Embedded Systems.
CS 0008 Day 2 1. Today Hardware and Software How computers store data How a program works Operators, types, input Print function Running the debugger.
Lecture 13 - Introduction to the Central Processing Unit (CPU)
COMP Computer Basics Yi Hong May 13, 2015.
Intro to Java The Java Virtual Machine. What is the JVM  a software emulation of a hypothetical computing machine that runs Java bytecodes (Java compiler.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Chapter Introduction to Computers and Programming 1.
Chapter 3.1:Operating Systems Concepts 1. A Computer Model An operating system has to deal with the fact that a computer is made up of a CPU, random access.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Topics Introduction Hardware and Software How Computers Store Data
How Java Programs Work MIS 3023 Business Programming Concepts II The University of Tulsa Professor: Akhilesh Bajaj All slides in this presentation ©Akhilesh.
CS 1308 Computer Literacy and the Internet Computer Systems Organization.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
COMP2011 Assembly Language Programming and Introduction to WRAMP.
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
CISC105 General Computer Science Class 1 – 6/5/2006.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
4-1 Chapter 4 - The Instruction Set Architecture Department of Information Technology, Radford University ITEC 352 Computer Organization Principles of.
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.
Computer Systems Organization CS 1428 Foundations of Computer Science.
Introduction to Computer Systems and the Java Programming Language.
1 CSC204 – Programming I Lecture 2 Intro to OOP with Java.
Your First Java Application Chapter 2. 2 Program Concepts Modern object-oriented programs help us build models to manage the complexity found in a problem.
CS 346 – Chapter 1 Operating system – definition Responsibilities What we find in computer systems Review of –Instruction execution –Compile – link – load.
4-1 Chapter 4 - The Instruction Set Architecture Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Principles.
Interrupts By Ryan Morris. Overview ● I/O Paradigm ● Synchronization ● Polling ● Control and Status Registers ● Interrupt Driven I/O ● Importance of Interrupts.
GCSE Information Technology Computer Systems 2 Hardware is the name that is given to any part of a computer that you can actually touch. An individual.
Memory The CPU in the computer fetches data and instructions from memory to process. This type of memory is called primary memory and it is the only memory.
1 Programming Fundamentals How to Program in C++ How to Program in C++
Lecture 3 Classes, Structs, Enums Passing by reference and value Arrays.
Object Oriented Software Development 4. C# data types, objects and references.
Today… “Hello World” ritual. Brief History of Java & How Java Works. Introduction to Java class structure. But first, next slide shows Java is No. 1 programming.
Chapter 1 Introduction. Components of a Computer CPU (central processing unit) Executing instructions –Carrying out arithmetic and logical operations.
Ch 1 - Introduction to Computers and Programming Hardware Terminology Main Memory Auxiliary Memory Drives Writing Algorithms Using Pseudocode Programming.
Simple ALU How to perform this C language integer operation in the computer C=A+B; ? The arithmetic/logic unit (ALU) of a processor performs integer arithmetic.
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
Object and Classes อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา Chapter 3.
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. Introduction to Computers and Computing.
Hello world !!! ASCII representation of hello.c.
Copyright © 2014, 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Eighth Edition by Tony Gaddis,
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Operating Systems A Biswas, Dept. of Information Technology.
Introduction To Computer Programming – 1A Computer Parts, Words, and Definition Herriman High School.
PCs ENVIRONMENT and PERIPHERALS Lecture 3. operating system and other system software that control the usage of the computer equipment application programs.
Chapter 1: Introduction to Computers and Programming
Topic 2: Hardware and Software
Java Programming: From the Ground Up
Lecture 1 Runtime environments.
Chapter 1: Introduction to Computers and Programming
Lecture 1 Runtime environments.
A Top-Level View Of Computer Function And Interconnection
Presentation transcript:

Lecture 8 February 29, 2000

Topics Questions about Exercise 4, due Thursday? Object Based Programming (Chapter 8) –Basic Principles –Methods –Fields –Memory Structures

Understanding Objects: Basic Principles Need to know the difference between classes and objects. Need to know how classes are represented on disk and how classes and objects are represented in the computer’s memory. –Need to know about memory and disk. Need to know how to define classes and how to instantiate them to produce objects. Need to know ways to define, declare, and reference fields (variables) and methods.

Computers and Virtual Machines Memory (RAM) Processor (CPU) Instructions and DataResults Disk Input Output LoadStore

Processor/Memory/Disk Processor interprets instructions, which are encoded as binary numbers. –Fetch an instruction from memory. –Interpret (execute) it. –Repeat previous two steps forever. Memory (RAM) consists of bytes, each of which has an associated address. Disk is non-volatile (retains information when turned off), and less expensive than RAM. But slower to access.

Memory Holds the instructions to be interpreted. –Instructions correspond to method definitions. –Never need more than one copy of a method in memory because the instructions never change. Holds the operands (data) that the instructions operate on. –Operands correspond to fields (variables). –Variable names correspond to memory addresses. Addresses aren’t really there. (Like “third house from the corner.”)

Some Synonyms Input – Copy information from disk to memory. –Read - when getting part of a file, like a line of text. –Load - when getting a program to be executed. Output – Copy information from memory to disk. –Write - when outputting a piece of information. –Print - when the destination is a terminal window or a printer rather than a disk file. Load – Copy information from memory to CPU. –Read – generic substitute for “load.” –Fetch – when getting an instruction to execute. Store – Copy information from CPU to memory. –Write – generic substitute for “store.”

Java Virtual Machine (JVM) Software that interprets JVM instructions. –Could be hardware, like a real CPU, but isn’t. –There are JVMs for lots of different real CPUs, not just Intel’s or Sun’s. –Allows the same binary instructions to run on different real CPUs. Uses real I/O devices, not simulated ones. Examples –java.exe –appletviewer.exe –Web browsers

Classes When you write a Java “program” you define one or more classes. –The java compiler generates one disk file for each class, with a filename consisting of the class name followed by “.class” In order to do anything with a class, its class file first has to be loaded into memory. –Transfer contents of the.class file into RAM. –Link the class with other classes already in the Java Virtual Machine’s RAM.

Objects Once a class has been loaded, you can create objects that are instances of the class. –Classes may be instantiated zero, one, or multiple times, depending on the needs of a particular program. –Instantiation is always done using the new operator. Allocate memory for the object’s fields. Initialize the fields. Invoke a constructor to complete initialization. –Compiler provides a default constructor that takes no arguments if the class doesn’t have any constructors defined explicitly.

Static and Instance Fields Defined inside a class, but outside any method. –Static fields have the static modifier. –Instance fields do not have the static modifier. An instance field is created when a new object is created. –The memory for an instance field is inside the memory allocated for the object. There can be zero, one, or multiple copies of an instance field in memory, depending on how many times a class has been instantiated. A static field is created when a class is loaded. –The memory for a static field is inside the memory for the class. There is never more than one copy of a static field in memory because a particular class is loaded into memory just once.

Static and Instance Methods All methods are defined inside classes. –Static methods have the static modifier. –Instance methods do not have the static modifier. An instance method is one that is associated with a particular object. –It refers to its own instance’s fields by name. –Or by using a special reference variable named this. A static method is not associated with an object. –Sometimes called a “class method.” Both kinds are loaded into memory exactly one time, when the class file is loaded. –Instance methods receive this as an extra hidden parameter when invoked (called).

An Object in Memory Reference Variable Class Pointer Instance Field Static Field This part is created when the class is instantiated This part is created when the class file is loaded into memory method

Multiple Objects of One Class

Sample Code [ Lecture_8.java ]Lecture_8.java [ Output From Running Class Lecture_8 ]Output From Running Class Lecture_8