Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
1Activity
0 of .
Results for:
No results containing your search query
P. 1
Core Java

Core Java

Ratings: (0)|Views: 80|Likes:
Published by api-3710223
Tai lieu tieng viet
Tai lieu tieng viet

More info:

Published by: api-3710223 on Oct 15, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

03/18/2014

pdf

text

original

\u00a1
\u00a2
\u00a3
\u00a4
\u00a5
\u00a6
\u00a7
\u00a8
\u00a9
\ue000
\ue001
\ue002
\ue003
\u00a4
\u00a1
\ue004
\u00a2
\ue005
\u00a4
\u00a5
\ue006
\ue007
\ue008
\ue001
\u00a2
\ue009
\u00a4
\u00a5
\u00a6

Tr\u00e2n tr\ue000ng c\ue001m \u01a1n c\u00e1c b\ue002n \ue003\u00e3 cung c\ue004p cho UDS cu\ue005n s\u00e1ch n\u00e0y.
Ch\u01b0\u01a1ng 1: L\ue006p tr\u00ecnh h\u01b0\ue007ng \ue003\ue005i t\u01b0\ue008ng.
Ch\u01b0\u01a1ng 2: Nh\ue006p m\u00f4n Java.
Ch\u01b0\u01a1ng 3: N\ue009n t\ue001ng c\ue00aa ng\u00f4n ng\ue00b Java.
Ch\u01b0\u01a1ng 4: C\u00e1c g\u00f3i v\u00e0 giao di\ue00cn.
Ch\u01b0\u01a1ng 5: AWT.
Ch\u01b0\u01a1ng 6: Applets.
Ch\u01b0\u01a1ng 7: X\ue00d l\u00fd ngo\ue002i l\ue00c.
Ch\u01b0\u01a1ng 8: \ue00ea lu\ue00fng.
Ch\u01b0\u01a1ng 9: Lu\ue00fng I/O.
Ch\u01b0\u01a1ng 10: Th\ue010c thi b\ue001o m\ue006t.

www.updatesofts.com
\u00a1
\ue002
\u00a2
\u00a3
\u00a4
\u00a5
\u00a4
Ch\u01b0\u01a1ng 1
L\ue000P TR\u00ccNH H\u01af\ue001NG \ue002\ue003I T\u01af\ue004NG
M\ue001c ti\u00eau
K\ue011t th\u00fac ch\u01b0\u01a1ng, h\ue000c vi\u00ean c\u00f3 th\ue012:

\ue000\ue00e\ue013nh ngh\u0129a L\ue006p tr\u00ecnh h\u01b0\ue007ng \ue00e\ue005i t\u01b0\ue008ng (Object-oriented Programming).
\ue000Nh\ue006n th\ue014c v\ue009 Tr\ue015u t\u01b0\ue008ng h\u00f3a D\ue00b li\ue00cu (Data Abstraction).
\ue000\ue00e\ue013nh ngh\u0129a m\ue016t L\ue007p (Class).
\ue000\ue00e\ue013nh ngh\u0129a m\ue016t \ue00e\ue005i t\u01b0\ue008ng (Object).
\ue000Nh\ue006n th\ue014c \ue003\u01b0\ue008c s\ue010 kh\u00e1c bi\ue00ct gi\ue00ba L\ue007p v\u00e0 \ue00e\ue005i t\u01b0\ue008ng.
\ue000Nh\ue006n th\ue014c \ue003\u01b0\ue008c s\ue010 c\ue017n thi\ue011t \ue003\ue005i v\ue007i Thi\ue011t l\ue006p (Construction) v\u00e0 H\ue00ay (Destruction).
\ue000\ue00e\ue013nh ngh\u0129a t\u00ednh B\ue009n v\ue00bng (Persistence).
\ue000Hi\ue012u bi\ue011t v\ue009 t\u00ednh Th\ue015a k\ue011 (Inheritance).
\ue000\ue00e\ue013nh ngh\u0129a t\u00ednh \ue00ea h\u00ecnh (Polymorphism).
\ue000Li\ue00ct k\u00ea nh\ue00bng thu\ue006n l\ue008i c\ue00aa ph\u01b0\u01a1ng ph\u00e1p h\u01b0\ue007ng \ue00e\ue005i t\u01b0\ue008ng.

1.1 Gi\ue002i thi\ue003u v\ue004 L\ue005p tr\u00ecnh h\u01b0\ue002ng \ue000\ue006i t\u01b0\ue007ng (Object-oriented Programming)

L\ue006p tr\u00ecnh h\u01b0\ue007ng \ue00e\ue005i t\u01b0\ue008ng (OOP) l\u00e0 m\ue016t ph\u01b0\u01a1ng ph\u00e1p thi\ue011t k\ue011 v\u00e0 ph\u00e1t tri\ue012n ph\ue017n m\ue009m. Nh\ue00bng ng\u00f4n ng\ue00b OOP kh\u00f4ng ch\ue018 bao g\ue00fm c\u00fa ph\u00e1p v\u00e0 m\ue016t tr\u00ecnh bi\u00ean d\ue013ch (compiler) m\u00e0 c\u00f2n c\u00f3 m\ue016t m\u00f4i tr\u01b0\ue019ng ph\u00e1t tri\ue012n to\u00e0n di\ue00cn. M\u00f4i tr\u01b0\ue019ng n\u00e0y bao g\ue00fm m\ue016t th\u01b0 vi\ue00cn \ue003\u01b0\ue008c thi\ue011t k\ue011 t\ue005t, thu\ue006n l\ue008i cho vi\ue00cc s\ue00d d\ue01ang c\u00e1c \ue003\ue005i t\u01b0\ue008ng.

\ue00e\ue005i v\ue007i m\ue016t ng\u00f4n ng\ue00b l\ue006p tr\u00ecnh h\ue01b tr\ue008 OOP th\u00ec vi\ue00cc tri\ue012n khai k\ue01c thu\ue006t l\ue006p tr\u00ecnh h\u01b0\ue007ng \ue003\ue005i t\u01b0\ue008ng s\ue01d d\ue01e d\u00e0ng h\u01a1n. K\ue01c thu\ue006t l\ue006p tr\u00ecnh h\u01b0\ue007ng \ue003\ue005i t\u01b0\ue008ng c\ue001i ti\ue011n vi\ue00cc ph\u00e1t tri\ue012n c\u00e1c h\ue00c th\ue005ng ph\ue017n m\ue009m. K\ue01c thu\ue006t \ue004y \ue003\ue009 cao nh\u00e2n t\ue005 ch\ue014c n\u0103ng (fucntionality) v\u00e0 c\u00e1c m\ue005i quan h\ue00c d\ue00b li\ue00cu.

OOP l\u00e0 ph\u01b0\u01a1ng th\ue014c t\u01b0 duy m\ue007i \ue003\ue012 gi\ue001i quy\ue011t v\ue004n \ue003\ue009 b\ue01fng m\u00e1y t\u00ednh. \ue00e\ue012 \ue003\ue002t k\ue011t qu\ue001, l\ue006p tr\u00ecnh vi\u00ean ph\ue001i n\ue020n v\ue004n \ue003\ue009 th\u00e0nh m\ue016t th\ue010c th\ue012 quen thu\ue016c v\ue007i m\u00e1y t\u00ednh. C\u00e1ch ti\ue011p c\ue006n h\u01b0\ue007ng \ue003\ue005i t\u01b0\ue008ng cung c\ue004p m\ue016t gi\ue001i ph\u00e1p to\u00e0n v\ue021n \ue003\ue012 gi\ue001i quy\ue011t v\ue004n \ue003\ue009.

H\u00e3y xem x\u00e9t m\ue016t t\u00ecnh hu\ue005ng c\ue017n \ue003\u01b0\ue008c tri\ue012n khai th\u00e0nh m\ue016t h\ue00c th\ue005ng tr\u00ean m\u00e1y vi t\u00ednh:
vi\ue00cc mua b\u00e1n xe h\u01a1i. V\ue004n \ue003\ue009 vi t\u00ednh h\u00f3a vi\ue00cc mua b\u00e1n xe h\u01a1i bao g\ue00fm nh\ue00bng g\u00ec?
Nh\ue00bng y\ue011u t\ue005 r\u00f5 r\u00e0ng nh\ue004t li\u00ean quan \ue003\ue011n vi\ue00cc mua b\u00e1n xe h\u01a1i l\u00e0:
1) C\u00e1c ki\ue012u xe h\u01a1i (model).
\u00a1
\u00a2
\u00a3
\u00a4
\u00a5
\u00a6
\u00a7
\u00a8
\u00a9
\ue000
\ue001
\ue002
\ue003
\u00a4
\u00a1
\ue004
\u00a2
\ue005
\u00a4
\u00a5
\ue006
\ue007
\ue008
\ue001
\u00a2
\ue009
\u00a4
\u00a5
2) Nh\u00e2n vi\u00ean b\u00e1n h\u00e0ng.
3) Kh\u00e1ch h\u00e0ng.

Nh\ue00bng ho\ue002t \ue003\ue016ng li\u00ean quan \ue003\ue011n vi\ue00cc mua b\u00e1n:
1) Nh\u00e2n vi\u00ean b\u00e1n h\u00e0ng \ue003\u01b0a kh\u00e1ch h\u00e0ng tham quan ph\u00f2ng tr\u01b0ng b\u00e0y.
2) Kh\u00e1ch h\u00e0ng ch\ue000n l\ue010a m\ue016t xe h\u01a1i.
3) Kh\u00e1ch h\u00e0ng \ue003\ue022t h\u00f3a \ue003\u01a1n.
4) Kh\u00e1ch h\u00e0ng tr\ue001 ti\ue009n.
5) Chi\ue011c xe \ue003\u01b0\ue008c trao cho kh\u00e1ch h\u00e0ng.

M\ue01bi v\ue004n \ue003\ue009 \ue003\u01b0\ue008c chia ra th\u00e0nh nhi\ue009u y\ue011u t\ue005, \ue003\u01b0\ue008c g\ue000i l\u00e0 c\u00e1c \ue00e\ue005i t\u01b0\ue008ng (Objects) ho\ue022c c\u00e1c Th\ue010c th\ue012 (Entities). Ch\ue023ng h\ue002n nh\u01b0 \ue024 v\u00ed d\ue01a tr\u00ean, kh\u00e1ch h\u00e0ng, xe h\u01a1i v\u00e0 nh\u00e2n vi\u00ean b\u00e1n h\u00e0ng l\u00e0 nh\ue00bng \ue003\ue005i t\u01b0\ue008ng ho\ue022c th\ue010c th\ue012.

L\ue006p tr\u00ecnh vi\u00ean lu\u00f4n lu\u00f4n c\ue005 g\ue020ng t\ue002o ra nh\ue00bng k\ue013ch b\ue001n (scenarios) th\ue006t quen thu\ue016c v\ue007i nh\ue00bng t\u00ecnh hu\ue005ng \ue003\ue019i s\ue005ng th\ue010c. B\u01b0\ue007c th\ue014 nh\ue004t trong \ue003\u01b0\ue019ng h\u01b0\ue007ng n\u00e0y l\u00e0 l\u00e0m cho m\u00e1y t\u00ednh li\u00ean k\ue011t v\ue007i nh\ue00bng \ue003\ue005i t\u01b0\ue008ng th\ue011 gi\ue007i th\ue010c.

Tuy nhi\u00ean, m\u00e1y t\u00ednh ch\ue018 l\u00e0 m\ue016t c\ue01b m\u00e1y. N\u00f3 ch\ue018 th\ue010c hi\ue00cn nh\ue00bng c\u00f4ng vi\ue00cc \ue003\u01b0\ue008c l\ue006p tr\u00ecnh m\u00e0 th\u00f4i. V\u00ec th\ue011, tr\u00e1ch nhi\ue00cm c\ue00aa l\ue006p tr\u00ecnh vi\u00ean l\u00e0 cung c\ue004p cho m\u00e1y t\u00ednh nh\ue00bng th\u00f4ng tin theo c\u00e1ch th\ue014c m\u00e0 n\u00f3 c\u0169ng nh\ue006n th\ue014c \ue003\u01b0\ue008c c\u00f9ng nh\ue00bng th\ue010c th\ue012 nh\u01b0 ch\u00fang ta nh\ue006n th\ue014c.

\ue00e\u00f3 ch\u00ednh l\u00e0 l\u00e3nh v\ue010c c\ue00aa k\ue01c thu\ue006t h\u01b0\ue007ng \ue003\ue005i t\u01b0\ue008ng. Ch\u00fang ta s\ue00d d\ue01ang k\ue01c thu\ue006t h\u01b0\ue007ng \ue003\ue005i t\u01b0\ue008ng \ue003\ue012 \u00e1nh x\ue002 nh\ue00bng th\ue010c th\ue012 ch\u00fang ta g\ue022p ph\ue001i trong \ue003\ue019i s\ue005ng th\ue010c th\u00e0nh nh\ue00bng th\ue010c th\ue012 t\u01b0\u01a1ng t\ue010 trong m\u00e1y t\u00ednh.

Ph\u00e1t tri\ue012n ph\ue017n m\ue009m theo k\ue01c thu\ue006t l\ue006p tr\u00ecnh h\u01b0\ue007ng \ue003\ue005i t\u01b0\ue008ng c\u00f3 kh\ue001 n\u0103ng gi\ue001m thi\ue012u s\ue010
l\ue025n l\ue016n th\u01b0\ue019ng x\ue001y ra gi\ue00ba h\ue00c th\ue005ng v\u00e0 l\u00e3nh v\ue010c \ue014ng d\ue01ang.

L\ue006p tr\u00ecnh h\u01b0\ue007ng \ue003\ue005i t\u01b0\ue008ng \ue003\ue009 c\ue006p \ue003\ue011n d\ue00b li\ue00cu v\u00e0 th\ue00a t\ue01ac x\ue00d l\u00fd d\ue00b li\ue00cu theo quan \ue003i\ue012m l\u00e0 m\ue016t \ue003\ue005i t\u01b0\ue008ng duy nh\ue004t. L\ue006p tr\u00ecnh h\u01b0\ue007ng \ue003\ue005i t\u01b0\ue008ng xem x\u00e9t d\ue00b li\ue00cu nh\u01b0 l\u00e0 m\ue016t th\ue010c th\ue012 hay l\u00e0 m\ue016t \ue003\u01a1n v\ue013 \ue003\ue016c l\ue006p, v\ue007i b\ue001n ch\ue004t ri\u00eang v\u00e0 nh\ue00bng \ue003\ue022c t\u00ednh c\ue00aa th\ue010c th\ue012 \ue004y. B\u00e2y gi\ue019 ch\u00fang ta h\u00e3y kh\ue001o s\u00e1t nh\ue00bng h\ue002n t\ue015 \u2018\ue003\ue005i t\u01b0\ue008ng\u2019 (object), \u2018d\ue00b li\ue00cu\u2019 (data) v\u00e0 \u2018ph\u01b0\u01a1ng th\ue014c\u2019 (method).

C\u00f3 nhi\ue009u lo\ue002i \ue003\ue005i t\u01b0\ue008ng kh\u00e1c nhau. Ch\u00fang ta c\u00f3 th\ue012 xem c\u00e1c b\ue016 ph\ue006n kh\u00e1c nhau trong m\ue016t c\u01a1 quan l\u00e0 c\u00e1c \ue003\ue005i t\u01b0\ue008ng. \ue00ei\ue012n h\u00ecnh l\u00e0 m\ue016t c\u01a1 quan c\u00f3 nh\ue00bng b\ue016 ph\ue006n li\u00ean quan \ue003\ue011n vi\ue00cc qu\ue001n tr\ue013, \ue003\ue011n vi\ue00cc kinh doanh, \ue003\ue011n vi\ue00cc k\ue011 to\u00e1n, \ue003\ue011n vi\ue00cc ti\ue011p th\ue013 \u2026 M\ue01bi b\ue016 ph\ue006n c\u00f3 nh\u00e2n s\ue010 ri\u00eang, c\u00e1c nh\u00e2n s\ue010 \ue003\u01b0\ue008c trao cho nh\ue00bng tr\u00e1ch nhi\ue00cm r\u00f5 r\u00e0ng. M\ue01bi b\ue016 ph\ue006n c\u0169ng c\u00f3 nh\ue00bng d\ue00b li\ue00cu ri\u00eang ch\ue023ng h\ue002n nh\u01b0 th\u00f4ng tin c\u00e1 nh\u00e2n, b\ue001ng ki\ue012m k\u00ea, nh\ue00bng th\ue012 th\ue014c kinh doanh, ho\ue022c b\ue004t k\u1ef3 d\ue00b li\ue00cu n\u00e0o li\u00ean quan \ue003\ue011n ch\ue014c n\u0103ng c\ue00aa b\ue016 ph\ue006n \ue003\u00f3. R\u00f5 r\u00e0ng l\u00e0 m\ue016t c\u01a1 quan \ue003\u01b0\ue008c chia th\u00e0nh nhi\ue009u b\ue016 ph\ue006n th\u00ec vi\ue00cc qu\ue001n tr\ue013 nh\u00e2n s\ue010 v\u00e0 nh\ue00bng ho\ue002t \ue003\ue016ng doanh nghi\ue00cp d\ue01e d\u00e0ng h\u01a1n. Nh\u00e2n s\ue010 c\ue00aa c\u01a1 quan \ue003i\ue009u khi\ue012n v\u00e0 x\ue00d l\u00fd d\ue00b li\ue00cu li\u00ean quan \ue003\ue011n b\ue016 ph\ue006n c\ue00aa m\u00ecnh.

Ch\ue023ng h\ue002n nh\u01b0 b\ue016 ph\ue006n k\ue011 to\u00e1n ch\ue013u tr\u00e1ch nhi\ue00cm v\ue009 l\u01b0\u01a1ng b\ue026ng \ue003\ue005i v\ue007i c\u01a1 quan. N\ue011u m\ue016t ng\u01b0\ue019i \ue024 \ue003\u01a1n v\ue013 ti\ue011p th\ue013 c\ue017n nh\ue00bng chi ti\ue011t li\u00ean quan \ue003\ue011n l\u01b0\u01a1ng b\ue026ng c\ue00aa \ue003\u01a1n v\ue013 m\u00ecnh, ng\u01b0\ue019i \ue004y ch\ue018 c\ue017n li\u00ean h\ue00c v\ue007i b\ue016 ph\ue006n k\ue011 to\u00e1n. M\ue016t ng\u01b0\ue019i c\u00f3 th\ue027m quy\ue009n trong b\ue016 ph\ue006n k\ue011 to\u00e1n s\ue01d

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->