Copyright

Java Programming Problems Chapter Exam

Exam Instructions:

Choose your answers to the questions and click 'Next' to see the next set of questions. You can skip questions if you would like and come back to them later with the yellow "Go To First Skipped Question" button. When you have completed the practice exam, a green submit button will appear. Click it to see your results. Good luck!

Page 1

Question 1 1. Examine the following code. What could we add to ensure only integers were entered?

Question 2 2. This code will not compile, Java displays an error. What is missing?

Question 3 3. You are developing a program to accept user input. Users will enter population counts of bacteria and add them together (numbers in the billions). Which data type would be best for the user to convert their input to?

Question 4 4. Based on the variables below, which is the correct way to square 19?

Question 5 5. Examine the following code. What is missing?

Page 2

Question 6 6. The following code will not compile. What needs to be added or removed so it will compile successfully?

Question 7 7. What will be the value of the variable result after the following code processes?

Question 8 8. After the following code is processed, what is the value of the variable result?

Question 9 9. If we try to multiply the following numbers, the value will exceed the limits of the int data type. What could you do to correct the problem?

Question 10 10. What is missing from the following Java code?

Page 3

Question 11 11. Based on the Java code below, what is true about the variable r?

Question 12 12. In the Java code below, what is the data type of the variable max?

Question 13 13. What is missing from the following Java code?

Question 14 14. In the following Java code, what is the variable counter?

Question 15 15. Examine the following Java code. Based on the values of the integers, what will the compareTo() method return?

Page 4

Question 16 16. Which of the following is the Java symbol for division operation?

Question 17 17. The result of the division operation is the _____ value that when multiplied by the second operand will result in a value less than or equal to the first operand.

Question 18 18. What is the value stored as the result for the following statement, 'double result = 11 / 5;'?

Question 19 19. Consider the following variables. You would like to add some or all of them as part of your program. What is an option to reduce potential errors for this operation?

Question 20 20. When combining arithmetic operations, what should you do to ensure the numbers are correct?

Page 5

Question 21 21. Based on the following variables, what option will result in a value of 158?

Question 22 22. Given the following code, what statement will result in a value of 462?

Question 23 23. The following code is displaying an error. What can be done to fix the problem?

Question 24 24. Which Java class provides a subtract() method for subtracting bigger numbers or numbers with multiple digits after a decimal point?

Question 25 25. Which of the following correctly checks to make sure the matrices can be multiplied?

Page 6

Question 26 26. After completing the matrix multiplication, the resulting matrix will have the same number of _____ as the first matrix, and the same number of _____ as the second matrix.

Question 27 27. Examine the following code. What is it missing?

Question 28 28. Why would we need to use the Integer wrapper class?

Question 29 29. Which of the following is a reason for using Integer instead of int?

Question 30 30. Integer is the _____ and int is a _____ in Java.

Java Programming Problems Chapter Exam Instructions

Choose your answers to the questions and click 'Next' to see the next set of questions. You can skip questions if you would like and come back to them later with the yellow "Go To First Skipped Question" button. When you have completed the practice exam, a green submit button will appear. Click it to see your results. Good luck!

Information Systems: Help and Review  /  Business Courses
Support