Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- True / False
- 1. The first generation of programming language is assembly language. F
- 2. Java is an example of a high-level language. T
- 3. Mistakes found early in the coding process are much more expensive to fix than mistakes found later in the process. F
- 4. Byte code is a program that behaves like a computer. F
- 5. An arithmetic expression consists of operands and binary operators combined as in algebra. T
- 6. Programs manipulate objects by sending them methods. F
- 7. An integer is a positive or negative whole number. T
- 8. Strings are objects, not primitive data types. T
- 9. A relational operator is used to compare data items. T
- 10. Most, but not all, information in a computer is represented in binary form. F
- Fill In The Blank
- 1. OOP stands for object-oriented programming.
- 2. The software responsible for translating a program in a high-level language to machine code is called a compiler.
- 3. JVM stands for Java Virtual Machine.
- 4. When an object receives a message, the object responds by running a block of code called a method.
- 5. Numbers with a fractional part are called floating point numbers.
- 6. When evaluating an expression, Java performs operations of higher precedence first unless overridden by parenthesis.
- 7. Use the concatenation operator to create a new string out of existing strings.
- 8. The while statements implements a conditional.
- 9. An off by one error occurs when a loop goes around one too many or one too few times.
- 10. An infinite loop error occurs when a loop never stops.
- Written Questions
- 1. What is the purpose of a variable in a program?
- Variables allow for a value to change within a program.
- 2. What are the three types of programming errors? Give a brief example of each.
- The three types of programming errors are compilation errors, run time errors, and logic errors. An example of a compilation error is a misspelled word. A run time error could occur when an equation gives an imaginary number. A logic error would be if the program was supposed to prompt the user for two things and it only prompted for one.
- 3. Describe the differences between the data types double and int.
- A double holds decimals, an int holds whole numbers.
- 4. Assume that the variables x and y contain the values 8 and 4, respectively. What are the values of the expressions listed below?
- A. x * y * 2
- 16
- B. (x+ y ) / 3
- 4
- C. x-y *3
- -4
- D. x + y * 1.5
- 14
- 5. Write a valid java statement that adds 5 to the value of variable x if the value of variable y is greater than 10
- if (y > 10) {
- x = x + 5;
- }
- 6. A program has the following loop heading: while ( 3 < x < 10 ). Is the heading syntactically correct? If incorrect, explain why.
- It is incorrect, there should be a comma, so it is while (3 < x , x < 10 ) {...
- 7. Write a loop that outputs the first 10 positive powers of 2
- while (x < 2^10) {
- int x;
- x = 2;
- x = x *2;
- System.out.println (x);
- }
Advertisement
Add Comment
Please, Sign In to add comment