midterm 1 theory review.txt

Card Set Information

midterm 1 theory review.txt
2015-03-03 20:15:23
diane cs140
diane cs140 midterm theory 1 review
Show Answers:

  1. Java is a(n) ______________ programming language.
    object oriented
  2. Programs are a __________ solution to a problem.
  3. The ________ method is where the program starts executing.
  4. In Java, logical blocks are enclosed by ____________.
    braces {}
  5. ____________ shows the nesting structure of a program and _______________ affect program correctness.
    Indentation, does not
  6. Comments _______ affect program correctness but proper documentation is essential for writing good clean code.
    do not
  7. A variable is a _________ for a __________ to store a ___________ of some ___________.
    name, place, value, type
  8. Variable names __________ case sensitive and can start with ___________, an ___________, or ______ but not with a _______.
    are, a letter, underscore, $, number
  9. The __________ of a variable is the part of the program where the variable is known and can be referenced.
  10. A variable can be declared _____________ times in non-nested blocks, but _________ in nested blocks.
    multiple, only once
  11. ____________ are used to keep values to be reused and changed throughout the run of the program.
  12. Variables can be of __________ type or ________ type.
    primitive, class
  13. Primitive variable types for integers - _________, ____________, _________, _________.
    byte, short, int, long
  14. Primitive variable types for numbers with precision - _________ and ___________.
    float, double
  15. Primitive type for single characters - ________.
  16. Primitive type for true or false - _________.
  17. String is a __________ type.
  18. Constants are _________.
  19. For primitive type variables _________ is comparison (results in true or false), while _____ is the assignment operator (changes the value of the variable).
    ==, =
  20. Assignment is ________-associative.
  21. ____________ is used to convert types.
    Type cast
  22. Type casting changes the ___________ value but not the __________ value.
    destination, source
  23. Dividing two integers results in a(n) _________ value.
  24. Typecasting an into to a double _________ precision, typecasting a double into an int ________ precision.
    adds, removes
  25. In the Java order of operations, the _________ minus precedes the typecast. The __________, ____________, _________ operations precede addition and subtraction.
    multiplication, division, remainder (modulo)
  26. _______________ happens last in the Java order of operations.
  27. Operations in parentheses happen ___________.
  28. The addition operation for Strings is called _____________.
  29. The method to replace a character in a String with another is called _________.
  30. The method to turn a String into all capital letters is called _____________.
  31. To return the character at a certain position of a String, use the __________ method.
  32. To find out how many characters are in a String, call ____________.
  33. Comparing String variables happens with the ___________ method.
  34. Certain characters (e.g. ",',\) are special. In order to include them in a String they need to be escaped with a _________.
    backslash \
  35. The first position in a String is at __________.
    0 zero
  36. The _____________ class is used to take user input from the keyboard or read input from a ______________.
    Scanner, text file
  37. Reading a String from the keyboard or file happens by calling the method ___________ on the Scanner type variable.
  38. The .nextInt() method reads a(n) ______________ from the keyboard or a text file, while .nextLine() fetches _______________.
    integer, the remainder of the line
  39. _________________________ displays output on the screen and moves to a new line.
  40. ___________________ displays formatted output by using ______________ for variables of the corresponding type.
  41. The placeholders for printf are _______ for Strings, _______ for integers, ______ for floats/doubles, _____ for newline.
    %s, %d, %f, %n
  42. A %.3f placeholder in a printf statement displays a floating point value with __________ numbers after the decimal point even if they are zeros.
  43. ___________________ terminates the program with a code - 0 means ________________, any other value denotes __________.
    System.exit(), normal completion, an error code
  44. The result of an if statement condition is ______________.
    true or false
  45. The _________ clause in selection statememts does not have a condition.
  46. Selection statements _________ be nested.
  47. If _______________ line has to be executed in a selection clause (if, else, or else if), those statements must be enclosed in a block marked by { and }.
    more than one
  48. The relational operators are ______, _______, and _________.
    <=, !=, and >
  49. The logical operators are __________, __________ and _______.
    &&, ||, !
  50. The logical operator _____ precedes the logical operator ________ in order of operations.
    &&, ||
  51. A ________ statement allows a control variable to be tested for a certain number of values (must be constants), each contained in a case.
  52. Each case in a switch must contain a __________ statement.
  53. The _______ case in a switch is executed when the value of the control variable is not equal to the value of any of the cases.
  54. The default case is _________.
  55. The ___________ class is a Java class that contains a number of static methods - e.g., abs, random, min, max, floor, sqrt.
  56. The Math.random() method returns a value between __________.
    0 (inclusive) and 1 (exclusive)
  57. Which loop types are top tested?
    While and for loops.
  58. Which loop type is bottom tested?
  59. Loops __________ be nested.
  60. Make sure to properly set the condition and update the loop control variable at the _______ of the loop iteration.
  61. A for loop updates the control variable at the _____ of the loop iteration.
  62. A ____________ loop will be executed at least once, whereas a _____________ may execute zero times.
    do-while, for / while
  63. What statement ends the innermost loop or switch?
  64. What statement ends the current iteration and proceeds to the next one?
  65. Exceptions are ___________ and _____________.
    thrown, caught
  66. The _________ block contains some code to attempt to execute.
  67. The _________ block contains the code to execute when that attempt fails.
  68. Trying to open a file that doesn't exist throws a _______________ exception.
  69. Scanner is the input Stream to fetch data from a text file, while _____________ is the output stream.
  70. After you are done writing to a file, you should ____________________.
    close the output stream