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

Monday, January 19, 2015

Head First into Java: Chapter 2


Chapter 2

  • When creating a class think about the objects, what the object knows and what the object does.
  • Things an object knows are called instance variables 
  • Things an object can do are called method
  • classes are not objects they are used to construct them
  • The dot operator gives you access to an object's state and behavior (instance variable and method)
  •  Java code is defined in a class 
  • A Java program is objects talking to other objects
  • A class is like a blueprint 

 In this activity I created my first object. I used two classes, one for the type of objec i wanted to use and another to test my new class. I learned the tester class is where you put the main method, and in that in that in the main() method you create and access objects.One class is real and the other is a tester.



Tuesday, January 13, 2015

Head First into Java: Chapter 1

In Beer Song Activity, we had to code "99 bottles of beer" song using if/else statement, variables and while loops. However when completing this task a problem presented itself; when there was one bottle left it would say "1 bottles of beer on the wall" and this is not proper grammar. Therefore, I created an if/else statement that tells the program if there is one bottle left then switch "bottles" to "bottle".


In this chapter I've learned many thing such as
  • Variables are declared with a name and a type 
  • white blank spaces don't matter
  • Classes and method are defined within curly braces
  • Functions such as String and System.out.print have to be captitalized
  • ln after System.out.print makes the result in a diffrent sentence 
In the phrase o matic activity uses list to create phrases. Instead I created a phrase that chooses what color shirt to where randomly. This activity has taught me to use the Math.random  function with the int function to make the value and interger.

Friday, December 12, 2014

Activity 1.3.7



 

Conclusion
1.      Sometimes code using an iterative loop can be written without a loop, simply repeating the iterated code over and over as separate lines in the program. Explain the disadvantages of developing a program this way.
 It is very inefficient and tedious.
2.      Name a large collection across which you might iterate.
 The hardware store would iterate list for what they have in stock. 
3.      What is the relationship between iteration and the analysis of a large set of data?
 Iteration changes information about each item in data and data analysis only reads their statistics.