Download
computer science i 22c 016 106 n.
Skip this Video
Loading SlideShow in 5 Seconds..
Computer Science I 22C: 016/106 PowerPoint Presentation
Download Presentation
Computer Science I 22C: 016/106

Computer Science I 22C: 016/106

292 Views Download Presentation
Download Presentation

Computer Science I 22C: 016/106

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Computer Science I22C: 016/106 Jun Ni. Ph.D. Adjunct Assistant Professor Department of Computer Science The University of Iowa Iowa City, IA 52242

  2. Introduction • Computer science • Computer programming languages • Prerequisites: • access computer • installation of JDK 1.1 or later version (Java 2, SDK, from www.javasoft.com) • Editing Java codes using editing tools • textbook • Your commitment in learning programming

  3. Introduction • Computer basics (hardware and software) • Hardware: physical computer machine • CPU, or processor, chip • memory (primary, main, temporary) • disk memory (secondary, auxiliary, permanent) • Unit of memory: Byte (8 bits) • Address of memory, address of data is the first byte • input devices: keyboard, mouse, … • output devices: screen, monitor, printer, ...

  4. Introduction Binary Memory address (location) 01001010 2823454 01100001 2823455 01110110 2823456 01100001 2823457 00110001 2823458 00101110 2823459 00110010 2823410 (in unit of byte)

  5. Introduction Binary ASCII 01001010 J 01100001 a 01110110 v 01100001 a 00110001 1 00101110 . 00110010 2

  6. Introduction • Computer basics (hardware and software) • Software: programs give instructions to computer for computing • running or executing: processing to perform computing • input data and output result • Operating System: supervisory program OS and programs Input data Output result computer

  7. Introduction • High-Level Programming Languages • Lower-level programming Languages FORTRAN, C/C++, BASIC COBOL, Lisp, Ada (source codes) compilers Machine languages or assembly languages (object codes)

  8. Introduction • Java Byte code: • Java compiler translates Java programming language into byte code, which can be interpreted to computer’s machine language. • The interpreter is called Java Virtual Machine (JVM) which translates from byte-code instructions to machine language instructions. Compiler Java code Byte code Byte code Machine language (JVM)

  9. Introduction Java program Input data Java compiler Byte code interpreter (JVM) Machine-language instructions Execution of machine-language instructions output

  10. Introduction • Designing Programming (programming techniques) • methods used to solve problems (algorithm) • algorithm in computer science means a set of instructions for solving a problem • algorithm into pseudo-code, then then into programming language

  11. Introduction • Designing Programming (programming techniques) • Procedure programming (PP) • data (not cataloged) and computing procedure • Object-orient programming (OOP) • class: same kind of objects cataloged together • object: data (cataloged) behaviors (action or methods) • computing procedure • scalability of classes • testing and debugging

  12. Introduction • Errors • syntax error: mistakes caused due to the conflict of grammar rule of programming language • run-time error: errors occurs when program is running, system errors • logic error: errors happens due to the mistakes of logical design of the program

  13. Introduction • Java history • Java applications and Java applets • Java simple example public class FirstProgram { public static void main(String[] args) { System.out.println("Hello out there."); System.out.println("Want to talk some more?"); System.out.println("Answer y for yes or n for no.");

  14. char answerLetter; answerLetter = SavitchIn.readLineNonwhiteChar(); if (answerLetter == 'y') System.out.println("Nice weather we are having."); System.out.println("Good-bye."); System.out.println("Press enter key to end program."); String junk; junk = SavitchIn.readLine(); } }

  15. Introduction • OOP’s method invocation • syntax: • example: Object_Name.Method_Name(arguments) System.out.println("Press enter key to end program."); junk = SavitchIn.readLine( );

  16. Introduction • Naming in Java • identifier, names in program • case-sensitive • rules of identifier • convention

  17. Introduction • Reserved keywords: abstract break bytes case catch char class const continue default do double else extends final finally float for future generic goto if implements import innner instanceof long native new null operator package private protected

  18. Introduction • Reserved keywords (continued): public rest return short static supper switch synchronized this throw throws transient try var void volatile while

  19. Introduction • How to install JDK on a PC • download from www.javasoft.com • setting path and class path in PC's autoexec.bat REM setting for JDK 1.2 REM set PATH=c:\jdk1.2beta4\bin; %PATH%; REM set CLASSPATH=.;c:\jdk1.2beta4\lib; ;%CLASSPATH%; REM setting for JDK 1.3 (SDK) set PATH=c:\jdk1.3\bin;%PATH%; set CLASSPATH=.;c:\jdk1.3\lib;%CLASSPATH%;

  20. Introduction • How to install JDK on a Mac • download MRJ from www.apple.com • How to install install JDK on a UNIX (LINUX) platform (ask your system administrator)

  21. Introduction • How to compile a Java code on a PC or on UNIX (LINUX) • How to compile a Java code on a Mac • open "javac" program in MRJ, or drag your Java code to "javac" program javac JavaCode.java

  22. Introduction • How to execute a Java Byte code on PC or on a UNIX (LINUX) platform java JavaCode.java For Java application java JavaCode For Java applet appletviewer HTMLfile (which calls JavaCode)

  23. Introduction • How to execute JavaByte code on a Mac • open "Jbinary" program in MRJ, or drag your Java code to Jbinary program for Java applications • open "Apple Applet Runner" program in MRJ, or drag your Java code to "Apple Applet Runner" program for Java applets

  24. Introduction • Java commercial development tools (alternative and optional) • Microsoft's J++ • Bordland's JBuilder • Symantec's Café • IBM's Visual Age • Sun's Java Workshop • CodeWarrier • …

  25. Introduction • Homework Assignment: • Read chapter 1 of Walter Savitch's textbook • do self-test questions through 1 to 19 • Do Exercises 1 to 3, on Page 27 to 28 • Due date: Feb. 6, 2001