1 / 24

Objective Type Quiz 1

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;

marlon
Download Presentation

Objective Type Quiz 1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Objective Type Quiz 1 4.10 – 4.10.5

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

  3. 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

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

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

  6. 9. What is the output of the following codes: int ice = 11; int buko = 15; int refreshment = ice / buko; System.out.println(refreshment);

  7. 10. When an integer and a float are used as operands to a single arithmetic operation, the result is a _______. • Integer • Float • Double • Char

  8. 11. True or False. The increment and decrement operators can only be placed after an operand.

  9. 12-13. Write the prefix form and the postfix form of writing the decrement of an operand called “num”.

  10. 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); // #14 System.out.println(“b = “+b); // #15 System.out.println(“c = “+c); // #16

  11. 17. _____ operators compare two values and determine the relationship beween those values.

  12. 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); } }

  13. 19. Yes or No. Is (val1 > = val2) an error? i.e. there is a space between > and =

  14. 20. Fill in the blanks float horse = 2.0f; float chicken = 2.00f; Boolean compare = ________; //chicken is equal to horse.

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

  16. 22. What is this symbol: &&? • Boolean logical and • Logical and • Logical or • Boolean logical exclusive and

  17. 23. What is this symbol: ^? • Logical or • Boolean logical exclusive or • Boolean logical inclusive or • Logical not

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

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

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

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

  22. 28. Which of the following is the structure of an expression using a conditional operator? • exp1:exp2:exp3 • exp1:exp2?exp3 • exp1?exp2;exp3 • exp1?exp2:exp3 • exp1;exp2?exp3

  23. 29. Fill in the blanks int 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

  24. 30-32. Was the test too hard? Here’s a three point bonus: Eradng Elvteae Gltesurg Lecndas Edteiav Rapyhet Raniet reughn

More Related