Download presentation
Presentation is loading. Please wait.
1
hardware bits and bytes Java
Introduction hardware bits and bytes Java
2
What we will do in this class
Understand how to control a computer with a programming language. Learn (and practice) strategies and techniques for programming. Learn and use Java.
3
Hardware and Software Hardware is the machine
CPU, monitor, keyboard, speakers, disks, chips Software is the programs that make the machine do things.
4
Memory the CPU is the chip that does the computation
RAM (processor memory) is the storage for programs and data that are in active use.
5
Input and output devices
Input devices: keyboard, mouse, touch part of touch screen, microphone,camera, hard drive, instruments like thermometers... Output devices: monitor, speakers, printer, hard drive, controllers ...
6
Analogue vs Digital Analogue - old record players, film cameras, speech Digital - audio CDs, digital cameras, written words
7
Binary Numbers How high can you count on your fingers? (Assuming 10 fingers)
8
How to count to 1023 on your fingers, (and why you will snicker at the number 4)
128 256 4 8 64 2 512 1 32 16 credit:
9
Bits and Bytes How many bits it takes to represent
the days of the week the months of a year one million different colors A byte is 8 bits. How many bytes would it take...
10
Storing Information 9278 9279 9280 9281 9282 9283 9284 9285 9286 Each memory cell stores a set number of bits (usually 8 bits, or one byte) Large values are stored in consecutive memory locations Copyright © 2012 Pearson Education, Inc.
11
From program to execution
Each CPU has its own machine language. Typically, a compiler converts a program to machine language. Different versions of the compiler for different machines.
12
From program to execution: Java
A Java compiler converts the program to bytecode - the same for all machines. An interpreter translates the bytecode to machine code and executes it.
13
Java Introduced in 1995 by Sun
Goal: programs that could be run on any computer, run over the web. Includes its own graphics, including GUIs. Object oriented language.
14
Program Example: Facts.java
credit: Lewis and Loftus
16
Comments
17
Comments // A single line comment /* This comment can be on many
lines */
18
class class body Class header
19
main method main method body main method header
20
printing System.out.println
semicolon ends each statement a string literal between the quotes
21
concatenation + to put two strings together, concatenation
22
concatenation a number gets converted to a string for concatenation
23
skipping a line no parameter, just prints a line
24
oops! Go from start to end, one command at a time. output:
We present the following facts foryour extracurricular edification: Letters in the Hawaiian alphabet: 12 Dialing Code for Antarctica: 672 Year in which Leonardo da Vinci invented the parachute: 1515 Speed of ketchup: 40 km per year Go from start to end, one command at a time.
25
Escape Sequences Special characters as part of a string:
\n newline \t tab \" quote \' single quote \\ backslash
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.