* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Savitch Java Ch. 1
Java performance wikipedia , lookup
Programming language wikipedia , lookup
Stream processing wikipedia , lookup
Structured programming wikipedia , lookup
Reactive programming wikipedia , lookup
Abstraction (computer science) wikipedia , lookup
Falcon (programming language) wikipedia , lookup
Interpreter (computing) wikipedia , lookup
Assembly language wikipedia , lookup
Go (programming language) wikipedia , lookup
Week 1 Introduction to Computers and Java Background information » important regardless of programming language Introduction to Java 1 Computer Basics Computer system: hardware + software Hardware: the physical components Software: the instructions that tell the hardware what to do 2 Common Hardware Components Standard Hardware Organization » Central Processing Unit » Interprets and executes the instructions (main & auxiliary) (such as mouse and keyboard) Processor (CPU) Memory » main & auxiliary » holds data and instructions Memory Input Devices Processor (CPU) Output Devices (such as video display or printer) Input device(s) » mouse, keyboard, etc. Output device(s) » video display, printer, etc. CPU and memory are physically housed together 3 Physical Organization Keyboard Monitor Chassis » » » » » CPU memory disk drives I/O connectors etc. 4 Running a Program Program—a set of instructions for a computer to follow Program Data (input for the program) Computer Output 5 Many Types of Programs User-created applications Existing applications » » » » word-processor/editor web browser compiler or assembler etc. Operating System » DOS, Microsoft Windows, MacOS, Linux, UNIX, etc. 6 Various Types of User Interfaces Command-line » type in key words and letters » DOS, Linux, and UNIX Menu » parts of DOS and Windows GUI (Graphical User Interface) » click on icon » also called “event-driven” » MacOS, Windows 7 Programming Language Hierarchy High-Level Language (HLL) Assembly Language Machine Language Hardware 8 The highs and lows of programming languages ... High-Level Language (HLL) » closest to natural language » words, numbers, and math symbols » not directly understood by hardware » “portable” source code (hardware independent) » Java, C, C++, COBOL, FORTRAN, BASIC, Lisp, Ada, etc. Machine Language (lowest level) » least natural language for humans, most natural language for hardware » just 0s and 1s » directly understood by hardware » not portable (hardware dependent) 9 Assembly Language (middle level) a more or less human readable version of machine language words, abbreviations, letters and numbers replace 0s and 1s easily translated from human readable to machine executable code like machine code, not portable (hardware dependent) 10 Object-Oriented Programming: OOP A design and programming technique Some terminology: » object - usually a person, place or thing (a noun) » method - an action performed by an object (a verb) » type or class - a category of similar objects (such as automobiles) Objects have both data and methods Objects of the same class have the same data elements and methods Objects send and receive messages to invoke actions 11 Example of an Object Class Class: Automobile Data Items: » » » » » » » » manufacturer’s name model name year made color number of doors size of engine odometer miles miles per gallon Methods: » Define data items (specify manufacturer’s name, model, year, etc.) » Change a data item (color, engine, etc.) » Display data items » Calculate cost » Calculate mpg 12 Inheritance Inheritance—a way of organizing classes Term comes from inheritance of traits like eye color, hair color, and so on. Classes with properties in common can be grouped so that their common properties are only defined once. 13 An Inheritance Hierarchy Vehicle Automobile Sedan Motorcycle Sports Car School Bus Bus Luxury Bus What properties does each vehicle inherit from the types of vehicles above it in the diagram? 14 Algorithms Algorithm - a set of instructions (steps) for solving a problem. » must be precise » must be complete May be in a number of different formats » natural language (such as English) » a specific programming language » a diagram, such as a flow chart » pseudocode - a mix of natural and programming language 15 Example of an Algorithm Algorithm that determines the total cost of a list of items: 1. Write the number 0 on the blackboard. 2. Do the following for each item on the list: --Add the cost of the item to the number on the blackboard. --Replace the old number on the board by this sum. 3. Announce that the answer is the number written on the board 16 Testing and Debugging Even with careful programming, your code could still contain errors and must be thoroughly tested. Bug—a mistake in a program Debugging—finding mistakes in a program and (possibly) fixing them 17 The Java Programming Language History 1991 - James Gosling, Sun Microsystems, Inc. originally a language for programming home appliances later (1994) used for World Wide Web applications (since byte code can be downloaded and run without compiling it) eventually used as a general-purpose programming language (for the same reason as above plus it is objectoriented) Why the name “Java”? Not sure - it may just be a name that came during a coffee break and it had not been copyrighted, yet. 18 Applets vs. Java Applications Applets » Java programs intended to be downloaded via the Web and run immediately » “little applications” » requires a web browser Applications » Java programs intended to be installed then run » often larger applications Slightly different programming for each, but both are easy to do 19