objective type quiz 1

24
Objective Type Quiz 1 4.10 – 4.10.5

Upload: marlon

Post on 22-Jan-2016

55 views

Category:

Documents


0 download

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

TRANSCRIPT

Page 1: Objective Type Quiz 1

Objective Type Quiz 1

4.10 – 4.10.5

Page 2: Objective Type Quiz 1

1-4. What are four types of operators used in Java?

Page 3: Objective Type Quiz 1

5. What is the output of the following codes:

int num = 56 % 9;System.out.print(num);

a. 2b. 4c. 6d. 6.22

Page 4: Objective Type Quiz 1

6. Fill in the blanks

int buda = 4;int pest = 15;Int budapest = pest___buda;System.out.println(budapest);//The output must be 3.

Page 5: Objective Type Quiz 1

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);

Page 6: Objective Type Quiz 1

9. What is the output of the following codes:

int ice = 11;int buko = 15;int refreshment = ice / buko;System.out.println(refreshment);

Page 7: Objective Type Quiz 1

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

Page 8: Objective Type Quiz 1

11. True or False. The increment and decrement operators can only be

placed after an operand.

Page 9: Objective Type Quiz 1

12-13. Write the prefix form and the postfix form of writing the decrement

of an operand called “num”.

Page 10: Objective Type Quiz 1

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

Page 11: Objective Type Quiz 1

17. _____ operators compare two values and determine the relationship

beween those values.

Page 12: Objective Type Quiz 1

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);

}}

Page 13: Objective Type Quiz 1

19. Yes or No.

Is (val1 > = val2) an error?i.e. there is a space between > and =

Page 14: Objective Type Quiz 1

20. Fill in the blanks

float horse = 2.0f;float chicken = 2.00f;Boolean compare = ________;//chicken is equal to horse.

Page 15: Objective Type Quiz 1

21. Logical operators have one or two _______ operands that yield a

_______ result.

Page 16: Objective Type Quiz 1

22. What is this symbol: &&?

a. Boolean logical andb. Logical andc. Logical ord. Boolean logical exclusive and

Page 17: Objective Type Quiz 1

23. What is this symbol: ^?

a. Logical orb. Boolean logical exclusive orc. Boolean logical inclusive ord. Logical not

Page 18: Objective Type Quiz 1

24. The basic difference between && and & operators is that && supports

___________ evaluations.

Page 19: Objective Type Quiz 1

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);

Page 20: Objective Type Quiz 1

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);

Page 21: Objective Type Quiz 1

27. ____ operator is an operator that takes in three arguments to form a

conditional expression.

Page 22: Objective Type Quiz 1

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

Page 23: Objective Type Quiz 1

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

Page 24: Objective Type Quiz 1

30-32. Was the test too hard? Here’s a three point bonus:

EradngElvteaeGltesurgLecndasEdteiavRapyhetRanietreughn