Friday, September 20, 2013

Building a Simple Java Program Part 5: Overview of Definitions

Why am I pausing a moment and doing an overview?  This is where we will add some vocabulary to your knowledge so far.  We did a lot in the past few blogs and it is good if you know the definitions of what you did.  This makes it easier to talk to someone who also uses Java.  Let start by looking at definitions that create a Java program.

Source File - This is code that is readable by humans or hasn't been converted to binary.

Binary File - Code that has been compiled so processor can execute the code.

Declaration - Parts of the code that are organized. For example, this declares a class:
class example{
}
The ellipsis is what declares the group and class is what we are declaring.

Class - A body that includes code with objects, states, methods, and behaviors

Methods - A declaration that returns a results, even if the results is nothing. For example:
public int isThis(int x){
     return 1 + x;
}
This would return 1 if ran.  There are 6 parts to this see this for more info.

  1. Modifiers define how the Method can be used.  This is usually public or private.  No definition assumes private.
  2. Return Type defines what will be returned.  Defining this as void returns nothing.  If a return type is defined, it must have a return.
  3. Method Name is the name given to the method.  In my example, I used isThis.
  4. Parameter list that is contained in the parentheses.  This is how we send data to the method. In my example I have x provided.  When we call on this method, we can say isThis(1) and what will be returned is 2 because 1 + x where we replace x with 1.  Also, the variable x has to be define with is defined as an integer in my example.
  5. Exceptions list is how we handle errors in the code.  The example above doesn't have any defined.
  6. Body is enclosed with Ellipsis.  Everything within them are a part of the method.

Constructors - See this

Object - Defines a state and behavior.  Created from classes. More info here

Variables - See this for definition 

The next blog will be about adding more functionality and parts for our car.  (Next blog isn't published yet.)

No comments:

Post a Comment