Thursday, 17 January 2013

Basic Java terminology

The purpose of this page is to help the beginner with the basic Java terminology. Advanced programmers and teachers often use words that are very common in Java and computers without explaining them because they are so accustomed to using them. Therefore, the beginner is often unable to understand what is being taught, because he is lacking in the basic vocabulary. The terminology below is meant to be easily understood, and is therefore not given a technical definition.
  • processor: The processor is inside the brain of the computer, and it is its job to read, or process, the instructions. It takes each instruction (after it has been broken down into basic computer language by the compiler) and runs it, turning on and off switches, causing the program to execute.
  • CPU: The CPU or Central Processing Unit, is the brain of the computer. It holds inside it the processor, the Arithmetic Logical Unit (ALU: the computer's math machine), and controls and tells the rest of the computer what to do.
  • code: Code just means the instructions that the programmer writes. The code of a program means the part that the programmer wrote up, and will give to the computer to run.
  • compiler The compiler "translates" the code that you have written in the language that you understand (like Java) into a language that the computer understands, either assembly language, or pure computer language (ones and zeros).
  • keywords: Keywords are words that have a very specific meaning to the compiler. Whenever the compiler sees one, it knows what it is, and translates it as such. For example, the word"int" means a number. Whenever in the program the programmer writes "int", it has only that meaning, a number. The programmer can never use it for something else. Another example is the word "if". If means try to see if what I am saying is true. If it is then do the next line, if not not. The word if can only mean that, and can never change. There are approximately 30 keywords.
  • control statements: Whenever the computer runs a Java program, it goes straight from the first line of code to the last. However, lets say you only want to run some code on condition. For example, you are writing an adventure game, and your player is hit, do you want him to die, or not. Well, it depends, how many "hits" is he allowed to have before he dies. So you want a control statement that says "if he is down to his last hit, then run the dying code, else subtract the number of hits that he is allowed, and continue". The if else is one kind of control statement, and it changes control to read from a different line of code, instead of the next. For more see the Control statements section.
  • variables Variables are words in your code, that have different meanings based on different times in the program. Why would I want that? The reason is, that that which makes a computer so powerful, is the ability to be given a set of instructions, and act differently based on the circumstances. For example, in the adventure game, your player has the ability to be hit 5 times before he dies. That number is going to change, as he runs through the game. Sometimes when he gets to the tower (for example) he will have 4 "hits" remaining, sometimes he will be down to his last one, and when the bad guy comes and hits him he will die. How is the computer able to keep track and know this? With variables. There will be one variable that is called "life", and you will start it off with 5. Every time that the player gets hit, you will tell life to subtract from itself one. You will also check, if life equals zero, then run the code to die. Since "life" is a variable and not a keyword, you will create this word. I called it life, but you can call it whatever you like. Also, when you go online, the computer asks you to tell them your name. You type in "Shlomo" (assuming that that is your name). Then for the rest of the time that you are on that site they always call you Shlomo. You go onto a new page, and they say "Shlomo, what do you want to buy?". They don't have a hundred premade web pages for each name. Instead, they collect your name into a variable, let's call firstName, and have one web page that says "print out 'firstName, what do you want to buy'".
  • operations and operands: Operations are symbols that have a specific meaning. Operands are the words that use the operations. For example the line " salary + bonus " means take the two operands of salary and bonus, and use the operation of "+" to add them. In Java the operation of "+" means to add, the operation of "=" means to get, and the operation of "==" means equal. "int payment = salary + bonus " means create a number variable called "payment" and let it get the variable of salary added to the variable of bonus.
  • int : in Java a number is represented by the word int. However, this is only one representation. For a complicated number like 4.5, you will need a different representation, like "double" or "float". The word "int" is a keyword that means number. If you write "int payment" you are saying that you are making a variable called payment that is a number. If you write "int payment = 5" you are saying that you are making a variable called payment that is a number and giving it the value of 5.
  • String : A string is a variable that holds a word, or a few words, or a mixture of characters, that do not mean anything besides for a quote. Meaning: when I go online and they ask me for my name, I tell them "Shlomo". They save that quote of "Shlomo" in a String variable. The actual word "Shlomo" doesn't mean anything to the compiler. However, whenever the program wants to call my name it says "print out that String that we called firstName" and whatever is in that String is printed. For example, if I were to write a piece of code "String message = "How are you today?", I would be telling the computer that there is a variable called message, and whenever I refer to that variable, I am referring to the String of "How are you today?".
  • Primitive : Almost everything in Java is an Object or Class, meaning that it has inside it operations, behaviors and methods (meaning stuff).Primitives are the exception. A primitive is only what it is, and nothing more, it can not do anything but hold that one piece of information that it is supposed to hold. For example, an int is a primitive. It can only hold a number. A String is an Object, it can change itself. Meaning, I can tell the String change yourself to be capitalized, and the String of "hello" will change into "HELLO". A primitive can not do anything besides hold itself.
  • Debugging : debugging means finding the errors and fixing them. 
  • Objects, classes, class interfaces, methods, argument lists, parameters, inheritance
  • interfaces, user interfaces, and GUI : An interface simply means the way that two entities communicate with each other. For example, if two people write two separate programs that interact with each other, they communicate with each other through an interface. If you write a program that works on a real system, like an ATM, then in order to communicate with the money dispenser, you will need an interface in between. An interface allows the ability to say I don't know how you do what you are doing, all I need is a common way to communicate and get the information that you are giving me that I need to use, and give you only what you need to use. (In Java there is a special thing called an interface, check out the above note). A user interface is the way that a user interacts with a machine. The user doesn't need to know how the machine works, or what is going on inside, it just needs to be able to interact with it. The command console below is a user interface. A GUI or Graphical User Interface is an user interface, that talks to the user using graphics. For example, Windows is a GUI. Instead of typing in the word "exit", "OK', or whatever you will need to type, in a GUI you can press a button, use a scrollbar, etc.

No comments:

Post a Comment

if You Need Any Help Then Write Us:We Come Back With Solution