midterm 1 theory review.txt

Card Set Information

Author:
dimeng
ID:
297475
Filename:
midterm 1 theory review.txt
Updated:
2015-03-03 20:15:23
Tags:
diane cs140
Folders:
diane,cs140
Description:
diane cs140 midterm theory 1 review
Show Answers:

Home > Flashcards > Print Preview

The flashcards below were created by user dimeng on FreezingBlue Flashcards. What would you like to do?


  1. Java is a(n) ______________ programming language.
    object oriented
  2. Programs are a __________ solution to a problem.
    general
  3. The ________ method is where the program starts executing.
    main
  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.
    scope
  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.
    Variables
  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 - ________.
    char
  16. Primitive type for true or false - _________.
    boolean
  17. String is a __________ type.
    class
  18. Constants are _________.
    final
  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.
    right
  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.
    integer
  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.
    Assignment
  27. Operations in parentheses happen ___________.
    first
  28. The addition operation for Strings is called _____________.
    concatenation
  29. The method to replace a character in a String with another is called _________.
    .replace()
  30. The method to turn a String into all capital letters is called _____________.
    .toUpperCase()
  31. To return the character at a certain position of a String, use the __________ method.
    .charAt()
  32. To find out how many characters are in a String, call ____________.
    .length()
  33. Comparing String variables happens with the ___________ method.
    .equals()
  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.
    .next()
  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.
    System.out.println()
  40. ___________________ displays formatted output by using ______________ for variables of the corresponding type.
    System.out.printf()
  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.
    three
  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.
    else
  46. Selection statements _________ be nested.
    can
  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.
    switch
  52. Each case in a switch must contain a __________ statement.
    break
  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.
    default
  54. The default case is _________.
    optional
  55. The ___________ class is a Java class that contains a number of static methods - e.g., abs, random, min, max, floor, sqrt.
    Math
  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?
    do-while
  59. Loops __________ be nested.
    can
  60. Make sure to properly set the condition and update the loop control variable at the _______ of the loop iteration.
    end
  61. A for loop updates the control variable at the _____ of the loop iteration.
    end
  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?
    break;
  64. What statement ends the current iteration and proceeds to the next one?
    continue
  65. Exceptions are ___________ and _____________.
    thrown, caught
  66. The _________ block contains some code to attempt to execute.
    try
  67. The _________ block contains the code to execute when that attempt fails.
    catch
  68. Trying to open a file that doesn't exist throws a _______________ exception.
    FileNotFound
  69. Scanner is the input Stream to fetch data from a text file, while _____________ is the output stream.
    PrintWriter
  70. After you are done writing to a file, you should ____________________.
    close the output stream

What would you like to do?

Home > Flashcards > Print Preview