Survey
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
Exposure Java Chapter 3 Review Name: REVIEW KEY 01. Date: Period: What is the first Java syntax rule? Use only keywords known by the Java compiler. 02. List 3 examples of Java Reserved Words. public, static, void 03. Java has a large number of libraries that enhance the basic Java language. These libraries contain special program modules that perform a variety of tasks to simplify the life of a programmer. What are these modules called? methods 04. Write the Java statement that will declare x as an integer. int x; 05. Refer to the previous question. Print the statement that will assign the value of 7 to x. x = 7; 06. In program Java0301.java, why does the statement: System.out.println(a); display the value of 10 and not a? The letter is not between double quotes consequently it is the contents of the memory location called a.. 07. Why does program Java0302.java not compile? There are no values assigned to the variables. 08. Print the Java statement that will declare x as an integer and assigns the value of 7 to x in one single statement. int x = 7; 09. List Java’s 4 integer types. byte, short, int and long 10. How many bytes are used by an int? What is the largest value of a byte? 4 11. 127 Would a short be appropriate to store Zip Codes? No, you would get Error – possible loss of precision 12. What are the 5 integer operations? Addition, subtraction, multiplication, integer division and remainder division 13. What is the difference between the / and the % division operators? / is integer division and % is remainder division Exposure Java, 2006 Exercises0302 10-08-06 14. What does x += 5; mean? Increase x by 5 15. What does x -= 5; mean? Decrease x by 5 16. What does x *= 5; mean? Multiply x by 5 17. What does x /= 5; mean? Divide x by 5 18. What does x %= 5; mean? Compute the remainder or dividing x by 5 19. In binary, what indicates if a number is positive or negative? If the first bit is 0, the number is positive and if the first bit is 1, the number is negative 20. How is it possible for a computer to multiply 2 positive numbers, and get a negative product? Memory flow, which alters the sign bit 21. Explain Memory Overflow. A condition that occurs when the mathematical value is too large to be stored in the actual computer memory space. 22. The Real Number data type that we will use is called double. Why is a double called a double? It has double the bytes of a float Which is more precise? A double, or a float? Double Assume x is an int for the next several questions. 23. What does x++; or ++x; mean? In both case variable x is incremented by 1. 24. What does x--; or –x; mean? In both cases variable x is decremented by 1. 25. Should Java shortcuts be combined with other Java statements? Example: System.out.println(x++); No, it causes confusion 26. What is the difference between the char and String data types? The char type store one character and the String data type store one or more characters. 27. In program Java0312.java, what is accomplished by the statement: c1 = c2 = c3 = 'Q'; ? Every variable is assigned the value of Q. 28. What is the fancy name for using the plus ( + ) sign to join strings together? Concatenation Exposure Java, 2006 Exercises0302 10-08-06 29. The plus ( + ) sign can be used to add integers and real numbers. It can also be used to join strings. What is it called when one operator can perform different functions. Overloading 30. What is “2” + “3” ? 23 31. Who invented a form of Algebra based on logical statements that are either true or false? George Boole 32. Today, in computer science, a data type that has only two values of true and false is a called a _______ data type. boolean 33. Say you want to use PI in your program with value of 3.14159. This value will never change in your program. Print the proper way to define and initialize this constant. final double PI = 3.14159; 34. What happens when you attempt to alter the value of a final variable? It causes a compile error. 35. What is the difference between double-slash ( // ) comments and slash-star star-slash comments (/* */) ? // is a single line comment /* */ is a multiple line comment 36. Does Java follow the same Order of Operations that you learned in your Math Yes 37. Translate 7abc into Java source code. 7*a*b*c 38. x+7 Translate ————— into Java source code. 2x - 3 (x + 7) / (2 * x - 3) 39. Translate “one half” into Java source code. 1.0 / 2 40. What is the output of: System.out.println( 10 / 3 ); ? 3 41. What is the output of: System.out.println( (double) 10 / 3 ); ? 3.333333 Exposure Java, 2006 Exercises0302 10-08-06 42. What is an escape sequence? A special set of characters, starting with /, that means something to print, like \n 43. What does the escape sequence \n do? carriage return, line feed 44. What escape sequence is used to generate a <tab>? \t 45. Why do we need escape sequences to generate backslash ( \ ) and quote ( " ) characters? It prevents confusion to the compiler 46. What are the 4 data types that will be tested on the AP Exam? int, double, boolean and String Exposure Java, 2006 Exercises0302 10-08-06