Running Java

Compilation, Loading, and Execution :

Before a Java program can be executed, it must be compiled and loaded. The compiler checks that the Java program is legal: that the program conforms to the Java syntax , that operators are applied operands of the correct type, and so on. If so, the compiler generates so-called class files. Execution then starts by loading the needed class files.

Thus running a Java program involves three stages:
compilation : checks that the program is well-formed .
loading : loads and initializes classes.
execution :runs the program code.

To run a compiled program, the Java interpreter always starts execution with the code in
the main method in the class you indicate. Thus, you must have a main method in the source
file for your class in order for your code to execute. You can, of course, add your own
methods to a class and call them from the main method.

Language Fundamentals:
A name in a Java program is called an identifier , which can be used for representing classes,methods,variables and labels.
If a name is composed of several words, then each word (except possibly the first one)
begins with an uppercase letter.
Names of variables, fields, and methods begin with a lowercase letter.
Ex: vehicle,total_number.
Names of classes and interfaces begin with an uppercase letter. Examples: Cube.
Named constants (that is, final variables and fields) are written entirely in uppercase, and
the parts of composite names are separated by underscores (_).
Package names are sequences of dot-separated lowercase names.
No identifier starts with the digits.
There is no length limit for Java identifier ,but SUN highly recommended upto 15 char's for the identifier.identifiers in Java are case sensitive.
we are nor allowed reserved words as identifiers.

A legal name (of a variable, method, field, parameter, class, interface or package) starts with a letter ordollar sign ($) or underscore (_), and continues with zero or more letters or dollar signs or underscoresor digits (0–9). Avoid dollar signs in class names. Uppercase letters and lowercase letters are considered distinct.

Reserved words:

some identifiers are reserved in Java,which has separate functionality and meaning ,such type of reserved identifiers are called reserved words.53 reserved words are there in Java.

keywords for Primitive Data Types:8
Four of them are integer types; two are floating-point
number types; one is the character type char, used for characters in the Unicode encoding, and one is a boolean type for truth values.

Data Type size range wrapper class Default

byte 1byte -128 to +127 Byte 0

short 2bytes -32768 to +32767 Short 0

int 4bytes -2147483648 to Integer 0

float 4bytes -3.4e38 to 3.4e38 Float 0.0

long 8bytes -9,223,372,036,854,775,808L Long 0
to 9,223,372,036,854,775,807L

double 8bytes -1.7e308 to 1.7e308 Double 0.0

char 2bytes 0 to 65535 Character 0 (empty

boolean not not applicable Boolean false

keywords for flow control:

  • if
  • else
  • default
  • switch
  • case
  • break
  • continue
  • do
  • while]
  • return
  • for
keywords for Exception Handling :5

  • try
  • catch
  • finally
  • throw
  • throws
keywords for Modifiers :11

  • public
  • private
  • protected
  • static
  • final
  • abstract
  • transient
  • volatile
  • native
  • synchronized
  • strict fp
keywords for class:6

  • class
  • interface
  • implements
  • extends
  • import
  • package
Object related keywords:4
  • new
  • instance of
  • super
  • this
return type keyword :1
  • void -indicates no return type
unused keywords:
  • const -use final
  • goto
New keyword in j2se1.5 :

  • enum -(enumeration) for defining list of named constants.
  • all keywords contain only lower case letters,symbols.

No comments:

Post a Comment