Thursday, January 29, 2015

Head First Java: Chapter 3

Chapter 3

The Heap Quiz Assignment was to match each reference variable with matching object(s). Which taught me how to identify which object belong to with reference variable using the Heap analogy.

In this particular assignment i had to find the mistake in each of the following pieces of code and explain why they were wrong and what could be done to fix it. This worksheet helps with debugging skills and abilities. 
This program was a fill-in-the-blank to help the reader recognize what the program is doing and how it can be completed.
 Main Points


  • ·         Variables come in two flavors: primitive and reference.
  • ·         Variables must always be declared with a name and a type.
  • ·         A primitive variable value is the bits representing the value (5, ‘a’, true, 3.1416, etc.).
  • ·         A reference variable value is the bits representing a way to get to an object on the heap.
  • ·         A reference variable is like a remote control.
  • ·         Using the dot operator (.) on a reference variable is like pressing a button on the remote control to access a method or instance variable.
  • ·         A reference variable has a value of Null when it is not referencing any object.
  • ·         An array is always an object, even if the array is declared to hold primitives. There is no such thing as a primitive array, only an array that holds primitives.

One thing I thought was interesting and helpful was the use of arrays. An array is an object that hold primitives. This allows making object much easier and faster by assigning reference variable for the objects.


Code program for random student chooser

No comments:

Post a Comment