Free Guides

Language Tutorials

                            

SUN

Your Ad Here

 
               SUN CERTIFIED JAVA PROGRAMMER FOR JAVA2 PLATFORM 1.4

       Index     

Language fundamentals

  • Identifier is composed of a sequence of characters, where each character could be either a letter, currency symbol, digit or connecting punctuation. However first character cant be a digit.
    Examples of illegal identifiers :
    48chevy, all@hands, grand-sum

  • Keywords

abstract

default

implements

protected

throw

assert

do

import

public

throws

boolean

double

instanceof

return

transient

break

else

int

short

try

byte

extends

interface

static

void

case

final

long

strictfp

volatile

catch

finally

native

super

while

char

float

new

switch


 

class

for

package

synchronize


 

continue

if

private

This


 

  • Reserved Literals :

null

true

false

  • Reserved Keywords not currently in use :

const

goto

  • synchronized, abstract, strictfp and native can only be applied to methods. transient and volatile can only be applied to variables. static and final can be applied to both.

  • The class containing at least one abstract method has to be declared as abstract. However an abstract class need not have any abstract methods in it.

  • Literal denotes a constant values :

      • Integer Literals int, long, byte, short,octal, hexadecimal

      • Floating point Literals suffix f or F, d or D; exponent notation 1.2E-2

      • Boolean Literals true or false

      • Character Literals single quotes, hexadecimal with prefix \u, \ddd where ddd is octal

      • String Literals double quotes

  • Comment are of three types :

      • single line // ... to end of line

      • multiple line /* ... */

      • javadoc comment /** ... */

  • Comment start sequences are ignored when occurring inside comments, hence making nesting of comments impossible.

  • Primitive Data Types

byte

8 bits

-27

+27-1

Boolean

short

16 bits

-215

+215-1

Short

int

32 bits

-231

+231-1

Integer

long

64 bits

-263

+263-1

Long

char

16 bits

0x0

0xffff

Character

float

32 bits


 


 

Float

double

64 bits


 


 

Double

boolean


 

true or false only

Boolean

  • Default values for fields are false, '\u0000', 0L, 0, 0.0F, 0.0D and null. All static, instance variables as well as object references are automatically initialized. Local variables and object references need to be explicitly initialized before use.

  • If a reference is set to null, then the program will compile but throw a NullPointerException at runtime.