Unformatted text preview:

Lecture 1 IDE is an integrated development environment (we use eclipse)!It does:text editor (type in program)compile (java -> machine code)run programrun debugger !CVS = concurrent versioning system (a place where you can stick files)1.2.3.4.Lecture 2 Computer systemsHardware – the physical componentsCPU = central processing unit (the brain)RAM = random access memory (main/primary memory)Holds information the computer is working on at the timeTemporary!FAST!A byte !!address !6533 !6534 !Secondary memoryPermanent storage of data!PERMANENT & SPACIOUSI/O devices = input/output devicesTouchscreen monitor is both input and outputSoftwareApplications – everything but the operating systemOperating system – a program that automatically runsProcess management: decides which process is running (usingCPU) at which time, it switches between processes so fast itlooks like the processes are running simultaneouslyMemory management: keeps track of which process is usingwhat block of memoryBasic I/OWindowing (GUIs)Basic network controlNetwork = a bunch of computers that can talk to each otherSecurity enforcement (passwords)Information storage with bytes and bitsa bit = a thing with 2 states (0 or 1)a byte = 8 sequential bitskilobyte = 1024 bytes (210)megabyte = 220 ~ 1mil bytes! gigabyte = 230 bytesIntegers are stored by converting the decimal number to base 2, positive andnegatives are represented by 2s complementFloating point numbers are stored by converting to scientific notation, and thenconverting the number and power of ten to binary, attaching them together andstoring in byte(s)Characters are stored using codes, which are then turned into binary. We nowuse Unicode (65536 symbols) rather than ASCII (256 symbols) because weneed more symbols for other languages!Software keeps track of what is where, we cannot tell from looking at a byte what!kind of information it holdsProgramming languages!CPU speaks machine code – 0s and 1s, where bits are instructions! Assembly language is basically machine but uses numonics!à efficient execution and use of space!à used in embedded devices like appliances1.••••2.••--- . . .1001101110010111!à used in embedded devices like appliances!each CPU has its own machine code/assembly language!Timeline of higher level languages!50s + early 60s !-- !FORTRAN (Science) + cobalt (Buisness)!late 60s !-- !Algol (fist language with modern features)!70s !-- !Pascal (Education)!80s !-- !C (efficient code, error prone)! à great, but procedurally oriented!late 80s !-- !C++ (object oriented C)! à “has sharp edges” aka mysterious bugs!90s !-- !JAVA became popular! à object oriented, idiot proof! à disadvantage: slow compared to C++!Object v. Procedure oriented languages!Object oriented languages center around nouns (for classes)!Procedure oriented languages center around verbs!The most important difference is that you can recycle classes in object!oriented programming!Polymorphism: you can extend and object oriented class and!modify (Add features) to it ! !!6/5/09Lecture 3 General!How many different combinations of 0s and 1s are there in a byte? 28!Every time you add a bit, it doubles the number of combinations!n bits give 2n combinations of 0s and 1s!Another advantage of Java is that it is portable, so it can run on different platforms!(computers/OS) Some basic definitions!Object !– principal entity manipulated by a program!Class !– design for an object!Method !– chunk of code with a name!à every program starts with the “main” method!Statement !– one instruction/step for the program to do!à ends with a semicolon Notes on Java programs!Comments:!/* */ can span many lines!// single line comment!Println v. print!Println puts the cursor on a new line (enter)!Typically, the compiler translates the program into machine code (creates an!executable), but executables are not portable. Thus, Java complies source code into byte!code (universal code that is half way between java and machine code but is not specific to!a platform). Then, the JVM (java virtual machine) translates and runs the byte code one!line at a time.!2 disadvantages:!(1) must have Java installed on your machine! (2) this is SLOW!Variable declaration (only do this once)!Type variable;!Creates a “box” in the stack with the name “variable”!Assignment statement!Variable = value;!Puts the value in the variable “box” in the stack!‘=’ is the assignment operator !variable!stack!Concatenation!Joining things together using the ‘+’ operator!Java can turn anything into a stringPrimitive types (8)!Integer types (4)!Long !– 8 bytes !range of values: -263-1 up to 263!int !– 4 bytes !range of values: -2 bil up to 2 bil!short !– 2 bytes !range of values: -32768 up to 32767!byte !– 1 byte !range of values: -128 up to 127!Floating point types (2) value!Floating point types (2)!Double !– 8 bytes !main advantage: more precision (sig. digits)!Float !– 4 bytes!Other types (2)!Char !– 2 bytes !stores one symbol (ex. ‘t’)!Boolean !– depends on JVM !true or false! Between 1 bit and 1 byte!!6/8/09Lecture 4 Programming errors!Syntax – something typed in wrong (not a java statement)!Logical – valid java program but malfunctionArithmetic Operators!+ !- !* !/ !%!modulus operator (returns remainder)Comparison operators!< !> !<= !>= !== !!=!return a booleanScanner!Allows you to get text from the user!Scanner x = new Scanner(System.in) //creates a new Scanner (object)!x.nextInt() //reads input!Possible reading commands:!nextInt(), nextDouble(), nextByte(), nextFloat(), nextBoolean()!next() //gets a string but stops when it gets to the first white space!nextLine() // reads until it reaches an enterInteger Division!Returns a truncated integer!¾ = 0Find the length of a String s!s.length()Compare objects (not just primative types)!Don’t use ==!Use x.equals(y)If and If/else statements!~~~~!~~~~!if (x>y){!~~~~~~!} else{!~~~~~~~!}!The stuff inside the if block may or may not run depending on whether the stuff in!parenthesis is true or false.Logical operators!! !&& !||!not !and !or unary operand !binary operators statement on right !2 operands!if (A || B){…} runs if A is true, B is true, or A and B are true!if(A && B) runs iff A and B are true!if (!x<y) same as if (x >= y)!if (!x.equals(y))!6/10/09Lecture 5 Short Circuiting!Java will not evaluate the clause on the right of a logical operator if it is


View Full Document

UMD CMSC 131 - Lecture notes

Documents in this Course
Set #3

Set #3

7 pages

Exam #1

Exam #1

6 pages

Exam #1

Exam #1

6 pages

Notes

Notes

124 pages

Notes

Notes

124 pages

Load more
Download Lecture notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?