Monday, May 9, 2011

Quick notes for Week 3

Key points:

1. // - single line comment, source codes that starts with this is not executed.

2. /* */ - multi-line comments, source codes that are in-between this block comments are not executed.

3. Java is case-sensitive. HarryPotter is not the same as harrypotter.

4. The class name always starts with a letter, preferably in caps and meaningful in nature, e.g. public class MyFirstProgram

5. The class name must be the same as the filename.

6. There are many keywords that may not be used, refer to textbook figure 2.1 for a list.

7. A method is a section of a class that performs a task. e.g.
public static void main (String[] args) --> main method of a class, all classes must have a main method.

8. System.out.println("Hello") is different from System.out.print("Hello"). println prints a newline character, bringing the cursor to the next line.

9. Whatever that is encapsulated in " " denotes a string.

10. You can manipulate numbers using
- addition +
- subtraction -
- multiplication *
- division /
- modulus (remainder) %
- more than >
- less than <
- comparing equals ==
- and operator &&
- or operator ||
- not equals !=

11. Data types to remember
- integer : int : stores numbers
- double : double : stores decimals
- char : char : (see 2.3.3 of textbook for detailed information)
- boolean : boolean : true or false

12. comparing boolean expression
true && true = true
true || true = true
true && false = false
true || false = true
false && false = false
false || false = false
!true = false
!false = true

13. Joining strings or numbers
- "Hello " + "World" --> "Hello World"
- "Hello " + 21 --> "Hello 21"

Quick notes for Week 2

Key points:

1. A computer is a machine that performs computations and operations based on a set of operations --> a computer program.

2. A computer consist of :
- hardware
- software

3. All data on computers are stored in binary format (1 or 0)

4. All characters in the keyboard are identified via a 7-bit ASCII code. But as all characters are normally stored using 8-bit, a 0 precedes the binary code --> e.g. 'a' : 0110 0001

5. What you write in JGrasp is known as source code. This is then compiled by the Java compiler into machine language (bytecode for Java), which the CPU can understand and execute.

6. Java is:
- platform independent.
- secure.
- reliable.
- uses the Java Virtual Machine (JVM) to execute the bytecode.

7. An algorithm is a step-by-step procedure to achieve a purpose or solve a problem.

FSP Quick Notes

Hi People,

Use this blog for your revision and to ask me questions.