SJSU/Udacity CS046

Lesson 2 - Objects

  1. Introduction
  2. Introducing Ellora
  3. Why OOP is Important
  4. Objects
  5. Objects Demo
  6. Quiz: Mariner 4
  7. Classes
  8. Quiz: Match the Methods
  9. Drawing Pictures
  10. Quiz: What Does This Method Do?
  11. Variables
  12. Variable Names
  13. Quiz: An Exercise on Variable Names
  14. Variable Types
  15. Quiz: Variable Types
  16. Initial Values
  17. Quiz: Initial Values
  18. Comments
  19. Quiz: How Many Days
  20. Quiz: Adding Comments
  21. Quiz: Variable Declarations: The Fine Print
  22. Variable Values Can Change
  23. Public Interfaces
  24. Public Interfaces 2
  25. Arguments and Return Values
  26. Quiz: Arguments and Return Values Exercise
  27. Method Declarations
  28. Quiz: Method Description
  29. Quiz: More Method Descriptions
  30. Constructing Objects
  31. Making Rectangles
  32. Quiz: Constructing Rectangles
  33. String Methods
  34. Quiz: The replace Method
  35. Quiz: The trim Method
  36. Quiz: toUpperCase and toLowerCase
  37. Accessors and Mutators
  38. Quiz: Accessor or Mutator?
  39. Quiz: Accessor or Mutator? 2
  40. Quiz: Pitfall
  41. Shared Objects
  42. Quiz: Copying Rectangles
  43. Quiz: Copying Strings
  44. Quiz: Copying Numbers
  45. Implementing a Test Program
  46. Quiz: Test Program
  47. Why It's Important to Test Your Code
  48. More About Graphics
  49. Quiz: Draw a Crate
  50. Quiz: Write Top Secret
  51. Quiz: Intro to Color
  52. Colors
  53. Matching Color
  54. An Interesting Project Ellora Worked On
  55. Ellora's Advice to You
  56. Conclusion

Quiz: Pitfall

Run this code in the BlueJ code pad:

Rectangle box = new Rectangle(5, 10, 60, 90);
Rectangle box2 = box;
box.translate(100,100);
What is the value of box.getX()? 105 The translate method shifts the rectangle by 100 pixels to the right, so now x is 5 + 100 = 105.
What is the value of box2.getX()? 105 Why did box2 change? See Cay's next video for an explanation!

Problem on this page?

Your name:

Your email address:

Problem description:

To protect against spam robots, please answer this simple math problem:
× =