School

Purdue UniversityDepartment

Computer SciencesCourse Code

CS 18000Professor

Dunsmore BusterStudy Guide

FinalThis

**preview**shows pages 1-3. to view the full**32 pages of the document.**Purdue

CS 18000

FINAL EXAM

STUDY GUIDE

Only pages 1-3 are available for preview. Some parts have been intentionally blurred.

Only pages 1-3 are available for preview. Some parts have been intentionally blurred.

CS180 8/31/16:!

Numbers and Mathematical Operations

•CPUs work with values

-represented by literals and variables

-Literals: #, String, boolean, char

-Variables: location in memory (“camelNotation”)

•Types

•Variables and literals have types

•EX: int, double, string

•Type is a formal deﬁnition

•Set of values

•Set of operations on those values

•Java Type: Int

•Literals with no decimals.

•Uses “int” reserved word

•Type Categories in Java

•Primitive Types

•Built-into language

•boolean, byte, short, int, etc

•Occupy enough bits/bytes to store value

•Reference Types

•Can be deﬁned by the user

•Holds “reference” of an object

•Ex Reference Type: String

•Set of values

•Set of operations:

•concat() (also + operator)

•toUpperCase();

•length();

•substring();

•Plus many more

•Set of Values

•limited by memory only

•Set of operations also designated by user

•Variables and literals

•Variable: Memory location where something is stored, can change

•Literal: value cannot change, can be stored in variable

•Declarations

•In java, var must be declared and given a type

•Compiler does two things with this info:

•Arranges space to be allocated for variable

•Ensures that only valid operations are performed on the variable

•Integer Types in Java

•All represent subset of the integers

•Differ in how many bits

•Byte: 8 bits

•Short: 16 bits

find more resources at oneclass.com

find more resources at oneclass.com

###### You're Reading a Preview

Unlock to view full version

Only pages 1-3 are available for preview. Some parts have been intentionally blurred.

•Int: 32 bits

•Long: 64 bits

•Most popular: int

•Int/Int results in truncated result

•Real Number Types in Java

•Represent subsets of the real numbers

•Two types, differing in the # of bits used

•Float: 32 bits (“single precision”) [about 9 digits]

•double: 64 bits (“double precision”) [about 17 digits]

•Most popular: Double

•Operations:

•Mathematical (+,-,*,/)

•Math.pow(base, exponent)

•Math.log10(#)

•Trig functions, logs, etc

•Declaring and initializing Variables: Syntax

•int x; //declare only

•int x = 5 // declare and initialize

•Good practice:

•one variable per line

•Include comment describing purpose

•Expressions

•Combining variables, literals, and operators

•Usual mathematical precedence

•PEMDAS is followed

find more resources at oneclass.com

find more resources at oneclass.com

###### You're Reading a Preview

Unlock to view full version