Download Exposure Java Exercises

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
APCS Exposure Java
Name: KEY
Exercises 3.5-14 Date:
Period:
1.
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
2.
How is it possible for a computer to multiply 2 positive numbers, and get a negative product?
Memory flow, which alters the sign bit
3.
Explain Memory Overflow.
A condition that occurs when the mathematical value is too large to be stored in the actual
computer memory space.
Assume x is an int for the next several questions.
4.
What does x++; or ++x; mean?
In both case variable x is incremented by 1.
5.
What does x--; or –x; mean?
In both cases variable x is decremented by 1.
6.
Should Java shortcuts be combined with other Java statements?
Example: System.out.println(x++);
No, it causes confusion.
7.
What does x += 5; mean?
Increase x by 5.
8.
What does x -= 5; mean?
Decrease x by 5.
9.
What does x *= 5; mean?
Multiply x by 5.
10.
What does x /= 5; mean?
Divide x by 5.
11.
What does x %= 5; mean?
x will become the remainder or dividing x by 5.
12.
What kind of quotes are used with characters?
Single Quotes
13.
What kind of quotes are used with strings?
Double Quotes
Exposure Java 2011, APCS Edition
Exercises 3.5-14
Page 1
08-07-11
14.
Besides the quotes, 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.
15.
In program Java0312.java, what is accomplished by the statement: c1 = c2 = c3 = 'Q'; ?
Every variable is assigned the value of Q.
16.
What is the fancy name for using the plus ( + ) sign to join strings together?
Concatenation
17.
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
18.
What is “2” + “3” ?
23
19.
Who invented a form of Algebra based on logical statements that are either true or false?
George Boole
20.
Today, in computer science, a data type that has only two values of true and false is a called a _______
data type.
boolean
21.
What is Java’s formal language for the term simple data types.
primitive
22.
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;
23.
What happens when you attempt to alter the value of a final variable?
It causes a compile error.
24.
What is a self documenting identifier?
An identifier, such as grossPay, that explains the purpose of the variable.
25.
What is the difference between double-slash ( // ) comments and slash-star star-slash comments (/* */) ?
// is a single line comment
/* */ is a multiple line comment
26.
Does Java follow the same Order of Operations that you learned in your Math class?
Yes
27.
Translate 7abc into Java source code.
7*a*b*c
Exposure Java 2011, APCS Edition
Exercises 3.5-14
Page 2
08-07-11
28.
x+3
Translate ————— into Java source code.
2x - 7
(x + 3) / (2 * x - 7)
29.
Translate “one half” into Java source code.
1.0 / 2.0 or 0.5
30.
What is the output of: System.out.println( 10 / 3 ); ?
3
31.
What is the output of: System.out.println( (double) 10 / 3 ); ?
3.333333
32.
What is an escape sequence?
A special set of characters, starting with /, that means something to print, like \n
33.
What does the escape sequence \n do?
carriage return, line feed
34.
What escape sequence is used to generate a <tab>?
\t
35.
Why do we need escape sequences to generate backslash ( \ ) and quote ( " ) characters?
It prevents confusion to the compiler
36.
What are the 4 data types that will be tested on the AP Exam?
int, double, boolean and String
Exposure Java 2011, APCS Edition
Exercises 3.5-14
Page 3
08-07-11