Name: Class: Date: Here are all the questions from all your previous tests. Your exam will be made up of some of these questions. Use these to study from. Remember - all the answers are contained in your textbook. Possible Exam Questions True/False Indicate whether the sentence or statement is true or false. 1. An overflow error occurs when there are not enough bits to hold the mantissa. 2. Ergonomics is the science that studies copyright infringement. 3. The physical components of the computer are called software. 4. A multiuser OS allows for more than one user at the same time. 5. Cross-platform connectivity is the ability for one PC to use more than one input device. 6. WANs are used to connect devices over large geographical distances. 7. The largest and most widely accessed network is the Internet. 8. Outlook is an example of e-mail software. 9. A citation gives credit to the original author. 10. The illegal copying of software is called piracy. 11. The equal sign operator is used to assign a new value to a variable. 12. Values represented by the double data type are referred to as floating point. 13. The statement numplayers += 2; is the same as numplayers = numplayers + 2; 14. A run-time error is also called a syntax error. 15. The statement system.out.println("hello world!"); will generate a syntax error. 16. A run-time error halts program execution at the statement that cannot be executed. 17. The condition of an if statement is a Boolean expression. 18. A set of statements that perform a task over and over again based on a condition is called a loop structure. 19. Each execution of a loop is called an iteration. 20. The ++ operator is used in a for statement to automatically increment a counter by 2 during each loop iteration. 21. A method must include parameters. 22. Data passed to a method is called a parameter. 23. The return type void means that the method will return a value. 24. A method declaration contains the statements that implement the method. 25. Multiple parameters are separated by semicolons. 1
Name: 26. The order of the arguments passed to a procedure need to correspond to the order of the parameters declared in the procedure. 27. The number of arguments in a method call must match the number of parameters in the method declaration. 28. A method can return a value. 29. The return statement is used to send a value back to the calling statement. 30. Method overloading means that an application contains more than 10 methods. 31. Files are used to store the data generated by an application. 32. An exception is an error affecting execution. 33. The try statements are statements that could possibly generate an exception. 34. The file stream keeps track of the file position. 35. The end of file is indicated by 0. 36. A file on disk is a set of characters, even if the file contains numeric data. 37. Numeric data from a file must be converted to int or double values before it can processed. 38. A BufferedWriter class object is used to send text to the input file stream. 39. Writing objects to a file is called object deserialization. 40. The ObjectOutputStream class contains methods for writing primitive data types. Multiple Choice Identify the letter of the choice that best completes the statement or answers the question. 41. Which processes data and controls the flow of data between the computer s other units? a. CPU c. ROM b. USB d. SRAM 42. SRAM (Static Access RAM) is also referred to as a. ROM. c. cache. b. integrated circuits. d. clock rate. 43. Operating system software a. is a combination of hardware and software that works together to allow computers to exchange data. b. is network security hardware that prevents unauthorized network access. c. is software that enables the user to communicate with the computer. d. is a series of related web pages. 44. In which type of network topology is each node attached to a hub? a. bus topology c. ring topology b. star topology d. client topology 45. How many states do the electrical circuits on an IC (integrated circuit) have? a. one: on c. four: + - * / b. two: on, off d. three: on, off, wait 2
Name: 46. Which prevents unauthorized network access? a. a hub c. a firewall b. a router d. a cookie 47. An ISDN is a a. cable modem. c. subscriber line. b. conventional modem. d. digital telephone network. 48. Which programming language is considered a third generation programming language (3GL)? a. machine language c. SQL b. assembly language d. C 49. Which programming language is considered an object-oriented language? a. Fortran c. SQL b. Java d. C 50. Computer memory capacity and file size are measured in a. bytes. c. nanoseconds. b. inches. d. codes. 51. Which of the following represent correctly-formed comments? I. // Happy II. /* Sorry /* III. /* Wise */ a. I only c. I and III only b. I and II only d. III only 52. Which is a valid declaration statement? a. int height int width; c. int height; width; b. int height, width; d. int height, int width; 53. Which statement assigns the value 15 to radius? a. radius = 15; c. 15 = radius; b. radius == 15; d. 15radius; 54. What is the result of the following expression when x is 125? x%6 a. 0 c. 20 b. 5 d. 20.5 55. What happens to the decimal portion of a number when a double is cast to an int? a. The decimal portion is truncated. c. Nothing, a syntax error occurs. b. The decimal portion is rounded. d. The value 0.5 is added to the number. 56. Which type of error occurs in statements that are syntactically correct, but produce undesired or unexpected results? a. syntax error c. run-time error b. semantic error d. exception error 3
Name: 57. Which code segment displays the circle area when the radius is a positive value? a. if (radius!=0) { System.out.println("The area is: " + radius * radius * Math.PI); b. if (radius>=0) { System.out.println("The area is: " + radius * radius * Math.PI); c. if (radius>0) { System.out.println("The area is: " + radius * radius * Math.PI); d. if (radius==0) { System.out.println("The area is: " + radius * radius * Math.PI); 58. Which will be displayed when the code segment below is run? double grosspay = 4250.50; if (grosspay > 3000) { System.out.println("Your tax rate is 33%"); else if (grosspay > 4000) { System.out.println("Your tax rate is 35%"); a. Your tax rate is 33% b. Your tax rate is 35% c. Your tax rate is 33% Your tax rate is 35% d. A run-time error will be generated. 59. Given the following code segment: int x = 0; for (int i = 0; i < 8; i++) { x += i; System.out.println(x); Which will be displayed when the code segment is run? a. 7 c. 9 b. 8 d. 28 60. Given the following code segment: String lastname = "Watson"; int namelength; namelength = lastname.length(); What is the value of namelength after the statements execute? a. 5 c. 8 b. 6 d. Watson 4
Name: 61. A problem-solving approach that breaks tasks into smaller subtasks is called a. bottom-up development. c. top-down development. b. task division development. d. procedural development. 62. A method is executed when it is a. typed. c. declared. b. called. d. named. 63. Which keyword is an access modifier? a. static c. public b. void d. call 64. Which statement calls the method inchestocentimeters()? a. call inchestocentimeters; b. inchestocentimeters(call); c. inchestocentimeters(); d. execute inchestocentimeters(); 65. How many arguments are passed in the statement checkguess(i, valitem)? a. 1 c. 3 b. 2 d. 4 66. How many parameters are declared in the statement public static void checkguess(int length, int width)? a. 1 c. 3 b. 2 d. 4 67. (Application) Given the following code segment: public static void prob(int x, int y) { System.out.print(x + " "); if (x <= y) { System.out.println(x + y); Which will be displayed when prob(6, 7) is called? a. 6 7 c. x + 7 b. x + 6 d. 6 13 68. The arguments in a method call must a. correspond in order to the parameters in the method being called. b. have the same names as the corresponding parameters in the method being called. c. be variables. d. be integers. 69. When more than one method of the same name is included in a class, it is referred to as method a. passing. c. overloading. b. duplicating. d. voiding. 5
Name: 70. (Application) Given the following application: public class Calculation { public static int linelength(int x, int y) { int length; length = x * y; return length; public static int linelength(int x) { int length; length = x * x; return length; public static void main(string[] args) { System.out.println(lineLength(5)); Which will be displayed when the application is run? a. 5 c. 25 b. 10 d. A syntax error will be generated. 71. (Application) Given the following application: public class Comparison { public static double maxnum(int num1, int num2) { if (num1 > num2) { return num1; else { return (num2); public static double maxnum(int value1, int value2) { if (value1 > value2) { return value1; else { return (value2); public static void main(string[] args) { System.out.println(maxNum(1, 2)); Which will be displayed when the application is run? a. 1 c. 2.0 b. 2 d. A syntax error will be generated. 6
Name: 72. (Application) Given the following code segment: public static int prob2(int x, int y) { y += x * 2; return(y); public static void main(string[] args) { int j = 6, k = 4; j = prob2(j, k); System.out.println(j); Which will be displayed after the code executes? a. 4 6 c. 16 b. 12 d. 20 73. How many values can a return statement return? a. 0 c. 3 b. 1 d. An unlimited number. 74. A statement of what must be true at the end of the execution of a procedure is called a(n) a. precondition. c. ending comment. b. postcondition. d. procedure condition. 75. Which statement is required to access the File class? a. import java.io.* c. import java.awt.* b. import java.util.* d. import java.lang.* 76. Which is the error in the statement, File textfile = new File("c:\MyDocuments\data.txt");? a. The file path does not have to be in quotes ("). b. The words new File are not necessary. c. Escape sequences need to separate the drive, folder, and file names (\\). d. There is no error in the statement. 77. Which is a block of code that performs an action when an exception occurs? a. throw stream c. exception handler b. err stream d. action handler 7
Name: 78. Given the following code segment: File textfile = new File("c:\\inventory.txt"); if (textfile.exists()) { System.out.println("The file already exists."); else { try { textfile.createnewfile(); System.out.println("The file was created."); catch (IOException e) { System.out.println("The file could not be created."); System.err.println("IOException: " + e.getmessage()); Which is the statement that could possibly generate an exception in the try-catch-finally statement? a. textfile.exists() b. System.err.println("IOException: " + e.getmessage()); c. IOException d. textfile.createnewfile(); 79. Which class is used to create an input file stream? a. BufferedReader c. FileWriter b. FileReader d. BufferedWriter 80. Which class is used to create an output file stream? a. BufferedReader c. FileWriter b. FileReader d. BufferedWriter 81. Given the following statement: File datafile = new File("inventory.dat"); Which will occur if there is an existing inventory.dat file? a. An IOException will be thrown. b. An inventory1.dat file will be created. c. The existing file will automatically be overwritten. d. A prompt will appear asking if the file should be overwritten. 82. Given the following statement: File datafile = new File("inventory.dat"); Which will occur if inventory.data does not exist? a. An IOException will be thrown. b. A new inventory.dat file will be created. c. The existing file will automatically be overwritten. d. A prompt will appear asking if the file should be overwritten. Completion Complete each sentence or statement. 83. Errors that violate the rules of Java are called errors. 8
Name: 84. A is a collection of related data stored on a persistent medium. 85. File streams are used to perform file access, with all the reading and writing performed one character after another or one line after another. Short Answer 86. (1 mark) What does HTML stand for? 87. (1 mark) What does CSS stand for? 88. (4 marks) List some rules typically found on an Acceptable Use Policy. 89. (5 marks Application) Sketch a flowchart for the following program description: The Information application displays your name on a separate line, your school on a separate line, and your current school classes on the same line, separated by a tab. 90. (5 marks Application) Identify five errors in the following application: /* * InternetRules.java /* package studentrules /** * Displays student rules for accessing the Internet. */ public class InternetRules public static void main(string[] args) { System.out.println("Internet Rules\n"); System.out.println("1. Use school issued login and password."); System.out.println("2. Do not download any files.") system.out.println("3. Do not reveal personal information."); 91. (2 Marks - Communication) Write an appropriate decision statement to display You move to the next level. when the value of points is 150 or higher. 92. (8 marks - communication) Complete the following: a) Write an algorithm for obtaining a gross pay amount from the user and then determining an appropriate tax bracket amount based on the gross pay entered. If the gross pay is less than $700, the tax rate is 26%, if the gross pay is between $700 and $1,200 inclusive, the tax rate is 33%, and if the gross pay is greater than $1,200, the tax rate is 36%. b) Write the pseudocode for the algorithm developed in part (a). 93. (Communication 4 marks)list two naming conventions for method names. 9
Name: 94. (Application) (2 marks)write a statement to call a method named checkvalue() that has two int parameters named firstnum and secondnum. 95. (Communication 6 marks) Write the method declaration for a public class method named calculateaverage() that has double parameters firstnum, secondnum, thirdnum and returns a double value. 96. (Application) (4 marks) Write a productinventory() method that calculates the total number of products available in four store locations and returns the total. The productinventory() method should contain int store1, store2, store3, and store4 parameters and return an int value. 97. (2 marks Application) List two examples of a persistent medium. 98. (2 marks Communication & Application) Explain why should an exception handler should be used in an application? 99. (2 marks Communication & Application) Explain how the FileReader and BufferedReader classes work together to read the contents of an existing file? Essay 100. (4 MARKS) Describe the ethical and system reliability responsibilities associated with being an IT professional. 10