Practice Exam 1 solution

Practice Exam 1 solution -...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 Multiple-choice Answers 1. A 2. C 3. E 4. A 5. C 6. E 7. B 8. E 9. A 10. D 11. D 12. D 13. B 14. E 15. D 16. B 17. A 18. B 19. A 20. B 21. B Coding Question Answers Question 1 part (a) public void printName() { System.out.println(lastName + "," + firstName.charAt(0) + ".") } part (b) public boolean comesBefore(Person other) { // first check the last name if (lastName.compareTo(other.lastName) < 0) return true if (lastName.compareTo(other.lastName) > 0) return false // if we've gotten here, that means the last names are the same // so now check the first names
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: if (firstName.compareTo(other.firstName) < 0) return true else return false } Question 2 Sheet1 Page 2 public class LaundryOrder { private String customer private int numItems private boolean ready public LaundryOrder(String name, int items) { customer = name numItems = items ready = false } public String getCustomerName() { return customer } public int getNumItems() { return numItems } public boolean isReady() { return ready } public void changeToReady() { ready = true } }...
View Full Document

{[ snackBarMessage ]}

Page1 / 2

Practice Exam 1 solution -...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online