GoConqr has a new look! Let us know what you think.

Flashcards

CIS 1030 - FlashCards

Heather Williams Computer Science English 100 cards

What will be the result of executing the following code?

Cards in this deck (100)

  1. 1Which of the following statements opens a file named MyFile.txt and allows you to append data to its existing contents?FileWriter fwriter = new FileWriter("MyFile.txt", true); PrintWriter outFile = new PrintWriter(fwriter);
  2. 2When an object is created, the attributes associated with the object are calledinstance fields
  3. 3What will be the value of x after the following code is executed?210What will be the value of x after the following code is executed?
  4. 4Which of the following strings could be passed to the DecimalFormat constructor to display 12.78 as 12.8%?0.00%
  5. 5Given the following statement, which statement will write the string "Calvin" to the file DiskFile.txt?diskOut.println("Calvin");Given the following statement, which statement will write the string "Calvin" to the file DiskFile.txt?
  6. 6What would be the value of discountRate after the following statements are executed?0What would be the value of discountRate after the following statements are executed?
  7. 7The ________ is ideal in situations where the exact number of iterations is known.for loop
  8. 8What will be the result of executing the following code?An array of 6 values, ranging from 0 through 5 and referenced by the variable x, will be created.What will be the result of executing the following code?
  9. 9What will be displayed when the following code is executed?45,678.26What will be displayed when the following code is executed?
  10. 10What will be the value of bonus after the following code is executed?1000What will be the value of bonus after the following code is executed?
  11. 11In an if-else statement, if the boolean expression is falsethe statement or block following the else is executed.
  12. 12Assume that inputFile references a Scanner object that was used to open a file. Which of the following while loops shows the correct way to read data from the file until the end of the file is reached?while (inputFile.hasNext())
  13. 13What would be the value of discountRate after the following statements are executed?0.04What would be the value of discountRate after the following statements are executed?
  14. 14A ________ is a boolean variable that signals when some condition exists in the program.flag
  15. 15You should not define a class field that is dependent upon the values of other class fieldsin order to avoid having stale data.
  16. 16Variables are classified according to theirdata type
  17. 17A class that is defined inside of another class is called a(n)inner class
  18. 18Because Java byte code is the same on all computers, compiled Java programsare highly portable.
  19. 19Java requires that the boolean expression being tested by an if statement be enclosed ina set of parentheses.
  20. 20The scope of a local variable isthe method in which they are defined.
  21. 21What will be returned from the method, if the following is the method header?the address of an object of the Rectangle classWhat will be returned from the method, if the following is the method header?
  22. 22How many bits are in a byte?8
  23. 23What will be the value of x after the following code is executed?100What will be the value of x after the following code is executed?
  24. 24If you do not provide initialization values for a class's numeric fields, they willbe automatically initialized with 0.
  25. 25________ operators are used to determine whether a specific relationship exists between two values.Relational
  26. 26Using a counter-controlled while loop, write Java code to compute the sum of the integers from 1 to 100, inclusively, and output that result to the console. You will declare the integer variable num to count the number of executions (in the counter-controlled loop) and initialize it to 1. You will also declare the integer variable sum to store your computation result and initialize it to 0. Be sure to print your result to the console.Using a counter-controlled while loop, write Java code to compute the sum of the integers from 1 to 100, inclusively, and output that res...
  27. 27How many times will the following for loop be executed?12How many times will the following for loop be executed?
  28. 28This type of loop will always be executed at least once.posttest
  29. 29Before entering a loop to compute a running total, the program should firstset the accumulator variable to an initial value, usually zero.
  30. 30Class objects normally have ________ that perform useful operations on their data, but primitive variables do not.methods
  31. 31After the header, the body of the method appears inside a set ofbraces, {}.
  32. 32A for loop normally performs which of these steps?update the control variable during each iteration, test the control variable by comparing it to a maximum/minimum value and terminate when the variable reaches that value, initialize a control variable to a starting value (ALL OF THESE IS ANSWER)
  33. 33In UML diagrams, what symbol indicates that a member is public?+ (Plus sign)
  34. 34How many times will the following do-while loop be executed?5How many times will the following do-while loop be executed?
  35. 35What would be the value of discountRate after the following statements are executed?0What would be the value of discountRate after the following statements are executed?
  36. 36A method (unsure of answer)may have zero or more parameter variables.
  37. 37What is the result of the following expression?5What is the result of the following expression?
  38. 38What will be the result of the following code?The value variable will contain the lowest value in the numbers array.What will be the result of the following code?
  39. 39A loop that executes as long as a particular condition exists is called a(n) ________ loop.conditional
  40. 40UML diagrams do not containobject names
  41. 41To print "Hello, world" on the monitor, use the following Java statement:System.out.println("Hello, world");
  42. 42If str1 and str2 are both String objects, which of the following expressions will correctly determine whether or not they are equal?str1.equals(str2)
  43. 43What will be displayed after the following code has been executed?120What will be displayed after the following code has been executed?
  44. 44The key word newcreates an object in memory.
  45. 45Which of the following expressions could be used to perform a case-insensitive comparison of two String objects named str1 and str2?str1.equalsIgnoreCase(str2)
  46. 46How many times will the following do-while loop be executed?1How many times will the following do-while loop be executed?
  47. 47What will be the value of x after the following code is executed?40What will be the value of x after the following code is executed?
  48. 48A UML diagram uses the ________ symbol to indicate that a member is private.-
  49. 49What will be the value of x after the following code is executed?15What will be the value of x after the following code is executed?
  50. 50Which of the following is not a rule that must be followed when naming identifiers?Identifiers can contain spaces.
  51. 51Identifiers can contain spaces.a set of instructions that enable the computer to solve a problem or perform a task.
  52. 52In all but rare cases, loops must contain within themselvesa way to terminate.
  53. 53A method's signature consists ofthe method name and the parameter list.
  54. 54What does the following UML diagram entry mean?a public method with a parameter of data type double that does not return a valueWhat does the following UML diagram entry mean?
  55. 55Using a for loop, write Java code that prints out all multiples of 5 from 0 to 100, inclusively, to the console.Need Answer - Q55
  56. 56A loop that repeats a specific number of times is known as a(n) ________ loop.count-controlled
  57. 57What will be displayed when the following code is executed?45,678.30What will be displayed when the following code is executed?
  58. 58What will be the values of ans, x, and y after the following statements are executed?ans = 60, x = 0, y = 50What will be the values of ans, x, and y after the following statements are executed?
  59. 59What would be the value of x after the following statements were executed?20What would be the value of x after the following statements were executed?
  60. 60When working with the PrintWriter class, which of the following import statements should you have near the top of your program?import java.io.*;
  61. 61The boolean expression in an if statement must evaluate totrue or false.
  62. 62This is a named storage location in the computer's memory.Variable
  63. 63Methods that operate on an object's fields are calledinstance methods
  64. 64The variable used to keep the running total is called a(n)accumulator
  65. 65If object1 and object2 are objects of the same class, to make object2 a copy of object1write a method for the class that will make a field by field copy of object1 data members into object2 data members.
  66. 66If you wish to use the System.out.printf method to print a string argument, use the ________ format specifier.%s
  67. 67A static field is created by placing the key word staticafter the access specifier and before the field's data type.
  68. 68Character literals are enclosed in ________, and string literals are enclosed in ________.single quotes, double quotes
  69. 69What will be the value of x after the following code is executed?15What will be the value of x after the following code is executed?
  70. 70Which of the following expressions determines whether the char variable chrA is not equal to the letter 'A'?chrA != 'A'
  71. 71A block of code is enclosed in a set ofbraces
  72. 72A class's responsibilities includeboth the things a class is responsible for knowing and the things a class is responsible for doing
  73. 73What is syntax?Rules that must be followed when writing a program.
  74. 74Which of the following statements opens a file named MyFile.txt and allows you to read data from it?File file = new File("MyFile.txt"); Scanner inputFile = new Scanner(file);
  75. 75What is the value of ans after the following code has been executed?The code contains an error and will not compile. **Need == in if condition.**What is the value of ans after the following code has been executed?
  76. 76The ________ statement is used to create a decision structure, which allows a program to have more than one path of execution.if
  77. 77Rewrite the following if-else if statement as a switch statement:Need Answer #77
    switch(letter)
    {
    case 'A':
    S.o.p.("You selected A.");
    break;
    case 'B':
    S.o.p.("You selected B.");
    break;
    case 'C':
    S.o.p.("You selected C.");
    break;
    case 'D':
    S.o.p.("You selected D.");
    break;
    default:
    S.o.p.("Please enter A,B,C, or D.");
    break;
    }
    Rewrite the following if-else if statement as a switch statement:
  78. 78What will be displayed when the following code is executed?(NEED RIGHT ANSWER) Q78
    30, 20, or 40
    What will be displayed when the following code is executed?
  79. 79What is the result of the following expression?7What is the result of the following expression?
  80. 80A search algorithmis used to locate a specific item in a larger collection of data.
  81. 81Overloading ishaving two or more methods with the same name, but different signatures.
  82. 82A constructorhas the same name as the class.
  83. 83Data hiding, which means that critical data stored inside the object is protected from code outside the object, is accomplished in Java byusing the private access specifier on the class fields.
  84. 84Which of the following expressions will determine whether x is less than or equal to y?x <= y
  85. 85When saving a Java source file, save it with an extension of.java.
  86. 86Another term for an object of a class is a(n)instance
  87. 87Which of the following statements determines whether temp is within the range of 0 through 100?if (temp >= 0 && temp <= 100)
  88. 88Using a switch statement, write Java code to output the season of the year to the console based on the value of an integer variable called month according to the following:Need Answer Q 88Using a switch statement, write Java code to output the season of the year to the console based on the value of an integer variable calle...
  89. 89What will be the result of the following code?Q89 (NEED ANSWER)What will be the result of the following code?
  90. 90A constructor is a method thatperforms initialization or setup operations.
  91. 91A group of related classes is called a(n)package
  92. 92Assuming that inputFile references a Scanner object that was used to open a file, which of the following statements will read an int from the file?int number = inputFile.nextInt();
  93. 93What does the following code do?It allows the user to enter the name of the file that data will to be written to.What does the following code do?
  94. 94The ________ loop is ideal in situations where you always want the loop to iterate at least once.do-while
  95. 95A ________ is a value that signals when the end of a list of values has been reached.sentinel
  96. 96________ is the term for the relationship created by object aggregation.Has a
  97. 97Which Scanner class method reads a String?nextLine
  98. 98Enclosing a group of statements inside a set of braces createsa block of statements.
  99. 99This statement tells the compiler where to find the JOptionPane class and makes it available to your program.import javax.swing.JOptionPane;
  100. 100Which of the following is not a valid Java comment?*/ Comment 2 /*

Information

Description
Computer Science Flashcards on CIS 1030 - FlashCards, created by Heather Williams on 28/06/2018.
Views
1
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?