Ch. 3 APCS
Terms in this set (70)
What makes Math, Science, and Computer Science possible?
A computer program is made up of words, which usually are called what?
Under what condition will the compiler create a bytecode file?
if the source code obeys all Java syntax rules
What is the first Java syntax rule?
Use only keywords known to the Java compiler
List the 3 categories of keywords.
1) Reserved words
2) Pre-defined Java identifiers
3) User-defined identifiers
List 3 examples of Java Reserved Words.
public, static, void
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?
List 2 examples of Predefined Identifiers
When you are creating User-Defined Identifiers, you must make sure your identifier is not one of what two things?
A reserved word or a predefined identifier
What are the rules for naming an identifier?
Use alpha-numeric characters and start with an alpha character.
Print the Java statement that will declare x as an integer.
Refer to the previous question. Print the statement that will assign the value of 7 to x.
x = 7;
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.
Why does program Java0302.java not compile?
There are no values assigned to the variables.
Print the Java statement that will declare x as an integer and assign the value of 7 to x in one single statement.
int x = 7;
List Java's 4 integer types.
1) byte (1 byte)
2) short (2 bytes)
3) int (4 bytes)
4) long (8 bytes)
How many bytes are used by an int?
What is the largest value of a byte?
2^(8-1)-1 = 127
Would a short be appropriate to store Zip Codes?
nope, it's too
Explain your answer to the previous question (shorts and zip codes)
A short cannot hold any number above 32,767 (2^(7) -1), Many zip codes are larger than this.
What are the 5
1) Addition (+)
2) Subtraction (-)
3) Multiplication (*)
4) Integer quotient division (/)
5) Integer remainder division (%)
What is the difference between the / and the % division operators?
/ is for integer
% is for integer
What 2 data types are used by Java for
double and float
Refer to the previous question. Which of these 2 data types is more more accurate?
What are the 4
1) addition (+)
2) subtraction (-)
3) multiplication (*)
4) real number quotient division (/)
Is real number remainder division possible in Java? If so, is it practical?
Yes it is possible
No it is not practical
In binary, what indicates if a number is positive or negative?
If the first bit is 0, the number is positive (+).
If the first bit is 1, the number is negative (-).
How is it posible for a computer to multiply 2 positive numbers, and get a negative product?
Memory flow, which alters the sign bit
Explain Memory Overflow.
A condition that occurs when the mathematical value is too large to be stored in the actual computer memory space.
What does x++; or ++x mean?
x = x+1
In both cases variable x is incremented by 1; the pre/post fix indicates what order of increment or display to do first
What does x--; or --x mean?
x = x-1
In both cases variable x is decremented by 1.
Should Java shortcuts be combined with other Java statements?
No wtf no, it causes confusion
What does x+=5; mean?
x = x+5
Increase x by 5
What does x-=5; mean?
x = x-5
Decrease x by 5
What does x*=5; mean?
x = x*5
Multiply x by 5
What does x /= 5; mean?
x = x/5
Divide x by 5
What does x %=; mean?
x = x%5
x will become the remainder of dividing x by 5
Which data type is used to process individual characters?
Which data type is used to process sets of one or more characters?
What kind of quotes are used with Strings?
double quotes ("word")
What kind of quotes are used with individual characters?
single quotes ('w')
In program Java0312.java, what is accomplished by the statement c1 = c2 = c3 = 'Q';?
Every variable is assigned the value of Q.
Refer to the previous question. What is the name for this type of shortcut (c1 = c2 = c3 = 'Q';)?
What is the fancy name for using the plus (+) sign to join Strings together?
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?
What is "2" + "3"?
Who invented a form of Algebra based on logical statements that are either true or false?
George Yuan jk George Boole
Today, in computer science, a data type that has only two values of true and false is called a _____ data type.
What is Java's formal language for the term "simple data types"?
primitive [data types]
Say you want to use the mathematical value of E (another non-repeating decimal similar to PI) in your program with value of 2.718281828. This value will never change in your program. Print the proper way to define and initialize this constant.
final double E = 2.718281828;
What are the 4 data types that will be tested on the AP Exam?
int, double, boolean, String
What happens when you attempt to alter the value of a constant?
It causes a compile error.
What does Java call constants?
What is the first form of program documentation?
to use comments
Why were computer programs in the 1960s and the 1970s often written with single-letter variables?
Computer memory was scarce and very expensive.
Programmers had to do anything they could to save every byte possible.
What is a self-commenting variable?
a variable whose name describes what the variable is used for
Look at programs Java0317.java and Java0318.java. Both programs do the exact same thing. Why is the second program so much easier to understand?
The second program uses
While, the first program uses
The age of single-letter variables is gone. Variables should now be ____ or ____.
words or compound words
Suppose you are writing a program to compute the average of a list of numbers. What name should you give the variable that stores the average?
In a well-documented program, are single-line comments or multi-line comments necessary in a program that already uses good self-commenting variables?
Does Java follow the same Order of Operations that you learned in your Math class?
Yes PEMDAS ayyyyy
Translate 7abc into Java source code.
7 (asterisk) a (asterisk) b (asterisk) c
Translate (x+3)/(2x-7) into Java source code.
(x+3)/(2*x - 7)
Translate "one-half" into Java source code.
1.0/2.0 or 0.5
What is the output of: System.out.println(10/3);?
What is the output of: System.out.println((double) 10/3);
[fifteen 3s after decimal followed by 5]
What is an escape sequence?
A special set of characters, starting with \, that means something to print, like \n
What does the escape sequence \n do?
carriage return, line feed (CRLF)
What escape sequence is used to generate a <tab>?
Why do we need escape sequences to generate backslash(\) and quote (") characters?
It prevents confusion to the compiler.
(needs some way of telling Java what is literal versus what characters need to be displayed)
YOU MIGHT ALSO LIKE...
APCS Chapter 3 Test (excercises)
Computer Science Review Chapter 3
OTHER SETS BY THIS CREATOR
AAS 206 Final
Midterm 1 - AAS 206
INDE 250 Midterm 1
AMATH 301 FINAL
THIS SET IS OFTEN IN FOLDERS WITH...
APCS Ch. 2
APCS CH 1
APCS Ch. 4
APCS Ch 5