Preview

Computer Science Study Guide

Good Essays
Open Document
Open Document
1031 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Computer Science Study Guide
I. Three Key Concepts:
a. Abstraction: Taking a simpler view of a complex entity by selectively ignoring details.
b. Procedure: An unambiguous step-by-step description of how to carry out a task
c. Representation: An unambiguous plan for how to build an object from simpler objects.
II. Greatest Common Divisor (GCD)
a. Given two positive integers a and b, find the largest integer that divides both a and b.
III. Representation and Abstraction
a. An Integer is represented as a sequence of (0s and 1s) according to the binary number system.
b. For large integers, this can get complicated especially in the two’s complement representation for signed integers.
c. Abstraction allows us ignore the representation details of an integer, and simply think of it as a number.

Variable
The name used to refer to a memory location that contains a value of a particular.

What’s in a name?
In Java, a variable name
Must have at least one character
First character must be a letter, _ , or $
Remaining characters must be letters, digits, _ , or $
Cannot be the same as a keyword (e.g. main, int)

Data Type
Valid Operators
Example Literals int + - * / %
== != < > =
42 159 0 -18 double + - * /
== != < > =
1.5 2.9e-8
-17.5 3.3334 boolean && || ! true false
String
+
“hi” “ ”

Variable Declaration
A statement that “declares” one or more variable, giving each a name and associating each with a data type.

String courseDescription;

Assigning an initial value is optional, but generally a good idea.

Boolean offeredFallSemester = true;

Declaring multiple variables in one statement is allowed but discourged.

int numberOfStudents = 174, numberOfTAs = 6;

Expression
A small piece of program code that represents or computes a value of a particular type.

Variables and Expressions
After a variable is declared and initialized, it can then be used in expressions

int

You May Also Find These Documents Helpful

Related Topics