Upload
marlon
View
55
Download
0
Embed Size (px)
DESCRIPTION
Objective Type Quiz 1. 4.10 – 4.10.5. 1-4. What are four types of operators used in Java?. 5. What is the output of the following codes:. int num = 56 % 9; System.out.print(num);. a. 2 b. 4 c. 6 d. 6.22. 6. Fill in the blanks. int buda = 4; int pest = 15; Int budapest = pest___buda; - PowerPoint PPT Presentation
Citation preview
Objective Type Quiz 1
4.10 – 4.10.5
1-4. What are four types of operators used in Java?
5. What is the output of the following codes:
int num = 56 % 9;System.out.print(num);
a. 2b. 4c. 6d. 6.22
6. Fill in the blanks
int buda = 4;int pest = 15;Int budapest = pest___buda;System.out.println(budapest);//The output must be 3.
7-8. What is the output of the following codes:
int val = 3;int you = val;val = 4;int tube = ++val;val = you + tube;System.out.print(val);
9. What is the output of the following codes:
int ice = 11;int buko = 15;int refreshment = ice / buko;System.out.println(refreshment);
10. When an integer and a float are used as operands to a single
arithmetic operation, the result is a _______.
a. Integerb. Floatc. Doubled. Char
11. True or False. The increment and decrement operators can only be
placed after an operand.
12-13. Write the prefix form and the postfix form of writing the decrement
of an operand called “num”.
14-16. What is the output of the following code:
int a = 1;int b = 1;int c;c= ++b;a++;System.out.println(“a = “+a); // #14System.out.println(“b = “+b); // #15 System.out.println(“c = “+c); // #16
17. _____ operators compare two values and determine the relationship
beween those values.
18. What is the output of the following codes.
public class Relations{
public static void main(String[] args) {
double val1 = 2.601;double val2 = 2.60;
Boolean test = false;test = (val1 <= val2);
System.out.print(test);
}}
19. Yes or No.
Is (val1 > = val2) an error?i.e. there is a space between > and =
20. Fill in the blanks
float horse = 2.0f;float chicken = 2.00f;Boolean compare = ________;//chicken is equal to horse.
21. Logical operators have one or two _______ operands that yield a
_______ result.
22. What is this symbol: &&?
a. Boolean logical andb. Logical andc. Logical ord. Boolean logical exclusive and
23. What is this symbol: ^?
a. Logical orb. Boolean logical exclusive orc. Boolean logical inclusive ord. Logical not
24. The basic difference between && and & operators is that && supports
___________ evaluations.
25. What is the output of the following codes:
int cost = 23;int price = 13;boolean econ = false;
econ = (cost < 20) || (price > 10);System.out.print(econ);
26. What is the output of the following codes:
int nature = 10;int spring = 11;boolean water = false;
water = (nature > 20%7) || (spring > nature);System.out.print(water);
27. ____ operator is an operator that takes in three arguments to form a
conditional expression.
28. Which of the following is the structure of an expression using a
conditional operator?a. exp1:exp2:exp3b. exp1:exp2?exp3c. exp1?exp2;exp3d. exp1?exp2:exp3e. exp1;exp2?exp3
29. Fill in the blanksint driverSpeed = 80;String violation = “”;//If speed is greater than 80, driver gets ticket.violation = (________)?”You don’t get ticket”:”You get ticket”;
System.out.println(violation)
//OUTPUT: You get ticket
30-32. Was the test too hard? Here’s a three point bonus:
EradngElvteaeGltesurgLecndasEdteiavRapyhetRanietreughn