Chapter 1 Introduction to Java

1 of
Published on Video
Go to video
Download PDF version
Download PDF version
Embed video
Share video
Ask about this video

Page 1 (0s)

1. Chapter 1 Introduction to Computers, Programs, and Java.

Page 2 (7s)

2. Objectives. To understand computer basics, programs, and operating systems (§§1.2–1.4). To describe the relationship between Java and the World Wide Web (§1.5). To understand the meaning of Java language specification, API, JDK, and IDE (§1.6). To write a simple Java program (§1.7). To display output on the console (§1.7). To explain the basic syntax of a Java program (§1.7). To create, compile, and run Java programs (§1.8). To use sound Java programming style and document programs properly (§1.9). To explain the differences between syntax errors, runtime errors, and logic errors (§1.10). To develop Java programs using NetBeans (§1.11). To develop Java programs using Eclipse (§1.12)..

Page 3 (43s)

3. What is a Computer?. A computer consists of a CPU, memory, hard disk, floppy disk, monitor, printer, and communication devices ..

Page 4 (54s)

4. CPU. The central processing unit (CPU) is the brain of a computer. It retrieves instructions from memory and executes them. The CPU speed is measured in megahertz (MHz), with 1 megahertz equaling 1 million pulses per second. The speed of the CPU has been improved continuously. If you buy a PC now, you can get an Intel Pentium 4 Processor at 3 gigahertz (1 gigahertz is 1000 megahertz)..

Page 5 (1m 13s)

5. Memory. Memory is to store data and program instructions for CPU to execute. A memory unit is an ordered sequence of bytes, each holds eight bits. A program and its data must be brought to memory before they can be executed. A memory byte is never empty, but its initial content may be meaningless to your program. The current content of a memory byte is lost whenever new information is placed in it..

Page 6 (1m 35s)

6. How Data is Stored?. Data of various kinds, such as numbers, characters, and strings, are encoded as a series of bits (zeros and ones). Computers use zeros and ones because digital devices have two stable states, which are referred to as zero and one by convention. The programmers need not to be concerned about the encoding and decoding of data, which is performed automatically by the system based on the encoding scheme. The encoding scheme varies. For example, character ‘J’ is represented by 01001010 in one byte. A small number such as three can be stored in a single byte. If computer needs to store a large number that cannot fit into a single byte, it uses a number of adjacent bytes. No two data can share or split a same byte. A byte is the minimum storage unit..

Page 7 (2m 15s)

7. Storage Devices. Memory is volatile, because information is lost when the power is off. Programs and data are permanently stored on storage devices and are moved to memory when the computer actually uses them. There are three main types of storage devices:Disk drives (hard disks and floppy disks), CD drives (CD-R and CD-RW), and Tape drives..

Page 8 (2m 34s)

8. Output Devices: Monitor. The monitor displays information (text and graphics). The resolution and dot pitch determine the quality of the display..

Page 9 (2m 45s)

9. Monitor Resolution and Dot Pitch. The screen resolution specifies the number of pixels in horizontal and vertical dimensions of the display device. Pixels (short for “picture elements”) are tiny dots that form an image on the screen. A common resolution for a 17-inch screen, for example, is 1,024 pixels wide and 768 pixels high. The resolution can be set manually. The higher the resolution, the sharper and clearer the image is..

Page 10 (3m 13s)

10. Communication Devices. A regular modem uses a phone line and can transfer data in a speed up to 56,000 bps (bits per second). A DSL (digital subscriber line) also uses a phone line and can transfer data in a speed 20 times faster than a regular modem. A cable modem uses the TV cable line maintained by the cable company. A cable modem is as fast as a DSL. Network interface card ( NIC ) is a device to connect a computer to a local area network (LAN). The LAN is commonly used in business, universities, and government organizations. A typical type of NIC, called 10BaseT , can transfer data at 10 mbps (million bits per second)..

Page 11 (3m 42s)

11. Programs. Computer programs , known as software , are instructions to the computer. You tell a computer what to do through programs. Without programs, a computer is an empty machine. Computers do not understand human languages, so you need to use computer languages to communicate with them. Programs are written using programming languages..

Page 12 (4m 0s)

12. Programming Languages. Machine Language Assembly Language High-Level Language.

Page 13 (4m 22s)

13. Programming Languages. Machine Language Assembly Language High-Level Language.

Page 14 (4m 44s)

14. Programming Languages. Machine Language Assembly Language High-Level Language.

Page 15 (4m 59s)

15. Popular High-Level Languages.

Page 16 (5m 6s)

16. Interpreting/Compiling Source Code. A program written in a high-level language is called a source program or source code . Because a computer cannot understand a source program, a source program must be translated into machine code for execution. The translation can be done using another programming tool called an interpreter or a compiler ..

Page 17 (5m 22s)

17. Interpreting Source Code. An interpreter reads one statement from the source code, translates it to the machine code or virtual machine code, and then executes it right away, as shown in the following figure. Note that a statement from the source code may be translated into several machine instructions..

Page 18 (5m 41s)

18. Compiling Source Code. A compiler translates the entire source code into a machine-code file, and the machine-code file is then executed, as shown in the following figure..

Page 19 (5m 55s)

19. Operating Systems. The operating system (OS) is a program that manages and controls a computer’s activities. The popular operating systems for general-purpose computers are Microsoft Windows, Mac OS, and Linux. Application programs, such as a Web browser or a word processor, cannot run unless an operating system is installed and running on the computer..

Page 20 (6m 13s)

20. Why Java?. The answer is that Java enables users to develop and deploy applications on the Internet for servers, desktop computers, and small hand-held devices. The future of computing is being profoundly influenced by the Internet, and Java promises to remain a big part of that future. Java is the Internet programming language. Java is a general purpose programming language. Java is the Internet programming language..

Page 21 (6m 34s)

21. Java, Web, and Beyond. Java can be used to develop standalone applications. Java can be used to develop applications running from a browser. Java can also be used to develop applications for hand-held devices. Java can be used to develop applications for Web servers..

Page 22 (6m 50s)

22. Java’s History. James Gosling and Sun Microsystems Oak Java, May 20, 1995, Sun World HotJava The first Java-enabled Web browser Early History Website:.

Page 23 (7m 5s)

23. Characteristics of Java. Java Is Simple Java Is Object-Oriented Java Is Distributed Java Is Interpreted Java Is Robust Java Is Secure Java Is Architecture-Neutral Java Is Portable Java's Performance Java Is Multithreaded Java Is Dynamic.

Page 24 (7m 22s)

24. Characteristics of Java. Java Is Simple Java Is Object-Oriented Java Is Distributed Java Is Interpreted Java Is Robust Java Is Secure Java Is Architecture-Neutral Java Is Portable Java's Performance Java Is Multithreaded Java Is Dynamic.

Page 25 (7m 42s)

25. Characteristics of Java. Java Is Simple Java Is Object-Oriented Java Is Distributed Java Is Interpreted Java Is Robust Java Is Secure Java Is Architecture-Neutral Java Is Portable Java's Performance Java Is Multithreaded Java Is Dynamic.

Page 26 (8m 11s)

26. Characteristics of Java. Java Is Simple Java Is Object-Oriented Java Is Distributed Java Is Interpreted Java Is Robust Java Is Secure Java Is Architecture-Neutral Java Is Portable Java's Performance Java Is Multithreaded Java Is Dynamic.

Page 27 (8m 26s)

27. Characteristics of Java. Java Is Simple Java Is Object-Oriented Java Is Distributed Java Is Interpreted Java Is Robust Java Is Secure Java Is Architecture-Neutral Java Is Portable Java's Performance Java Is Multithreaded Java Is Dynamic.

Page 28 (8m 49s)

28. Characteristics of Java. Java Is Simple Java Is Object-Oriented Java Is Distributed Java Is Interpreted Java Is Robust Java Is Secure Java Is Architecture-Neutral Java Is Portable Java's Performance Java Is Multithreaded Java Is Dynamic.

Page 29 (9m 11s)

29. Characteristics of Java. Java Is Simple Java Is Object-Oriented Java Is Distributed Java Is Interpreted Java Is Robust Java Is Secure Java Is Architecture-Neutral Java Is Portable Java's Performance Java Is Multithreaded Java Is Dynamic.

Page 30 (9m 21s)

30. Characteristics of Java. Java Is Simple Java Is Object-Oriented Java Is Distributed Java Is Interpreted Java Is Robust Java Is Secure Java Is Architecture-Neutral Java Is Portable Java's Performance Java Is Multithreaded Java Is Dynamic.

Page 31 (9m 39s)

31. Characteristics of Java. Java Is Simple Java Is Object-Oriented Java Is Distributed Java Is Interpreted Java Is Robust Java Is Secure Java Is Architecture-Neutral Java Is Portable Java's Performance Java Is Multithreaded Java Is Dynamic.

Page 32 (9m 50s)

32. Characteristics of Java. Java Is Simple Java Is Object-Oriented Java Is Distributed Java Is Interpreted Java Is Robust Java Is Secure Java Is Architecture-Neutral Java Is Portable Java's Performance Java Is Multithreaded Java Is Dynamic.

Page 33 (10m 1s)

33. Characteristics of Java. Java Is Simple Java Is Object-Oriented Java Is Distributed Java Is Interpreted Java Is Robust Java Is Secure Java Is Architecture-Neutral Java Is Portable Java's Performance Java Is Multithreaded Java Is Dynamic.

Page 34 (10m 12s)

34. Characteristics of Java. Java Is Simple Java Is Object-Oriented Java Is Distributed Java Is Interpreted Java Is Robust Java Is Secure Java Is Architecture-Neutral Java Is Portable Java's Performance Java Is Multithreaded Java Is Dynamic.

Page 35 (10m 29s)

35. JDK Versions. JDK 1.02 (1995) JDK 1.1 (1996) JDK 1.2 (1998) JDK 1.3 (2000) JDK 1.4 (2002) JDK 1.5 (2004) a. k. a. JDK 5 or Java 5 JDK 1.6 (2006) a. k. a. JDK 6 or Java 6 JDK 1.7 (2011) a. k. a. JDK 7 or Java 7 JDK 1.8 (2014) a. k. a. JDK 8 or Java 8.

Page 36 (10m 52s)

36. JDK Editions. Java Standard Edition (J2SE) J2SE can be used to develop client-side standalone applications or applets. Java Enterprise Edition (J2EE) J2EE can be used to develop server-side applications such as Java servlets, Java ServerPages, and Java ServerFaces. Java Micro Edition (J2ME). J2ME can be used to develop applications for mobile devices such as cell phones. This book uses J2SE to introduce Java programming..

Page 37 (11m 12s)

37. Popular Java IDEs. NetBeans Eclipse.

Page 38 (11m 19s)

38. A Simple Java Program. // This program prints Welcome to Java! public class Welcome }.

Page 39 (11m 38s)

39. Creating and Editing Using NotePad. To use NotePad, type notepad Welcome.java from the DOS prompt..

Page 40 (11m 55s)

40. Creating and Editing Using WordPad. To use WordPad, type write Welcome.java from the DOS prompt..

Page 41 (12m 13s)

41. Create/Modify Source Code Source code (developed by the programmer) Saved on the disk public class Wel come { public static void args) { System come to Java! " ) ; Bytecode (generated by the compiler for JVM to read and interpret) Method Welcome ( ) O aload_O Method void main(java.1ang.StringÜ) O getstatic #2 3 Idc #3 <String "Welcome to Java! 5 invokevi rtual #4 8 return "Welcome to Java is displayed on the console Wel come to Java! Source Code Compile Source Code e.g., javac Welcome. java If compile errors occur Stored on the disk Bytecode Run Bytecode e.g., java Welcome Result If runtime errors or incorrect result.

Page 42 (12m 44s)

42. Compiling Java Source Code. You can port a source program to any machine with appropriate compilers. The source program must be recompiled, however, because the object program can only run on a specific machine. Nowadays computers are networked to work together. Java was designed to run object programs on any platform. With Java, you write the program once, and compile the source program into a special type of object code, known as bytecode . The bytecode can then run on any computer with a Java Virtual Machine, as shown below. Java Virtual Machine is a software that interprets Java bytecode..

Page 43 (13m 15s)

Enter main method. 43. // This program prints Welcome to Java! public class Welcome }.

Page 44 (13m 27s)

Execute statement. 44. // This program prints Welcome to Java! public class Welcome }.

Page 45 (13m 35s)

print a message to the console. 45. // This program prints Welcome to Java! public class Welcome }.

Page 46 (13m 44s)

46. Two More Simple Examples. Run. WelcomeWithThreeMessages.

Page 47 (13m 54s)

47. Supplements on the Companion Website. See Supplement I.B for installing and configuring JDK See Supplement I.C for compiling and running Java from the command window for details www.cs.armstrong.edu/liang/intro10e.

Page 48 (14m 9s)

48. Compiling and Running Java from the Command Window.

Page 49 (14m 34s)

49. Compiling and Running Java from TextPad. See Supplement II.A on the Website for details.

Page 50 (14m 45s)

50. Anatomy of a Java Program. Class name Main method Statements Statement terminator Reserved words Comments Blocks.