Exam 1 cs

  1. CPU
    Brain of computer. Uses instructions from memory. Speed measured in gigahertz
  2. Bits (binary digits)
    Stores data. 0s and 1s (on and off switches)
  3. Byte
    The minimum storage in a computer. Holds 8 bits, some numbers can’t just fit into one, and characters as a series.
  4. Memory
    • Stores program instructions for CPU to execute.
    • Volatile- info is lost w/o power.
  5. Storage devices
    Permanent storage of programs and data. ie disk
  6. Monitor
    Displays information. Resolution, dot pitch
  7. Communication devices
    NIC network interface card- connects computer to LAN.
  8. How are programs written?
    Programming language- computer language- software
  9. Machine language
    Primitive instructions (binary code). Very hard to read
  10. Assembly language
    Low level language, hard to read but not as hard as machine language. Uses ASSEMBLER
  11. High level language
    Like java or python. Human language, easiest to read
  12. Programs written in high level language
    Source code/program.
  13. Interpreter
    Translates and executes one statement of source code into machine code in one step.
  14. Compiler
    Translates entire source code into bytecode, then interpreter interprets and executes that into machine code. Two steps
  15. Operating systems
    Manage and control computer activity.
  16. How can we use java
    To develop and deploy apps on the internet for servers, desktop computers, and hand held devices
  17. 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
  18. API
    Application Programmer interface. Usable features that provide functionality while programming
  19. JDK
    Java development kit. Software for creating, compiling, and debugging programs.
  20. JRE
    Java runtime environment. Necessary with JDK and includes JVM. Software that runs java programs
  21. IDE
    Software to create, edit, compile, debug, execute code, and test code
  22. Components of a java program
    • Class
    • Main method
    • Statements
    • Statement terminator
    • Reserved words
    • Comments
    • Blocks
  23. How is a character value declared
    With single quotations ‘ ‘
  24. JVM
    Interprets byte code into machine code
  25. Syntax error
    Detected by compiler
  26. Runtime error
    Causes program to abort
  27. Logic error
    Incorrect result
  28. 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
  29. How to approach programming problems
    • Read/analyze problem
    • Design solution
    • Code a solution
    • Run code
    • Test and debug
  30. Variable
    H
  31. Primitive types
    Built in data types (int double char)
  32. Pseudo code
    Mix of language and code
  33. How to create scanner object?
    Scanner name = new Scanner(System.in);
  34. Steps for reading input from console
    • Import scanner
    • Create scanner object
    • Prompt text
    • Store value
  35. Assignment operator
    = ... does not mean equality. Variable on left side.
  36. Variables
    Must be declared before giving value
  37. Named constants
    Variables cannot be changed using final keyword. All caps, use underscore.

    final double PI = 3.14159;
  38. Naming variables and methods
    Use camelCase
  39. Naming classes
    CapitalizeFirstWord
  40. Data type order and bit count
    • Byte- 8
    • Short- 16
    • Int- 32
    • Long- 64
    • Float- 32
    • Double - 64
  41. What is a literal
    Can be letters string too. A number value that appears directly (ie. 34 with; int number = 34;)
  42. Augmented assignment ops
    • Addition- +=
    • Mod - %=

    Makes it so you don’t have to write variable name again (num = num + 8) = (num += 8)
  43. 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
  44. 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
  45. 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)
  46. 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
  47. Java order of operations
    • Parenthesis
    • Operators ( *, /, %) - if several left to right
    • Addition subtraction
  48. How to get total milliseconds since epoch?
    System.currentTimeMillis();
  49. Naming Boolean type
    Should be able to read variable and answer with true or false
  50. Expression vs statement
    Expression has no semicolon , any code that evaluates to a result
  51. Selections
    Conditional statements based on Boolean expressions (Boolean hasValue = true) or (hasValue >= 0)
  52. One way if
    • If true - executes
    • If false- blank
  53. Two way if
    • If true- executes a block
    • If falso- executes different block
  54. Nested if
    • If
    • If
    • Else
  55. Multi way if statements
    • If score > 90
    • A
    • else if score > 80 b
  56. Simplify if (number % 2 == 0)
    even = true
    else
    even = false
    boolean even = number % 2 == 0
  57. 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);
  58. Logical operators
    • !- not
    • &&- and
    • || - or
    • ^ - xor
  59. Why use switch statement
    It’s an if else that checks against a single quality. Don’t forget default means else
  60. 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
  61. 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
  62. 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
  63. API
    Application programmer interface- provides usable features to improve overall functionality while in programming process
  64. IDE
    Integrated development environment- provides an environment that lets you create, edit, compile, debug, and execute code
  65. JDK
    Java development kit- encompasses tools needed to compile, debug, execute, and test code. Source code- bytecode- machine code
  66. JRE
    Java runtime environment- encompasses tools needed to interpret and execute code such as the JVM. Bytecode- machine code
  67. 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
  68. What purpose does the main method serve?
    It’s the entry point for all programs
  69. 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
  70. fix this code:
    final MaxPossibleValue int = 365;
    final int MAX_POSSIBLE_VALUE = 365;
  71. Runtime error
    Code compiles but terminated program execution abruptly with an error
  72. Syntax error
    Code does not compile
Author
timmymorin
ID
352567
Card Set
Exam 1 cs
Description
Updated