-
CPU
Brain of computer. Uses instructions from memory. Speed measured in gigahertz
-
Bits (binary digits)
Stores data. 0s and 1s (on and off switches)
-
Byte
The minimum storage in a computer. Holds 8 bits, some numbers can’t just fit into one, and characters as a series.
-
Memory
- Stores program instructions for CPU to execute.
- Volatile- info is lost w/o power.
-
Storage devices
Permanent storage of programs and data. ie disk
-
Monitor
Displays information. Resolution, dot pitch
-
Communication devices
NIC network interface card- connects computer to LAN.
-
How are programs written?
Programming language- computer language- software
-
Machine language
Primitive instructions (binary code). Very hard to read
-
Assembly language
Low level language, hard to read but not as hard as machine language. Uses ASSEMBLER
-
High level language
Like java or python. Human language, easiest to read
-
Programs written in high level language
Source code/program.
-
Interpreter
Translates and executes one statement of source code into machine code in one step.
-
Compiler
Translates entire source code into bytecode, then interpreter interprets and executes that into machine code. Two steps
-
Operating systems
Manage and control computer activity.
-
How can we use java
To develop and deploy apps on the internet for servers, desktop computers, and hand held devices
-
What JDK edition do we use in class? What do the other ones do?
Java Standard edition (SE)- client based.
But there is Java enterprise edition (EE)- for servers and Micro edition (ME) - for mobile devices
-
API
Application Programmer interface. Usable features that provide functionality while programming
-
JDK
Java development kit. Software for creating, compiling, and debugging programs.
-
JRE
Java runtime environment. Necessary with JDK and includes JVM. Software that runs java programs
-
IDE
Software to create, edit, compile, debug, execute code, and test code
-
Components of a java program
- Class
- Main method
- Statements
- Statement terminator
- Reserved words
- Comments
- Blocks
-
How is a character value declared
With single quotations ‘ ‘
-
JVM
Interprets byte code into machine code
-
Syntax error
Detected by compiler
-
Runtime error
Causes program to abort
-
Logic error
Incorrect result
-
How is a java program created compiled and executed
JDK. Source code compiled into bytecode by compiler (javac) and that bytecode is ran through JVM to produce result
-
How to approach programming problems
- Read/analyze problem
- Design solution
- Code a solution
- Run code
- Test and debug
-
-
Primitive types
Built in data types (int double char)
-
Pseudo code
Mix of language and code
-
How to create scanner object?
Scanner name = new Scanner(System.in);
-
Steps for reading input from console
- Import scanner
- Create scanner object
- Prompt text
- Store value
-
Assignment operator
= ... does not mean equality. Variable on left side.
-
Variables
Must be declared before giving value
-
Named constants
Variables cannot be changed using final keyword. All caps, use underscore.
final double PI = 3.14159;
-
Naming variables and methods
Use camelCase
-
Naming classes
CapitalizeFirstWord
-
Data type order and bit count
- Byte- 8
- Short- 16
- Int- 32
- Long- 64
- Float- 32
- Double - 64
-
What is a literal
Can be letters string too. A number value that appears directly (ie. 34 with; int number = 34;)
-
Augmented assignment ops
Makes it so you don’t have to write variable name again (num = num + 8) = (num += 8)
-
Software development process and purpose
- Requirement specification -user/designer talk
- System analysis- input process output (IPO)
- System design- IPO
- Implementation- translating design to programs
- Testing- requirements satisfied and no bugs
- Deployment- available to use
- Maintenance- changing and improving
-
Common errors
- Undeclared/uninitializing/misspelling variables
- Integer overflow- using out of bounds values
- Round off errors- using floating point
- Integer division- won’t produce decimal
- Redundant input- creating 2 scanners
-
When would you use long data type vs integer and how to write?
If writing an integer bigger than 2 billion (such as national debt) use long data type and append with “L”. (long num = 22L)
-
When would you use float data type vs double and how to write it?
Float is less accurate (rounding off) and only necessary for looks. Append number like 100.4F or 100.4f
-
Java order of operations
- Parenthesis
- Operators ( *, /, %) - if several left to right
- Addition subtraction
-
How to get total milliseconds since epoch?
System.currentTimeMillis();
-
Naming Boolean type
Should be able to read variable and answer with true or false
-
Expression vs statement
Expression has no semicolon , any code that evaluates to a result
-
Selections
Conditional statements based on Boolean expressions (Boolean hasValue = true) or (hasValue >= 0)
-
One way if
- If true - executes
- If false- blank
-
Two way if
- If true- executes a block
- If falso- executes different block
-
-
Multi way if statements
- If score > 90
- A
- else if score > 80 b
-
Simplify if (number % 2 == 0)
even = true
else
even = false
boolean even = number % 2 == 0
-
How to generate random numbers? (Ex 1-10)
- double randNum = Math.random()
- Scale it- randNum * 11 // values below 11
- Cast scaled number as integer // gets whole number
double randNum = (int)(Math.random() * 11);
-
Logical operators
- !- not
- &&- and
- || - or
- ^ - xor
-
Why use switch statement
It’s an if else that checks against a single quality. Don’t forget default means else
-
How would a ternary operator be used and read
minVal = (a < b) ? a : b;
If a is less than b, assign a to minVal, else assign b
-
Name at least one piece of hardware and how it affects running code
CPU is brain of computer and retrieve data from memory to use. In newer models, cpu and process at gigahertz levels of speed, which makes retrieving and using data when processing code faster
-
Why are assembly languages/programming languages necessary
Programming languages allow us to talk to computers, but must be assembled into bytecode before they can be interpreted into machine code
-
API
Application programmer interface- provides usable features to improve overall functionality while in programming process
-
IDE
Integrated development environment- provides an environment that lets you create, edit, compile, debug, and execute code
-
JDK
Java development kit- encompasses tools needed to compile, debug, execute, and test code. Source code- bytecode- machine code
-
JRE
Java runtime environment- encompasses tools needed to interpret and execute code such as the JVM. Bytecode- machine code
-
What is the import statement generally used for in java programs
To import functions that aren’t standard with the main method, they wrap around it
-
What purpose does the main method serve?
It’s the entry point for all programs
-
What types of tasks can the debugger be used for
Can be used to point out errors and current values of variables so we can go value-by-value and determine if where there was a logic, syntax, or runtime error made
-
fix this code:
final MaxPossibleValue int = 365;
final int MAX_POSSIBLE_VALUE = 365;
-
Runtime error
Code compiles but terminated program execution abruptly with an error
-
Syntax error
Code does not compile
|
|