IT 105 Review Notes

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Part 1

1. A data type which declares a variable with the value either true or false.
a. char b. String c. expression d. boolean
1. An equality testing operator.
a. == b. = c.! = d. comparison operator
2. It is the counterpart of a multi-way if statement’s else clause in a switch statement.
a. break b. continue c. default d. switch
3. It immediately ends the switch statement.
a. break b. continue c. default d. switch
4. A type of selection statement that only executes if and only if the condition is true, and there is no
alternative action.
a. one-way if b. two-way if c. multi-way if d. nested-if
5. A type of selection statement which decides the execution path based on whether the condition is
true or false.
a. one-way if b. two-way if c. multi-way if d. nested-if
6. An if statement which is inside another if statement.
a. one-way if b. two-way if c. multi-way if d. nested-if
7. It is used to tell a program to execute statements repeatedly.
a. switch b. if-else c. loops d. selection
8. It is a function that is used to obtain a random value.
a. random.Math() b. Math.random() c. random.Function() d. Math.randomNum()
9. It is a storage that is used to represent values that may be changed in the program.
a. JOptionPane b. Scanner c. variable d. expression
10. To read a double value using a Scanner, you invoke:
a. nextDouble() b. nextInt() c. nextLine() d. next()
11. To read a String using a Scanner, you invoke:
a. nextDouble() b. nextInt() c. nextLine() d. nextString()
12. An operation that converts a value of one data type with bigger range into a value of another data
type with smaller range.
a. Casting b. Parsing c. Explicit d. Implicit
13. If x is 10 and y is 2, what is the value of x if this expression x*=y is executed?
a. 12 b. 10 c. 20 d. none is correct
14. If x is 10 and y is 2, what is the value of x if this expression x/=y is executed?
a. 5 b.10 c. 8 d. none is correct
15. If x is 9 and y is 4, what is the value of x if this expression x%=y is executed?
a.2.1 b. 2 c. 1 d. none is correct
16. If x is 100_000_000, what is the value of x if this expression x++ is executed?
a. 200_000_000 b. 200_100_00 c. 100_000_100 d. 100_000_001
17. A type of loop that executes a repeatedly while the condition is true
a. for loop b. while loop c. do-while loop d. none is correct
18. What is the correct import statement to import a JOptionPane?
a. import javax.swing.JOptionPane; b. import java.util.JOptionPane;
19. What is the correct import statement to import a Scanner?
a. import java.util.Scanner; b. import javax.swing.Scanner;
20. What is the correct definition of a Scanner variable?
a. Scanner input = new Scanner (System.out); b. Scanner entry = new Scanner (System.in);
1. Write a line of code that returns a random integer between 0 and 9.
2. Write a while loop that will implement the following and will ultimately print “Sum is 45.”:

3. Write a multi-way if-else that tests if the guess of the user is either equal to the number, or too high
or too low.
4. Write the appropriate if statement based on the following flowchart.

5. Finish the following program by writing a while loop to execute this output:

6. What will be displayed if year entered is 2008?


Part 3
A String type variable can store a true or false value. ___________
1. The relational operators (<, <=, ==, !=, >, >=) yield a Boolean value. ____________
2. Loop statements are used for programming with alternative courses of actions. ___________
3. There is only 1 type of selection statements. ___________
4. The various if statements all make control decisions based on a Boolean expression. _________
5. The Boolean operators &&, ||, !, and ^ operate with Boolean values and variables. __________
6. When evaluating p1 && p2, Java first evaluates p1 and then evaluates p2 if p1 is true; if p1 is false it
does not evaluate p2. ________
7. When evaluating p1 || p2, Java first evaluates p1 and then evaluates p2 if p1 is false; if p1 is true, it does
not evaluate p2.
8. The switch statement makes control decisions based on a switch expression of type char, byte, short,
int, or String. ________
9. The keyword break is optional in a switch statement. ___________
10. The part of the loop that contains the statements to be repeated is called the loop body. __________
11. A one-time execution of a loop body is referred to as an iteration of the loop. _____________
12. An infinite loop is a loop statement that executes non-stop. ________
13. The while loop checks the loop-continuation-condition first. If the condition is true, the loop body is
executed; if it is false, the loop terminates. _________
14. Identifiers are names for naming elements such as variables, constants, methods, classes, packages in
a program. ________
15. An identifier must start with a letter. _________
16. Variables are used to store data in a program. _________
17. In Java, the equal sign (=) is used as the assignment operator. __________
18. Integer arithmetic (/) yields an integer result. _________
19. The increment operator (++) increment a variable by 1. __________
20. Casting a variable of a type with a small range to a variable of a type with a larger range is known as
widening a type. _________
21. Casting a variable of a type with a large range to a variable of a type with a smaller range is known as
narrowing a type. _________
22. Widening a type can be performed automatically without explicit casting. Narrowing a type must be
performed explicitly through casting. ___________
23. The parseInt method in the Integer class is used to parse a numeric string into an int value._________
24. The program can decide which statements to execute based on a condition. ______________

You might also like