ࡱ> vxu'` S bjbjLULU 54.?.?C%%%%%%%%>>>8>?,%|z>?>?>?>?>?r@r@r@ssssOFtVxf|$_hǁ|%@r@r@@@|%%>?>?4|WDWDWD@%>?%>?sWD@sWDWDo%%-s>?2? [?>A<p,s4|0|ploCoX-so%-sr@@WD@ @Sr@r@r@||CXr@r@r@|@@@@%d*'*' .3 %*'*'.3%%%%%%%%% Chapter 1 Introduction to Computers, Programs, and Java A computer is an electronic device that stores and processes data. A computer includes both hardware and software. In general, hardware is the physical aspect of the computer that can be seen, and software is the invisible instructions that control the hardware and make it work. The hardware of a computer consists of a CPU, cache, memory, hard disk, floppy disk, monitor, printer, and communication devices. Five major hardware components: CPU, Memory, Storage Devices, Input/Out Devices, and Communication Devices. CPU stands for Central Processing Unit. It is the brain of the computer. The unit of measurement of clock speed is the hertz (Hz), with 1 hertz equaling 1 pulse per second. The clock speed of a computer is usually stated in megahertz (MHz) (1 MHz is 1 million Hz). A bit is a binary digit 0 or 1. A byte is a sequence of 8 bits. Memory is like a work area for programs. Before a program is executed, it is brought into the memory. RAM stands for random-access memory. It is called RAM because a memory cell can be accessed directly. Memory size is measured in bytes. Disk size is measured in bytes. Memory is volatile, because information is lost when the power is turned off. Programs and data are permanently stored on storage devices and are moved, when the computer actually uses them, to memory, which is much faster than storage devices. The machine language is a set of primitive instructions built into every computer. This is the language understood by a computer and executed by a computer. Assembly language is a low-level programming language in which a mnemonic is used to represent each of the machine language instructions. Assembler is a software that translates assembly language into machine language. The high-level languages are English-like and easy to learn and program. The program written in a programming language is called a source program. An interpreter is a software that reads one statement from the source code, translates it to the machine code or virtual machine code, and then executes it right away A compiler is a software that translates a program in high-level language into machine language code. An interpreter reads one statement from the source code, and translates it to the machine code or virtual machine code, and then executes it right away. A compiler translates the entire source code into a machine code file, and the machine code file is then executed. The operating system (OS) is a program that manages and controls a computers activities. The examples of OS are Windows 98, NT, 2000, XP, or ME. Windows. Application programs such as an Internet browser and a word processor run on top of an operating system. Major responsibilities: Controlling and monitoring system activities Allocating and assigning system resources Scheduling operations Multiprogramming allows multiple programs to run simultaneously by sharing the CPU. Multithreading allows concurrency within a program, so that its subtasks can run at the same time. Multiprocessing, or parallel processing, uses two or more processors together to perform a task. Java was invented by a team led by James Gosling at Sun Microsystems in 1991. Originally called Oak, it became Java in 1995 when it was redesigned for developing Internet applications. Oracle bought Sun and Oracle now owns Java. Java applet is a special program that runs from a Web browser. Android uses the Java programming language. The Java language specification specifies the syntax for the Java language. JDK stands for Java Development Toolkit. IDE stands integrated development environment. NetBeans and Eclipse are not programming languages, nor dialects, nor extensions of Java. They are Java development tools. Keywords have specific meaning to the compiler and cannot be used for other purposes in the program such as variables or method names. Examples of keywords are class, static, and void. Java source code is case sensitive. Java keywords are always in lowercase. 30. Comments are used to document what a program is for and how a program is constructed. Comments help the programmers or users to communicate and understand the program. Comments are not programming statements and are ignored by the compiler. In Java, comments are preceded by two forward slashes (//) in a line or enclosed between /* and */ in multiple lines. When the compiler sees //, it ignores all text after // in the same line. When it sees /*, it scans for the next */ and ignores any text between /* and */. 31. System.out.println(string); 32. Output is 3.5 * 4 / 2 2.5 is 4.5 33. The source file extension is .java and the bytecode file extension is .class. 34. The input of a Java compiler is a Java source code file and the output is a Java class file. 35. javac is the JDK command to compile a program. 36. java is the JDK command to run a program. 37. JVM is the Java virtual machine that runs a Java program. 38. Java can run on any machine with a JVM. 39. Java interpreter cannot find the .class file. Make sure you placed the .class in the right place, and invoked java command with appropriate package name. 40. The class does not have a main method, or the signature of the main method is incorrect. 41. JOptionPane.showMessageDialog(null, Hello world); 42. The System class is in the java.lang package. This package is implicitly imported. So, there is no need to explicitly import it. 43. No performance difference. 44. public class Test { // Main method public static void main(String[] args) { /** Display outpput */ System.out.println("Welcome to Java"); } } 45. Syntax errors are detected by compilers. Runtime errors occur during execution of the program. Logic errors results in incorrect results. 46. See the text. Syntax error. Runtime error. Logic error. Line 2. Main should be main. Line 2. static is missing. Line 3: Welcome to Java! should be enclosed inside double quotation marks. Line 5: The last ) should be }. 51. public class Welcome { public static void main(String[] args) { System.out.println("morning"); System.out.println("afternoon"); } }     8 *; ?f;<Kglntz~ !"sȲȫȫ h3hk=CJOJQJ^JaJ)h3hk=B*CJOJQJ^JaJph h3hk=h3hk=OJQJh3h@OJQJ h3h+h3hgOJQJ^Jh3hg6OJQJ^Jh3hg6 h3hg h3h@48 ? I U w *PB)?W<{ & F & Fgdg & FgdgC R L !s6t>?gdk=ogdk= 8^8`gdk= 80^8`0oh`hgdk= 7$8$H$gdk=egdk=egd+ & Fgd+ & F_~ ! ^`gd$fh^h ^`gdk=u^gd$ft^gd$fs^gd$f oh^h`gdk= ohh^h`hgdk=h^hgdk= 8^8`gdk= ! žx`N`N#h3h>*CJOJQJ^JaJ/h3h5>*B* CJOJQJ^JaJphPh3hCJ^JaJh3h$fCJ^JaJ h3h$fh3h$fOJQJ^Jh3hk=OJQJh3hk=OJQJ^J h3hk=h3hk=>*CJh3hk=>*B*ph3fh3hk=5>*B* phPh3hk=>*B*phh3hk=>*? : > @ A B h^hrdgdpdgdqdgdlh`hgd$f h^h`gd$fgd$f^gd$f & Fgd$f ^`gd$f  , 7 @ A C D F G I J L M O P Q R S Žh$fh$fOJQJhjhU h3h@h3hOJQJ#h3h>*CJOJQJ^JaJ,h3h>*B*CJOJQJ^JaJph3fB C E F H I K L N O P Q R S  6$&m 30&PP/ =!"#$% vH`H 3Normal CJPJ_HaJmH nHsH tH@@@ Heading 1  5B*CJ @@@ Heading 2  5B*CJJ@J Heading 3 B* CJOJQJkH@@@ Heading 4 $<562@AR2 Heading 5B* 2@Ab2 Heading 6B* 2@a2 Heading 7B* J@J Heading 8^6OJQJkHJ @J Heading 9 ^6OJQJkHDA`D 3Default Paragraph FontViV  Table Normal :V 44 la (k`(3No List ,>@, Title$a$.B@. Body TextTOT PDd&56CJOJQJ_HkHmH sH tH JO"J FT d CJOJQJ_HkHmH sH tH O2 nlv$ & Fh>T^h`a$CJOJQJkHfOBf BL'  d^` CJOJQJ_HkHmH sH tH fORf BX'  d^` CJOJQJ_HkHmH sH tH VObV C1d]#>*CJOJQJ_HkHmH sH tH ROrR C2d]#>*CJOJQJ_HkHmH sH tH ZOZ CA``d]`^` CJOJQJ_HkHmH sH tH ROR CLHd]H CJOJQJ_HkHmH sH tH FOF CRd CJOJQJ_HkHmH sH tH VOV CXd]#>*CJOJQJ_HkHmH sH tH ^O^ EH$d^a$&56CJOJQJ_HkHmH sH tH l$@l Envelope Address!@ &+D/^@ CJOJQJkHJ%@J Envelope ReturnCJOJQJkHROR ETd^ CJOJQJ_HkHmH sH tH ROR EX d^ CJOJQJ_HkHmH sH tH NON FC !d#6CJOJQJ_HkHmH sH tH NO"N FN "d#5CJOJQJ_HkHmH sH tH NO2N HA #d#5CJOJQJ_HkHmH sH tH NOBN HB $d#5CJOJQJ_HkHmH sH tH NORN HC %d#5CJOJQJ_HkHmH sH tH NObN HD &d#5CJOJQJ_HkHmH sH tH NOrN HE 'd#5CJOJQJ_HkHmH sH tH >@> Normal Indent (^NON HF )d#5CJOJQJ_HkHmH sH tH NON HG *d#5CJOJQJ_HkHmH sH tH ROR IT+d` CJOJQJ_HkHmH sH tH ZOZ UL, d^ CJOJQJ_HkHmH sH tH ZOZ UX- d^ CJOJQJ_HkHmH sH tH `O` LC1.d]^#>*CJOJQJ_HkHmH sH tH \O\ LC2/d]^#>*CJOJQJ_HkHmH sH tH `O` LCX0d]^#>*CJOJQJ_HkHmH sH tH NON LH 1d#6CJOJQJ_HkHmH sH tH JO"J M1 2d CJOJQJ_HkHmH sH tH JO2J M2 3d CJOJQJ_HkHmH sH tH JOBJ M3 4d CJOJQJ_HkHmH sH tH JORJ M4 5d CJOJQJ_HkHmH sH tH JObJ M5 6d CJOJQJ_HkHmH sH tH JOrJ M6 7d CJOJQJ_HkHmH sH tH JOJ M7 8d CJOJQJ_HkHmH sH tH JOJ M8 9d CJOJQJ_HkHmH sH tH dOd MH":$d]^a$#6CJOJQJ_HkHmH sH tH ZOZ MN;d]^ CJOJQJ_HkHmH sH tH fOf NL'<  d^` CJOJQJ_HkHmH sH tH ZOZ NO=``d]`^` CJOJQJ_HkHmH sH tH POPnormal paragraph >` mHnHuZOZ numbered list ? OJQJkHmHnHufOf NX'@  d^` CJOJQJ_HkHmH sH tH ROR QQAd#5CJOJQJ_HkHmH sH tH ZO"Z SBB``d]`^` CJOJQJ_HkHmH sH tH dO2d SH"C$``d]`^`a$#6CJOJQJ_HkHmH sH tH VOBV table bodyD pOJQJkHmHnHuRORR TBEdx  CJOJQJ_HkHmH sH tH VObV TCFd #5CJOJQJ_HkHmH sH tH $O!r$ TEGB*NON TH Hd#6CJOJQJ_HkHmH sH tH ZOZ TII``d]`^` CJOJQJ_HkHmH sH tH NON TN Jd#5CJOJQJ_HkHmH sH tH && TOC 1K.. TOC 2 L^.. TOC 3 M`^`.. TOC 4 N^.. TOC 5 O^.. TOC 6 Pp^p.. TOC 7 Q ^ .". TOC 8 R ^ .. TOC 9 S ^ TOBT TST$da$#6CJOJQJ_HkHmH sH tH RORR TXUd  CJOJQJ_HkHmH sH tH ^Ob^ UCV d^#6CJOJQJ_HkHmH sH tH ZOrZ UDW d^ CJOJQJ_HkHmH sH tH VOV USX d^ CJOJQJ_HkHmH sH tH ZOZ WAY``d]`^` CJOJQJ_HkHmH sH tH 4@4 Header Z !4 @4 Footer [ !lOl ETNL*\ d^` CJOJQJ_HkHmH sH tH lOl ETNX*] d^` CJOJQJ_HkHmH sH tH hOh EL*^ d^` CJOJQJ_HkHmH sH tH NO"N LN _d#5CJOJQJ_HkHmH sH tH ROR TR`dx  CJOJQJ_HkHmH sH tH NON AU ad#6CJOJQJ_HkHmH sH tH dO"d Calloutb``d]`^` CJOJQJ_HkHmH sH tH `O2` FTNc``d]`^`#6CJOJQJ_HkHmH sH tH <Z@B< Plain Textd OJQJkHFP@RF Body Text 2e0^`0CJ6U@a6 Hyperlink >*B*phXOrX FGcontainer gdCJOJQJ_HmH sH tH dOd BL1'h  d^`CJOJQJ_HmH sH tH 0O0 T1i1$ OJQJaJ"O" BL2jO Tk(OA( RQlCJaJ<O< RQNm$ & Fa$ CJOJQJFV@F FollowedHyperlink >*B* phLC@L Body Text Indento80^8`0(O( RQ CDTp*O* RQ CDT1q*O"* RQ CDT2rdO2d .RQCDT1"s 5$7$8$9DH$]^ >*CJOJPJQJaJtH bOBb .RQCDT"t 5$7$8$9DH$]^ >*CJOJPJQJaJtH dORd .RQCDT2"u 5$7$8$9DH$]^ >*CJOJPJQJaJtH S4 ) ?  T@ 0E@ 0E@ 0E@0n@0n@0n@0n@0n@0n@0n08?IUw*PB ) ? W < { L !s6t>?_~ !?:>@ABCEFHIKLNOPQT0 0 0 0 0 0 0 0 0 0 0  0  0  0  0  0 0 0 0 0 0  0  0  0 0 0 0 0 0 0 0 0 0e0e0e00o00000000o00o0000o00o0s0t0t0t0t0t0u0o00000 0 0 0 000000l0q0p0p0p0p0r000 m0@000@000@000@000@0@000(8?IUw*PB ) ? W < { L !s6t>?_~ !?:>@ABCEHKNPQT 0 0 0 0 0 0 0 0 0 0 0  0  0  0  0  0 0 0 0 0 0  0  0  0 0 0 0 0 0 0 0 0 0e0e0e00o00000000o0@0o0000o00o0s0t0@t0@t0@t0@t0@u0o00000 0 0 0 00@0@0@0@0l0q0p0p0p0p0@r0@0@0 00K00K00K00K00@0K00 00  S B S R @  @H 0(  0(  B S  ?,̙TT9*urn:schemas-microsoft-com:office:smarttagsplace PR#LTPX+CCEEFFHIKLNOQTPZ  $+,2X^ ,CCEEFFHIKLNOQT3333333333333333333 ?  ; { N?:BCCEEFFHIKLNOQTCCEEFFHIKLNOQT vNXX՜t n3ZZVkk8lL+)h5b3ǀt4XQP2OSP\/{uy_raaP_nhRLFgek =tqV62rD͂vuz FW8x  |ʾ88^8`o(. ^`hH.  L ^ `LhH.   ^ `hH. xx^x`hH. HLH^H`LhH. ^`hH. ^`hH. L^`LhH.^`o(. ^`hH. pLp^p`LhH. @ @ ^@ `hH. ^`hH. L^`LhH. ^`hH. ^`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^`LhH.  0^`0OJQJo(.h^`OJQJo(hH L ^ `L.  ^ `.xx^x`.HLH^H`L.^`.^`.L^`L.h XX^X`OJQJo(h ((^(`OJQJo(oh   ^ `OJ QJ o(h   ^ `OJQJo(h ^`OJQJo(oh hh^h`OJ QJ o(h 88^8`OJQJo(h ^`OJQJo(oh ^`OJ QJ o(hh^h`.^`o(. ^`hH. pLp^p`LhH. @ @ ^@ `hH. ^`hH. L^`LhH. ^`hH. ^`hH. PLP^P`LhH.ek62rvuP2OSa{uy_0t4W8xZZt _nh5b3=tqX\ |L+) 8$                 $2e                 \RnC                          &                                   ބ        ֒        x        2         _]n# .3k=rgrn!tqj_+8"GIlgPT,\@(k"jf|$f =gdHtT@HP LaserJet Professional P1102wNe03:winspoolHP LaserJet Professional P1102wHP LaserJet Professional P11024 oXSDDMHP LaserJet Professional P1102w-(dR4HP LaserJet Professional P11024 oXSDDMHP LaserJet Professional P1102w-(dR4C8N#SP@Unknown G:Ax Times New Roman5Symbol3& :Cx Arial?5 :Cx Courier New71 CourierY CG TimesTimes New Roman;(SimSun[SOABook Antiqua7RKino MT;Wingdings"@hr,&\ .% , ,477N >qHP?]n2*CS 492 Chapter 1 Answers To Odd Questions Y. Daniel LiangDanielX              Oh+'0 (4 T ` lx,CS 492 Chapter 1 Answers To Odd Questions Y. Daniel LiangNormalDaniel46Microsoft Office Word@(@rd'@I%՜.+,0 hp|   , 7' +CS 492 Chapter 1 Answers To Odd Questions Title  !"$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdfghijklnopqrstwRoot Entry Fvv?yData 1Table#ǂWordDocument54SummaryInformation(eDocumentSummaryInformation8mCompObjq  FMicrosoft Office Word Document MSWordDocWord.Document.89q