You are on page 1of 74

palteam_ps@yahoo.

com

!" # $ %#

Java& '

Sun Microsystems
%&

'

! "# $
$(

."

+)$

"

"Java 3
$
$

: ;& 0

"

)"'

'

!4 2

2 8

8 + ' $ +'

*) $ "

& 0

! 4 )Virtual Machine"

46 9 5 $

!+ 9
@

6 5 JVM

!+ 9

95

"*)"Write once, Run Everywhere"

1' 2
3

)"' ' Sun

'0

8 + ' *) ) *) <

" ?=> Linux ( !+ 9

"

Windows
<8 + ' &

? '
35

&
7

FD+ %

A$

!+ / 4 9

Web -

& D+ 8

3$

' BC

9>

' @ +E'

(Java Applets)

- 7D!

"# 9 5

'
'

35

'

@ +5 9 5
G /(
B 0

.
+ +

&

" 9

C
-'

'
$

8
&

' $
H

% I A

.? 2
J
J
B
<

"4

B
0

9
D $+

palteam_ps@yahoo.com

' !+

B $

+)

K4

0 +L 4

"4

M N M)
8

'

) $
!4

J @ +E' 7
,

& B#

' E % & (Garbage Collector)

D+

!" # $ %#

/ D! /
"

-)

" "
,"

"' B

'#

O 4) / D!

' N MG
Object/!

," '

" C " ,C

K( !4

;&

3 "

Sun

: +
JDK

(Java Development Kit)

9 5 "!
C

8 + ' $

'

.;& D+

& D+ ' 7
&5 0

," '

9 java.exe 8 + '
' %&

" !
)

*&

-javac.exe

*& (byte code)

*& 8 + ' *)

JIT ) (Just-in-time)
D

&)

'

-java.exe

& D+

B#

0'

'

95 C

';
>

&

D 3)
& 95 C
.$

(Applets)
"4

'

' & D+ ' 7

*& -applet Viewer

6 ( Documentation ) > "

*& -javadoc.exe
< HTML D

JER

!'

(Java Runtime Environment)

palteam_ps@yahoo.com

"#

$%

-2
&%!

'

!" # $ %#

%
Object Oriented / " G
"4

' $&'
"

*& "

>

8 '

"

'
B

" $

" Q,
/" G

'

F )

"

!D

, ' ,"

+'

'

95

35

@ +R 8 + '

8 + ' @ +' ,"


! + @ +5
'!)

," " , D'

' << 8 + ' @ +5

!4 $

('

'

'

"

8 + ' @ +' ,"

8 + ' $

"

<<

. >
JVM

8 + ' *"
;

+ '9

' C

Programming (OOP) :

'
'

' "

'

)8 '

>), >

'

Object !+

JVM : ! 4 & D+ ( '


E

'

8 + '

)
P

'
.$

"

GS

$( !D $

+ Class Libraries :

)
'

# $( ! '
+ ' "

)"'

@ +5
)"'

""

35 >

B $

. + +R B $
( +' F )

# $( ! '

OOP
$> $

T '

%&

"+ C,C++ : U
' C,C++

C++

+'

O #)
4: 9 +

P
)

$'

4:
.

palteam_ps@yahoo.com

!" # $ %#

*+# )
,# *

JVM :
#,

JAVA Virtual Machine , , '


<$

+)

8
8

' $

'

' ,C G 9

+)

&

JVM "

+ -

8 + '

95 $

&5

>-

8 + '

.8 + ' $
" " E' W
$

+ +T S! !4
' HTML /

"4

$=4

)HTML . U / 2
52

"

+ +T 8
@

0'

' "W

2 "

CLIENTSERVER .

palteam_ps@yahoo.com

= << $
)

UNIX ,
+

Java Applet -2
' V +)
V +

( "
"

Applet @ +5
F " $=4 X @
'

+ +R
,

> 9

> Applet 8 + ' &

' ,I +

+)

*) " " 5

- # Java Application -3

:
'

' "

! *&

.
O 4G

server " 4 9 Applet 8 + '

& HTML / $4 "

+B $

, D

+ $ Runtime

>$

' ! 4 JVM " " 5 " ' ,"

) WINDOWS $

( +E'

' @ +5 9

S ) 2 C+5

+)

8 + ' +I Software

)B

! 4 JVM /

>

2'

0'

'

S" ' $

+) S3 )

' ' K 4 ) DISKTOP '

!" # $ %#

"
#+

O 4G

G B

+9

+ $

%&
-

'

' , D *) F )
#-

%&

"4 +

<8 + ' $
<

'

$ D'

'

, '

;& -

'

"! + ++E

&

'

'

<Y << $

5
!4'
<+

$ + "+

&5

&

"

3R

'

=>

count++;

5 / 3 >count

#-

'

;&

'
<"

N'

3 ''

=> - 3

'

x*y*z
" 'y
'

'- 3 > x
B

4)

'

"' z

#S )'

2' +

+ - 3 > '
<

palteam_ps@yahoo.com

'

, 4G

!" # $ %#

#+
postfix operators

. !

[] . (params) expr++ expr--

unary operators

++expr --expr +expr -expr ~ !

creation or cast

new (type)expr

multiplicative

* / %

additive

+ -

shift

<< >> >>>

relational

< > <= >= instanceof

equality

== !=

bitwise AND

&

bitwise exclusive
OR

bitwise inclusive
OR

logical AND

&&

logical OR

||

conditional

? :

assignment

= += -= *= /= %= &= ^= |= <<=
>>= >>>=

palteam_ps@yahoo.com

!" # $ %#

V +

8 + ' $

$=4 ,

'
$ "

"4
$

Format

&/ 0
8-bit two's complement
byte

!
Bytelength
integer
Short integer
short

16-bit two's complement

" #$% & %' ()* # + ,


2- 34

- . /0&1

Integer
int

32-bit two's complement

34
!

" #$% &


2-

%' ()* # + ,

%' ()* # + ,

Long integer
long

64-bit two's complement

34
!

" #$% &


2-

""

+ &/ 0

Single-precision floating point


float

32-bit IEEE 754

34
!

" #$% &

%' ()* #$45

6 )7*

2-

Double-precision floating point


double

64-bit IEEE 754

34
!

palteam_ps@yahoo.com

" #$% &

%' ()* #$45

6 )7*

2-

!" # $ %#

2 3

A single character
16-bit Unicode character

char

8 % 948
A boolean value (true or false)
boolean

true or false
;+

4+< %' ;+

!: # +)

4
Import java.io.*;
Public class Count {
Public static void countChars(Reader in)
throws IOException
{
int count = 0;
while (in.read() != -1)
count++;
System.out.println(Counted + count +
chars.);
}
//..main method omitted..

palteam_ps@yahoo.com

!" # $ %#

5
"

# )

B $

95 L +

+ Array U' /

ArrayV + + ! ++

B $

+ )" +, > + )

"4 + &

6
G

%& - +
V +)

V +
9

# G B $

) +

>
+

+ '

+
< !4

;& $> "#A /


Strings.V +

Arrays
D

'

+ )
, '

'

)-

++I

V +)

Array ) ' < + ," D


# G V +) / 4

'B $
B

+9

+ '

"# # G ;&

# )

<?Y <<<

!A
Z

$>

++

int[] arrayOfInts;
int[] arrayOfInts = new int[10]
for (int j = 0; j < arrayOfInts.length; j ++)
{
arrayOfInts[j] = j;
System.out.println("[j] = " + arrayOfInts[j]);
}

palteam_ps@yahoo.com

!" # $ %#

<?

# G V +

;+

? =
<?lengthA0

A 2D

;&

A2

<
J 2+

$>

+
<2 ,

'
2

&

(
"

+#

"" ' + # %& " '

A
+

%+

'$ G

#2

9
J

+ "4

!+ $

+D3) >

' ' +#

4)

, ' Array V + Z

Rlength $>

@C C

new

G B $

2+

"4
G + "4

>

=
+ @3 )

%&

<0'

Strings
< # G $"' /

0'

V + ' 2' V + &


B > 0 ? @ " 4A

String[] arrayOfStrings = new String[10];


for (int i = 0; i < arrayOfStrings.length; i ++)
{
arrayOfStrings[i] = new String("Hello " + i);
}

palteam_ps@yahoo.com

!" # $ %#

;&

A2

""

2D

'$ G

+#
? =

?length< 0

2
<+

#2

+ "4

!+ $

+D3) >

!"
*

*
4

, - +*$ $ %& ' ($ #


- . / 0 1 0

+,
2 3 & 0

7 3 #
Z
9+

$ "

&'
)

++
G

B+!

if-else, switch-case
for, while, do-while

@ 4G
)
D 4

try-catch-finally, throw
break, continue, label: , return

palteam_ps@yahoo.com

>

!" # $ %#

!' = > ' < 3+


# &4
*

B3+

=4

83 #9 :

" $3

&5 $ + =>

8 + '
<&

=>
$" 'X

+
#

, "

$4"+

$" ' Y

=4

# $"

"C

'

! X

<3)
8 + '

@ 4 / + )B

Z;

<B# &5
+ ,
$

C
' ' D4

%+ " I
,

N ''

+)

;&
+ $

;& 2 +
>

<

G
G %

+
,

"' O

G' )

) $ $> O
<$ !D

palteam_ps@yahoo.com

!" # $ %#

" $3

if - else

' ?

if ( ' )

Statement

else

Statement

) )Statement
*) +

Statement

G'
<Statement

!? '
G'
< '

palteam_ps@yahoo.com

&5 +
!

+)

'
', D

!" # $ %#

/!

'

'
!

>-

=
Z ?O

%
=

'

%+ N A $ >
-

testscore
' grade

"4 +
"4 +

int testscore;
char grade;
if (testscore >= 90) {
grade = A;
} else if (testscore >= 80) {
grade = B;
} else if (testscore >= 70) {
grade = C;
} else if (testscore >= 60) {
grade = D;
} else {
grade = F;
}

palteam_ps@yahoo.com

!" # $ %#

switch - case
+

)9

'4

G &

"4 +
<+

"

+ '

'

9
+ -

)N

=>

Z %& 9

'

+ -

)N D

)/ O + <+

B'
Z

$ > &4I+

month ; +

" + ++) >

&E month

+ '

#9

@ +' 7 !

'

)/ +
$ ') )April

' +

>G

G &

int month;
switch (month) {
case 1: System.out.println(January); break;
case 2: System.out.println(February); break;
case 3: System.out.println(March); break;
case 4: System.out.println(April); break;
case 5: System.out.println(May); break;
case 6: System.out.println(June); break;
case 7: System.out.println(July); break;
case 8: System.out.println(August); break;
case 9: System.out.println(September);
break;
case 10: System.out.println(October); break;
case 11: System.out.println(November);
break;
case 12: System.out.println(December);
break;
}

palteam_ps@yahoo.com

!" # $ %#

'
?

for

for ( "' ;

+ ; $"

statements

$"

"'

," C'

'

$>

&4I+

int i;
for (i = 0; i < 50; i++) {
...
// @

' # +

...
}
) 9 5 [\

'

'

/
< =*

palteam_ps@yahoo.com

'

) O + $>
i

&
# 7'!

!" # $ %#

while &

while ( ' )
statement
<

statement &D+ &5 7 !

'

$>

"
++

while (X != 10) {
X++;
System.out.println(X does not equal to 10 yet );
}

&

0 do while

do {
statements
} while (booleanExpression);

<7 ! booleanExpression

palteam_ps@yahoo.com

'

" statements $

!" # $ %#

$>

O +

int c;
...
do {
c-- ;
...
} while (c != -1);

6!
A/

break

G + "4

=
<

' , D

palteam_ps@yahoo.com

%+I 9 G

switch - case

- &

2 B'

@C

- &

/#

G 95

$>

break /#

G O 4) D

%+

!" # $ %#

I' > Z

+U'

% & B' + >

'
Z

breakToHere: someJavaStatement

) *I' > Z

+ '

' breakToHere
=

CD B

+ / 4 B#

+ 4 O +
%& " ' @ +

break breakToHere;

"4

goto

G' 2'

G & Z

<

palteam_ps@yahoo.com

!" # $ %#

Inheritance 4
oop
9
* 2

!4

'

#"

2 D! >

'

' 2>

super class-G /+! ' 2 D!

8 + '
*)

abstract classes
"4 +

+ class /+! >

+!'

"

2+ "

>

)0

+ "#.

'

+ 4) /+!
8 '

"

subclass

)+ "
D

'

G N'

+ "+
+
public .
)B
class /+! *)
$ '
public
*& /+! *
*& /+!
+

subclass2
" )-

95

*& /+!

>)%

, '

'

class *) abstract classes


4:

'

<<

( abstract classes +
V 3
subclass

'
$

method

3) / + )B3+ ) $'#extends

public class SUPER {


public int x;
public int y;
protected String name;
public void method()
{
.
}
}//end super class
class SUBCLASS extends SUPER
{
public static void main( String [] arg) {
//can use any parmter or method by class supper
{
{//end subclass

palteam_ps@yahoo.com

!" # $ %#

'

<$
? ' A," " / D! 0 4 ," 5 *)Z >
O 4) ," " K( !4

"

/!

G "" P >
2

,"

Zopp U

'

K( !4 FD+

^ ?@ ')A
< '

+ A$

G ,""

>

subclass

'

<extends

%+ F

H D
"# / D!

/! ' ! 4

-G /! 9

superclass

-) ' /! $

/! 9

0
0

>

" ) >

>
<?"

'

=
ZS )

sub object is a super object


Z*) 7 !

MF

-G /!

N M

'

/!

N M *) ) +

super object is not a sub object


public V +

&5 -G @ 3 ) 9 5 $ !

<private V +
&5 2 5 $ !

'

2+

&5 -G @ 3 G $ !

package access V +

'
2+

-G @ 3 )

< package U FD+


'

/!

-G /! $'#

5$ !
<-G /!

palteam_ps@yahoo.com

Z protected
C

,"

/! Z_ + >
'

/!
+

&5 )

'

&5 )

/ D!
!" # $ %#

Z_> >
/! $4 " -G /!
< '

/!

,"

' +

M ! ," 5 *)Z over riding U

M -G

"# 2+) % &

-'

'
Z_ '

<

/! -G /! 9 5

super $
Z_

<
39 "

/!

N M "4

>

>

+ Z is a U

/! @ "

$> Z has a U

< 2' + *& /!


Z_ "
U 0

%&

'

/!

< exeptionZ *) @ +>

+" 8+

9 5 -G /!
casting U B3+

&5 ^ *

casting
Z_ '

*) <super $
3

'

+' @ "
&5 ?

-G A object /!

+'

B3+ 9
'

null^ +
3

+ ' -G /!

+ ' $4 " super

' false^
+' @ "

`
' '

D!

'
B3+

'
-`

/!

&5^ -G
]

+ ' &D+

*& A-`
+' %+

<?

palteam_ps@yahoo.com

!" # $ %#

Z final V +
<? " G -)
U $

A _"')

final V +

< final '

'
< final V +

'

2 0

P < '

/!

=
_ !)

final V +
&5 Z final

/! B $C+

'

2+G % & 2 &' "

>

Z static V +

< final

< 2 &' "

/ D!

/! P

V +

/! P

over riding

Z private V +

E final V +

/!

C &4I call U

2+ _ "' B3 final V +

Pa

&5 P

@ "

"+
<

Zfinalizer Pa
/!

,"

A finalizer U @ "

? finalizer

@ "
<

; ')

finalizer U &4I

2+E gc $ $'#

%+ F
)-

"+ super

,""
2+'

>

&

+"

E / D! " )

sub B $

+/

$' object

inalizer *) B3+

&5

finalizer $ + 3 &5
Z

'

B3+

?super.finalizerA

palteam_ps@yahoo.com

!" # $ %#

; 34 9

Exceptions
'

M B3

" "+ ;"

N M

@ +>

Exceptions

%
'

'

C4 '

Data Members

+ '

&
+

).

'

M B3 (

Throwing Exception; 34 9 C
9 5) 2 &#A 2

)-

.$
2+ $ + ?

( +>

argument

V + & B $

'A

;@ +') "

! !4 2 '

) Exception /!

BA/

/
%

N
+ '"

N M

5
@C

*& "

2
catch it
" ) Exception (/!

/ D!

+ ?N MG A

@ +>

bF ) N D'

RuntimeException/! " ? 2( +')


.F 2+ 8 +
.F V +) "

"

'

+)
):

2+

method %
4 0'

catch it*) method$


try

'method $ "
catch

palteam_ps@yahoo.com

+%

+ '

"

+ '
%+

3 @ +>

&5

%+

&5

4%"

2+E

Z$ G

32 %
3? ! $

%+

"
A

!" # $ %#

"
try{@ +>

/& 2+I' %

catch(

"

@ +>

$!

"

&5 ;& D+ *

}
*& "

\ ?@ +>

'

- +

B3+ A @ +>

try-catch)
@ +>
;&

"

*& /! O

?/& A
A9 )O

"#

;&

Z +>
I'

9 5 @ +>

4
5 "

B
)
i
"

int myMethod() thorows EOFException {.}

myMethod() :

"

*& /!

"
public MyClass{
..
try{ int x= myMethod() ; }
catch(Excrption e){ .. }
..
}

palteam_ps@yahoo.com

!" # $ %#

RuntimeException ; 34 9
/ D!

/ D!

Exception)

Exception ./!
'

+ N M)A

'

@ +>

%+

*& RuntimeException /!

4 "

' Compiler

% 7

@ +>

;&
'

.
/!

N M"

V + 2+ 8 + *& /! V +

'

RuntimeException)
N

9+ 'A
' "

"4 A

"

;&

@ 4) -' '

) I 4 V + (= @ +>

.
4

@ +>

'

%+

Catch it
< ?% &

%& B

" ) 5A

'

; 34 9 = D !4
>
D! 9

( +>

$>

)
'

V + Z @ +>

/!

ArithmeticException :
.

=> a

/!

N M9

#$

.2( ' "


2 +

'

D!

2( +') "
+

N M

ClassCastException :

a /! FD+ F " " /! 9 5...


C4

ArrayStoreException :
.

2 O

= null ( 2 # N M $

data member .$ ;" + 5 )


+ B 2 + @=

method 9 5

+' )
'

D!

2'

+ - +

NullPointerException :
method $

IllegalArgumentException :
.

palteam_ps@yahoo.com

new )

'

!" # $ %#

' 2

A 2> "

@ +>

B $

Z$ G

95 " +
(2> " $
"
\try

? D 4 / D! V +
& D+ $ ++ Catch

A > ) ) @ +>

+ H +' 2 &D+ @ +>

"# "

*) "

&

&5
finally
cStatment1
cStatment2
cStatment3
cStatment4
[

2+ /

try
2( '6 " ) ) IOException ) + A
$ +
$ +
' @ +>

>

"
catch(IOException e){
O *& @ +>
8 "

' ""

"

C=

IOException V +

@ +>

5 ) <<

5 5 <<< + >
.

palteam_ps@yahoo.com

8
finally
&5

@ +>
.

catch

catch % +

E
throws
"4 ,"( (

)
$ ' V +

@ +>

R &4 + O
/ &

try

/& method $ ) /!

V +

"4

RuntimeException

!" # $ %#

@ 4) 9

$!

'

.%

+ '
}

"
catch(Exception e){}

"# catch

' 2 "" *& V +

F 2 &# O

!!dd $
! <<< @ 'R >

) @ +'G

'

V +
'

*& @ +>

>)

"#

@ +>

> ) %+
) B3+ )

catch

'G
).%

+ '

@ 4) 9

' G -G /! Exception

$!

>

'G

'@ +

catch (Exception e){}

. @ +>
' +

V +G $

)B

@ +>

V + *) $'
. "

"#

@ +> =

"
}

" G %

*& "

finally{
=

:
.@ +>
> ' catch $ K
=

.8 + '

95 $ +
) +

@C ) "

palteam_ps@yahoo.com

&

/&# 2+ 8 +

Statment2; & D+

> H +' Statment1; & D+


finally

95 $ +

+ ;& 9 ; ' +

>

$!

) N D'
E

(= @ +>
Statment3;
Statment4;
& D+ *
!" # $ %#

.
$

try

3"

& D+ *

"

@ +>

4 finally
*) try

. "

3"

) finally

/&

& D+ $ +

catch(Exception $
catch) $

*) 2

" 2+
+

catch ( $

' +

A @ +>

catch

4+ 9
-

+G B3+

2+ 9 5 *"J

" ' @ +>

&5 Z

' @ +>

+ "#

++5 % + "#

? #" ,

'

catch $ $

: +>
.2 +' +

e)

@ 4) 9 5 *"J

9!#) )

<I 4
+

'

" ) )A Exception /!
-'

N
'

&5 > ) ," D

>), '

) '

2+

catch

"#

@ +>

95 ;

*& ?;@ +')


<<<< @ +>

/! K( !4 N '

?Exception /!
String
, '

&
'

+C4
-G A @ +>

;&
$ 2>

," D =

*& Throwable

2 Throwable /!

& 95

@ +>

"

< @ +> = ''


Z @ +>

$
? '

(
+

>" A + '

palteam_ps@yahoo.com

Throwable /!
'

+'

'
+

N MG

, '

!" # $ %#

" $

Record of execution Stack & D+ F"

<<<< @ +>
@ +>
?L 4
?@ "
@D#'

$4 "' @ "
' @ +>

"

$ )

"

$4"
"

"

"

# *

method $ $
<@ "

method$

4) LIFO )"' -

"#A

"

''

9
"

$! + 9
# '

$
@

& D+ F"

>

&

Z Stack F" A
'B
$

method$ ;&
' @ +> =

F"

&

'

@ "

>

method$

"
public class class3\
public static void main(String[] args) { method1[c?A
[

"
class class1\
method1 () { method2[c?A
[

palteam_ps@yahoo.com

!" # $ %#

"
class class2\
method2e \ ?A
@ +>

-'

"

[
?Amethod1 @ " = $!

) 9 5 class3

main ,@ '

& D+ $
@ "

2+ 3 "

class1

F"

?Amethod1 "

)"'
;

' $>

@ "

$ ) & <<<<

' ' & class3

%
?Amethod2

<$ G 0
"

"

class2

& @ "

?Amethod2 "

& D+ $

' & class1


< @ +>

@ +> = -'
4G

LIFO -

? ;@ +') "

)A Exception N

"

%
"

=>

# F"
95 2

'$

>
Z$ `
"

@ +>

"

palteam_ps@yahoo.com

*& "

# ZPackageName.class2.method2

!" # $ %#

*& "

# PackageName.class1.method1: method2
@ "

@ "

2 *& "

# PackageName.class3.main : method1

Z Throwable /!
F=

' M @ +>

/!

,"
O

methosd$
"

L 4 9

& D+ F"

'

Z ?AgetMessage

< @ +> =
A

! 4 /!

Z ?AprintStackTrace
? console$

L 4 O

'

"" +

'

FD+ Z ?printStackTrace(PrintStream s

< & D+ F"

method$ ;& @ "

+ 9 5 >G @ D # F"

9 + method$ ;& @ "

# 7'!

2 - + *&

"

Z ?AfillInStackTrace

@ +> = *
< '

palteam_ps@yahoo.com

#
@ "

!" # $ %#

Interfaces
""

+
0(

"

+)

3 O 4G V +G 2 "4

;& 0

(D

V +

+3

(D

)-

!+

" ) !+

K( !4
!
"

[ <attributelist> ] [ accessmodifier ] [ Shadows ] _


Interface name [ ( Of typelist ) ]
[ Inherits interfacenames ]
[ [ modifiers ] Property membername ]
[ [ modifiers ] Function membername ]
[ [ modifiers ] Sub membername ]
[ [ modifiers ] Event membername ]
[ [ modifiers ] Interface membername ]#C3
[ [ modifiers ] Class membername ]
[ [ modifiers ] Structure membername ]
End Interface
D!

Attributes
/

"

;&

*
9

) +

(D

O 4)

Y <<< K( !4

" /(

""
;&

D
Default
!+
3

"'

3 (

K( !4

!+

/(

"4

' 3

++
!4 ""

palteam_ps@yahoo.com

"+

( *)

/
3

O 4)

7 ! "+ Private ) Public $> $ !


"4

""

) +
@

FD+ 9

;& /

"

""

FD+' ,"

*) Module ) Namespace O
'

O +

) Public $> $

>

!+

)-

Shadows
(D

*& "

3 ,"
) )

7 ! 0'

M
3

""

"4

Shadows ) Overloads "4

!" # $ %#

Public $ !
7 !
I/

""

(D % O
'

"

)"'

"4
9

' (D ;&
;

) $3D

%+

!+

= R

*&

"+

>G N' : O +
K( !4 N ' 9

K4 G

/ + )
"

Interface IPerson
Property Name() As String
Property Birthdate() As Date
ReadOnly Property Age() As Integer
End Interface

'

N'

++

)
"

Interface ISomeMath
Function AddNumbers(ByVal a As Integer, ByVal b As Integer) As
Integer
Function AddNumbers(ByVal a As Double, ByVal b As Double) As
Double

palteam_ps@yahoo.com

!" # $ %#

Function Multiply(ByVal a As Integer, ByVal b As


Integer) As Double
End Interface

K4 G

"

/ + )
"

Interface IPhonebook
Inherits IPerson

Property Phone() As String


Property Address() As String
Sub ShowInformations?A
End Interface
"4 + Phonebook
$

/3

(' )O +

) + " +/
(D %
," "

( +"

7 ! "'
(D 9 5

5 :

Implements
%

!+

G
"

Public Class Phones


Implements IPhonebook
Public ReadOnly Property Age() As Integer Implements IPerson.Age

palteam_ps@yahoo.com

!" # $ %#

Get
End Get
End Property
<<<<<<<
End Class
,"

(D

> ) "4
"

Class SomeTest
Implements IPerson
Implements ISomeMath

Public ReadOnly Property Age() As Integer Implements IPerson.Age


Get

End Get
End Property
<<<<<<<
Public Function AddNumbers(ByVal a As Double, ByVal b As
Double) As Doubleg
Implements ISomeMath.AddNumbers

palteam_ps@yahoo.com

!" # $ %#

End Function
<<<<<<<

End Class
$

(D
;&

B - +

Public $ !

""

' !+
"4

% - +
'

3 ' $4 "'

"

!+
f

'

9'

/
9

$> &
"

Interface IPhonebook
Interface IPersone
Property Name() As String
Property Birthdate() As Date
ReadOnly Property Age() As Integer
End Interface

Property Phone() As String


Property Address() As String
Sub ShowInformations?A
Event SomeEvent(ByVal a As Int16?
End Interface

palteam_ps@yahoo.com

!" # $ %#

(D

"4
"

Class test
Implements IPhonebook
Implements IPhonebook.IPersone

<<<<<<<

End Class

palteam_ps@yahoo.com

!" # $ %#

Abstract E
9

$"

*) "

B# *
e2 0

"
)

- "
<<

"

"] $D

=
' /

'

=4

"
)

/+!

&

9+
46 9+ '

) (D & << ; M

/+!
/

'

D "

<< '
$

9+ '

interface

4) ' /+!

"

" )

/+!

/+! % &

2+ "e $

3 ) methodUU $' ,"

h2

, ' << "

95 $

$ i

"
implement

/ +!G

A3 0

/+! 0 + / <<
,"

/ +!G

+
M + D "
,

abstract class PRINT


{
int X;
PRINT(int y){X=y;)
abstract void print();
}
class IMPPRINT extends PRINT
{
public void print()
{
System.out.println(super.X);
}
}
public class main
{
public static void main(String [] arg)
{
PRINT p=new PRINT()//error
IMPPRINT i=new IMPPRINT();
i.print();
}
}

palteam_ps@yahoo.com

!" # $ %#

/+! /

$'# abstract

&' + #

=
B'

.."
/+!

+ ' B'
"

"
e

B'

G $4 " "

" *)
"

"

+ )
9+

)"

" D

=' *& % & 0

/+!

)-

& D+ "

*&

3 )method print U
'

)-

' #

M /+! $4 "' ,"

/+!

main

V 3
9

=+

' # *& IMPPRINT /+! + ) >

object &4
"

"

/+! $4 " )

..
"

2+ 9

*) B3

"' F #

N'

B' B3

*& "

/+! 9

- "4

,"
"

M B'

M -G /+!

abstract class

"

S"

'

+!

object

/+! 9

7 !

/+!

8 + *& I 4 V 3

F
<<

+@

$ 4"R %

)
e

'

DJ

FI -

$ )

/
$ '

D! / J

$ 4"R

$ 4"R

) $'<<

"

0 " +! $=4

Z - ' +)
$ "

palteam_ps@yahoo.com

' ,@ # 9

%+

N'*
$ 4"5 Joption V +

$ 4"T buffered #J *
<8 '

?,

'

"
-

=>
*& $ G - '+G

$ 4"R

)
5

=+

A system inP
!" # $ %#

)/

95

'

$ $

A InputStreamReaderP
?C

#J

&

)/

;& B

A bufferedReaderP
?

"

7'!

BufferedReader re=new BufferedReader


(InputStreamReader(System.inc??

object +I +) % & % &

'2

2 +(

'
@

class bufferreader U
java

$ !

object
IO '

"

,@

re )
"+

:
"

import java.ioca<
class BRRead\
public static void main(String args[])throws IOException\
char cc
BufferedReader br = new BufferedReader(new
InputStreamReader(System.inc??

palteam_ps@yahoo.com

!" # $ %#

System.out.println(Enter charactersc?h
c = (char) br.readc?A
System.out.println(cc?
[
[
$

'

) +#

+"

' $4"+ ) " + "+ "

95

' $ 4"5

>"
/

$=4

0'

"

char

$
" '

)
,@
Z"

import java.ioca<
class BRRead\
public static void main(String args[])throws IOException\
String cc
BufferedReader br = new BufferedReader(new
InputStreamReader(System.inc??
System.out.println(Enter charactersc?h
c = br.readLinec?A
System.out.println(cc?
[
[

palteam_ps@yahoo.com

!" # $ %#

,@ # 9

$ " % & read


enter /

$"' readLine B'


+'

3 "# C
< string

'

+ ' $ 4"5

3)

+/

"4

=+

B /
$

,"
)

$ 4"T

=+

'
bufferedU

<< 8
class scanner ' $ 4"T "
$>

5 $ 4"R

'

$ 4"R
O

"4

3)

G ' ) O 4) 0

2 "4 + 2+ object

& /
+!'

+ 3)
"

import java.util.Scannerc
class IN
\
public void in?A
\
Scanner sc=new Scanner(System.inc?
System.out.println(enter Host or IPc?i
String Hots = sc.nextLinec?A
[
[

palteam_ps@yahoo.com

!" # $ %#

scanner K 4 class$

"4

$ 4"5

;& 3 )

G
public
,C

+ "+ public *: ) !+ class $

8 + '
*)

@ "

,"

,C

8 + '

)2" +

'

+/

+ *)

"'
,C

"+ => method ,C public

public class anyname


{
public void namemethod()
{
}
public static void main(String [] args)
{
anyname object=anyname();
object.namemothed();
}
}

8 + '
+"

method @ "

= +

=>

public class anyname


{
public int X;
public int Y;
public void namemethod()
{
//
> B
X,Y +
}
public static void main(String [] args)
{
anyname object=anyname();
object.namemothed();
palteam_ps@yahoo.com

!" # $ %#

}
}

? ("' A

" ( "

&5

8 + '
> ) ! !4 2 public

0'

$ F

private J

..!!2+ object @ +5 B

&5 )

$' 9

private class

protected 9 5
>
&

extends 0

' K 4 2+ public UU ' 2 '


"+

protected +

class
&5 3 )

protected $
>

9
)

I+
&

/
0

'

+ "+ =>
)B

F=

public class anyname


{
protected int X;
protected int Y;
}
public class anyname2 extends anyname
{
//
"4 B
+ X,Y
{

palteam_ps@yahoo.com

!" # $ %#

"#

JBULDER 7 3 #

- M) $'#
8

"

8 + ' &

' / 4 L +5 2

palteam_ps@yahoo.com

8
'C

' 0'

'

8 + '

<

'

'

!" # $ %#

palteam_ps@yahoo.com

!" # $ %#

-+!,

palteam_ps@yahoo.com

!" # $ %#

)
V
%

@ +5 %

8 + ' 9

?new project A " " V

@"' PZ 9 G , ! <

@ +5 "+

'

< +> , !
)

C4

3
4+ PZ + > , ! <

< 3
) 2 " " 5 "" + V

=4

73

3 '

"" + PZ > > , ! <


< 2+ C4 B3

2+

V
6 ; + 4") *& V

"" R +
+

PZ

'

, ! <

@ +5

3+

< 3
0'

@"' 8 + ' F= @ +E'


PZ

palteam_ps@yahoo.com

'

+ '

! ' 73

4 "'
2

!" # $ %#

( +E'

palteam_ps@yahoo.com

' 0'

8 + ' 9

+)"' "#

+ &

!" # $ %#

HELLOW

B'

8 + ' => 2 '


PZ

palteam_ps@yahoo.com

8 + '$

! ' 73

$>

WORD

!" # $ %#

palteam_ps@yahoo.com

!" # $ %#

PZ B'

palteam_ps@yahoo.com

+ 9

8 + '

' "'

!" # $ %#

JCreator 7 3 #

H 3

palteam_ps@yahoo.com

!" # $ %#

palteam_ps@yahoo.com

!" # $ %#

palteam_ps@yahoo.com

!" # $ %#

palteam_ps@yahoo.com

!" # $ %#

8 + ' 7D
ZV

8 + '

! 4 @ +5
G F

' @"'

C'

=+ $

"'
3

7
1

palteam_ps@yahoo.com

!" # $ %#

palteam_ps@yahoo.com

!" # $ %#

{V

@"' $'# 2 D

8 + '

+ ) "' }

8 + ' & D+ .
: B' + 8 + ' & D+ ,"
(#

[Build ]
3+

palteam_ps@yahoo.com

4+ [Execute project ]
!4' )
[f5]
!" # $ %#

TextPad 7 3 #

Next DEF G 14H I+, 0! #

palteam_ps@yahoo.com

/ I+840 #J J

!" # $ %#

Next DEF K L+" #M3

Next

3 @

palteam_ps@yahoo.com

*) ) $

I $ N+O40 #+) P

'

"4

+ ' $4)

!" # $ %#

$=4

" ) 52
Next

8 + ' - !+ "
9'

*&

- )

3 )change

8 + ' - !+ ' @"' Install C 9

palteam_ps@yahoo.com

!" # $ %#

Finish

PZ

palteam_ps@yahoo.com

3 2

' #-

8 + '

+ 5

!" # $ %#

j2sedk 7 3 #
' # j2se sdk Y +

' #

:
d$

= "

I +)

4 + *) $

'

"+

- !+ $ )

' + 'd$

)c$

" " = " ] +)

"'

3 $

"' " ' j2sdk 9


:

palteam_ps@yahoo.com

, !

8 + ' - !+ ' # % & " '


change

!" # $ %#

, !

command

"

, !

next 9

, !

install 9

):

palteam_ps@yahoo.com

>$
, !

' # %& " '

3 %& " '

3 %& " '

> )"' 9 5 - &) 8 + ' & D+ % & " '


F " 95 $ !

!" # $ %#

' + 'd$ )c$

2 "

$ " 95 $ + %& " ' >


:

? c: K

C4 ,"

' A dZ- )
cd java- )
cd bin- )

%& 8 + '

C4 ,

4 & D+ B

' d:\java\bin $ "

:
first. java 9
:

palteam_ps@yahoo.com

$ '
$ "

8 + '

, !

4 ;& '

# &5

D 0

C4 8 + '
d:\java\bin\first.java

!" # $ %#

Java
Z 3)

'

$ '

"

" "

$" '

&
+ " " I'

#7

(# L 4 8 + '

import javax.swing.*;
import java.util.ArrayList;
public class while6 {
public static void main (String args []) {
int i = 1;
int c90 = 0, c80 = 0, c70 = 0, c60 = 0, failed = 0;
ArrayList<Integer> listC90 = new ArrayList<Integer>();
ArrayList<Integer> listC80 = new ArrayList<Integer>();
ArrayList<Integer> listC70 = new ArrayList<Integer>();
ArrayList<Integer> listC60 = new ArrayList<Integer>();
ArrayList<Integer> listFailed = new ArrayList<Integer>);
while(i != 0 ) {
String s = JOptionPane.showInputDialog("Enter number");
int x = Integer.parseInt(s);
if (x == 0)
i = 0;
if ( x >= 90 && x <= 100) {
listC90.add(x);
c90++;
} else if ( x >= 80 && x < 90) {
listC80.add(x);
c80 ++;
} else if ( x >= 70 && x < 80) {
listC70.add(x);
c70 ++;
} else if ( x >= 60 && x < 70) {
listC60.add(x);
c60 ++;
} else if ( x < 60) {
listFailed.add(x);
failed ++;
}
}
System.out.println("A "+ c90 + " - " + listC90);
System.out.println("B "+c80 + " - " + listC80);
System.out.println("C "+c70 + " - " + listC60);
System.out.println("D "+c60 + " - " + listC80);
System.out.println("F "+failed + " - " + listFailed);
}
}

palteam_ps@yahoo.com

!" # $ %#

D3 # +/

&/ 0 2

import javax.swing.JOptionPane;
public class sum_count_avg
{
public static void main(String args[])
{
int num1=0,num2=0,sum=0,coun=0;
float avg=0;
String message1=JOptionPane.showInputDialog("enter your first num:");
num1=Integer.parseInt(message1);
String message2=JOptionPane.showInputDialog("enter your second num:");
num2=Integer.parseInt(message2);
for(int i=num1+1;i<num2;i++)
{
sum=sum+i;
coun+=1;
}
avg=sum/coun;
String msg=String.format("the sum is:%d",sum);
String msg2=String.format("the Count is:%d",coun);
String msg3=String.format("the Average is:%f",avg);
JOptionPane.showMessageDialog(null,msg);
JOptionPane.showMessageDialog(null,msg2);
JOptionPane.showMessageDialog(null,msg3);
System.exit(0);
}
}

palteam_ps@yahoo.com

!" # $ %#

'

7 ! "" $ 4"R

PZ $4"

""

' 8 + ' - P)
', !

" D

# G B

import javax.swing.*;
class PrintOdd{
public static void main(String[] args){
String s = JOptionPane.showInputDialog("enter a positive integer");
int n = Integer.parseInt(s);
for(int i=0; i<=n; i++)
if(i%2 == 1)
System.out.println(i);
}}

<""

!) B

! "" G

D!

'

- P-

public int min(int [] arr){


int m = arr[0];
for(int i =1; i< arr.length;i++)
if(m < arr[i])
m = arr[i];
return m;
}

?nameA
G
K4

)
#

Person /+! /

?idA
("'

# K4 $

P)

#""

; 3# /

setName

class Person{
private int id;
private String name;
public Person(int id1, String
name1){
id = id1;
name = name1;
}
public void setName(String n){
name = n;
}
}
palteam_ps@yahoo.com

!" # $ %#

W%45 I&8 Person S , T4$ UV % Employee S , 94


RQ
B#+ 0
\name[ ]' % \id[ #$ X )7 SY (Z
salary IP 7 %
#$ L )4 #+^ 0! +) $ 0 . / 94

IP 4 % ]* %
;+0P >0 % getSalary #M$4_ 94

salary 4+E0 " ?

class Employee extends Person{


private double salary;
public Employee(int id1, String n, double s){
super(id1,n);
salary = s;
}
public double getSalary(){
return salary;
}
}

@ "

"4

xy B

'

""

&

public int power(int x, int y){


if (y==0)
return 1;
if(y==1)
return x;
return x*power(x,y-1);
}

palteam_ps@yahoo.com

!" # $ %#

olleH)B'

Hello $ > A -

'2 '

K+ $ 4"R

'8 + '- )

import javax.swing.*;
class PrintInverse{
public static void main(String[] args){
String s = JOptionPane.showInputDialog("enter a sentence");
for(int i=s.length()-1; i>=0; i--)
System.out.print(s.charAt(i));
}}

palteam_ps@yahoo.com

!" # $ %#

!
<

F"

?
<

'+

A? A
'

<-

"

palteam_ps@yahoo.com

'

'

"+

<*

B#

< SUN JAVA

B#

#
$

'-

$ % !
&

!" # $ %#

You might also like