Exercise p12 #2a,b and #4
Classes
Definition: A single unit that defines both data
that will be used and the operations that can be
performed on the data.
methods are the operations (procedures and/or functions)
object is an instance of the class
examples chromosome/gene map => you
blueprint for a house => your house
Program Translation
Machine Language is the code boiled down to the 0’s and 1’s.
Other High Level Languages: Java:
Source Code Source Code
| |
Interpreter/ Compiler Compiler
| |
Object Code Byte Code Format
| (Machine Code not
Linker geared to a specific
| processor)
Executable (.exe file) |
Java Virtual Machine
(Interpreter… Machine
specific details done here)
|
Program Execution
Java Translation Process (Same as above)
Java Java Java Java Machine
Source( Compiler ( Byte ( Virtual ( Code
Code Codes Machine
(file.java) (file.class) (interpreter)
java file
Identifiers(variable names):
• can contain letters, digits, underscores and dollar signs
• first character cannot be a digit
• cannot contain blanks
• cannot be a keyword (p26 Table 1.2… below)
• unlimited number of characters but sticking to maximum lengths of 14 to 20 is better.
• use mnemonics – words used as a memory aid
Java Reserved Words (from page 26 Table 1.2)
abstract default if private this
boolean do implements protected throw
break double import public throws
byte else instanceof return transient
case extends int short try
catch final interface static void
char finally long strictfp volatile
class float native super while
const for new switch synchronized
continue goto package
Exercise p19 #1 (or “Name Game” quia activity)
General Information
Primitive Data types: int, char, float, double
Java is very case sensitive.
Single statements must end in a semicolon ( ; ).
Each program must have at least one class.
Example:
public class HelloWorld
{
public static void main (String [] args)
{
System.out.println (“Hello World”);
}
}
Assignment 1: Create the above “Hello World” application
Comments
// - single line comment
/*
*/ - Multi-line comment
/**
*/ - Multi-line documentation style comment
Dialog Boxes
import javax.swing.*
JOptionPane.ShowMessageDialog(null, “Hello World”, “Message”, JOptionPane.QUESTION_MESSAGE);
//different types of messages shown on page 37
modal – user must respond and close before program continues
modeless – application continues
Two types of methods
1. strict methods – must be used with objects
general form: objectName.methodName(arguments);
2. static methods - do not operate on an object
- receives all data as arguments
- if declared in a public class, can be used
outside of it’s own class.
- general-purpose; utility methods
View the First Book of Java Chapter 1 Powerpoint
Assignment 2: Create a program to input two decimal numbers and calculates the average and outputs the answer. You must use dialog boxes.
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- ny lottery pick 3 and 4 results
- difference between 2 1 and 4 1
- enneagram 2 and 4 relationship
- new york lottery 3 and 4 digit
- pick 3 and 4 ny numbers
- 3 and 4 digit new york lottery
- difference between 3 73 and 4 10
- b and c alternator
- personality types a b and c
- enneagram 4 and 4 relationship
- b and r innovations
- r b and hip hop songs