1 / 29

Lecture 1 Intro to Java Programming

Lecture 1 Intro to Java Programming. Richard Gesick. CHAPTER TOPICS. What is Programming? Basic Computer Concepts Data Representation Introduction to Programming Languages Introduction to Programming Programming Basics Program Design with Pseudocode Developing a Java Application.

mandar
Download Presentation

Lecture 1 Intro to Java Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 1Intro to Java Programming Richard Gesick

  2. CHAPTER TOPICS • What is Programming? • Basic Computer Concepts • Data Representation • Introduction to Programming Languages • Introduction to Programming • Programming Basics • Program Design with Pseudocode • Developing a Java Application

  3. What is Programming? • Creating an application such as a ticketing kiosk, a game, a restaurant ordering system or another business application. • Programming is a science • Many techniques have been developed for accomplishing basic programming tasks • Software engineering practices insure that the program is correct and maintainable • Programming is also creative • We get to solve problems

  4. Basic Computer Concepts • Hardware • Central Processing Unit • Memory and Storage Devices • Operating Systems • Application Software • Computer Networks and the Internet

  5. Typical Computer Hardware • CPU • executes the instructions of the program • Hard disk and CD-ROM • store instructions and data so program can be loaded into memory and executed • Main memory • stores the program instructions and data while executing • Keyboard and mouse • used for data input • Monitor • used to display output from a program • Other accessories, such as a printer

  6. A Typical Design of a Personal Computer

  7. Central Processing Unit (CPU) • Arithmetic Logic Unit • performs integer arithmetic and logical operations • Floating-point Unit • performs floating-point operations • Hardware registers • store data and memory addresses • Instruction Pointer • keeps track of next instruction to execute • Examples of CPUs: • Intel Pentium ™ dual-core E5400, Oracle Sun SPARC, Hewlett-Packard PA-RISC, IBM POWER processor

  8. CPU Instructions • Move data from one location to another • Perform a calculation • Compare data • Change the sequence of instructions to execute (the flow of control)

  9. CPU Speed • Rated in MHz or GHz • In one clock cycle, a CPU • fetches an instruction from memory, • decodes the instruction, or • executes the instruction • Pipelining allows overlap of operations to improve performance • 3.4-Ghz CPU can execute 3.4 billion instructions per second

  10. Memory or Storage Devices • Memory consists of cells that hold one bit. • A bit's value can be 0 or 1 • A byte is 8 binary digits (bits) • Storage capacity is expressed as: • Kilobytes (1,024 bytes) • Megabytes (1,048,576 bytes) • Gigabytes (1,073,741,824 bytes) • Terabytes ( 1.09951 x 1012 bytes)

  11. Operating System (OS) Software • OS boots when computer is turned on, and runs continuously • Controls the peripheral devices (disks, keyboard, mouse, etc.) • Supports multitasking (multiple programs executing simultaneously) • Allocates memory to each program • Prevents one program from damaging another program • Examples: Microsoft Windows, Linux, MacOS

  12. Application Software • Written to perform specific tasks • Runs "on top of" the operating system • Examples: word processor, spreadsheet, database management system, games, Internet browser, etc.

  13. Computer Networks • Networks connect two or more computers so they can share files or devices • Local Area Network (LAN) • computers located geographically close to one another • Servers provide services • access to database • downloading of files • email delivery • Clients use these services. • Most desktop computers are clients.

  14. The Internet • A network of networks • Evolved from the ARPANET military research project • Web servers deliver Internet content (web pages) to clients via a browser. • Web pages are identified using a URL (Uniform Resource Locator) • Domain Name System (DNS) Servers • translate a URL to an Internet Protocol (IP) address

  15. Data Representation • Binary Numbers • Expressed in base 2 system (two digits are 0 and 1) • Hexadecimal Numbers • Base-16 system used as shorthand for representing binary numbers • The Unicode Character Set • Used to represent characters

  16. Binary Equivalents of Decimal Numbers DecimalBinary Equivalent 0 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0100 7 01118 1000

  17. Powers of 2 DecimalDecimal 20 1 28 256 21 2 29 512 22 4 210 1,024 23 8 211 2,048 24 16 212 4,096 25 32 213 8,192 26 64 214 16,384 27 128 215 32,768

  18. Decimal (base 10) numbers A decimal number can be represented as the sum of powers of 10 (the base) with coefficients in the base 10 alphabet (0 - 9) For example: 2485 = 2 * 103 + 4 * 102 + 8 * 101+ 5 * 100 2485 = 2 * 1000 + 4 * 100 + 8 * 10 + 5 * 1 2485 = 2000 + 400 + 80 + 5

  19. Converting From Decimal to Binary Just as a decimal number can be represented as a sum of powers of 10 (the base) with coefficients in the base 10 alphabet (0 to 9) A decimal number can be represented as the sum of powers of 2 (the base of the binary system) with coefficients in the base 2 alphabet (0 and 1) • So we need an algorithm to do that

  20. Converting From Decimal to Binary • Find the largest power of 2 that is smaller than or equal to the decimal number • Subtract that number from the decimal number • Insert 1 in the binary number for the position equivalent to that power of 2 • Repeat 1 - 3, until you reach 0

  21. Example: convert 359 to binary • Largest power of 2 that is smaller than 359 is 256 (28) • 359 - 256 = 103 so 359 = 28 * 1 + 103 • Largest power of 2 that is smaller than 103 is 64 (26) • 103 - 64 = 39 so 359 = 28 * 1 + 26 * 1 + 39 (continued on next slide)

  22. Example: convert 359 to binary • Largest power of 2 that is smaller than 39 is 32 (25) • 39 - 32 = 7 so 359 = 28*1 + 26*1 + 25*1 + 7 • Largest power of 2 that is smaller than 7 is 4 (22) • 7 - 4 = 3 so 359 = 28 * 1 + 26 * 1 + 25 * 1 + 22 * 1 + 3 (continued on next slide)

  23. Example: convert 359 to binary • Largest power of 2 that is smaller than 3 is 2 (21) • 3 - 2 = 1 so 359 = 28 * 1 + 26 * 1 + 25 * 1 + 22 * 1 + 21 * 1 + 1 • Largest power of 2 that is smaller than or equal to 1 is 1 (20) • 1 - 1 = 0, so we are finished

  24. Our Results • Insert a coefficient of 0 for any missing powers of 2 Thus, 359 = 28*1 + 27*0 + 26*1 + 25*1 + 24*0 + 23*0 + 22*1 + 21*1 + 20*1 Removing powers of 2, we get: 1 0 1 1 0 0 1 1 1 or 1 0110 0111

  25. Hexadecimal Numbers • Base-16 number system • Uses digits 0 - 9 and letters A – F • For example: C in hex represents 12 in decimal • One hexadecimal digit can express decimal values from 0 to 15 • Thus, one hexadecimal digit can represent 4 bits

  26. Hexadecimal - Binary Equivalents Hex Binary Hex Binary 0 0000 8 1000 1 0001 9 1001 2 0010 A 1010 3 0011 B 1011 4 0100 C 1100 5 0101 D 1101 6 0110 E 1110 7 0111 F 1111

  27. Examples Binary number: 0001 1010 1111 1001 Hex equivalent: 1 A F 9 Binary number: 1011 0011 1011 1110 Hex equivalent: B 3 B E

  28. The Unicode Character Set • Each character is stored as 16-bits • Maximum number of characters that can be represented: 65,536 (216) • ASCII character set (used by many programming languages) stores each character as 7 bits (maximum number of characters is 128). • For compatibility, first 128 characters of Unicode set represent the ASCII characters

  29. Some Unicode Characters CharacterDecimal ValueHex Value * 42 002A 1 49 0031 2 50 0032 A 65 0041 B 66 0042 a 97 0061 b 98 0062 } 125 007D

More Related