?? 10720.htm
字號(hào):
<html>
<!-- #BeginTemplate "/Templates/empolder-doc.dwt" -->
<head>
<title>|><| 太平洋電腦網(wǎng) -> 網(wǎng)絡(luò)學(xué)院</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
-->
</style>
<link rel="stylesheet" href="/pcedu/style/text.css">
<script language="JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF" topmargin=0 leftmargin=0 marginheight="0" onLoad="MM_preloadImages('/images/lefton.gif','/images/topon.gif')">
<a name="top"></a>
<script language="JavaScript" src="/pcedu/script/top.js">
</script>
<table width=760 border=0 cellspacing=0 cellpadding=0 align=center>
<tr>
<td width=194 height="56"><a href=http://www.pconline.com.cn><img src=http://www.pconline.com.cn/images/pconlinelogo.gif width=162 height=35 vspace=10 border=0></a></td>
<td width=406 height="56">
<script language="JavaScript" src="/pcedu/script/empolder_ad.js">
</script>
</td>
<td width=158 align=right height="56">
<script language="JavaScript" src="/pcedu/script/empolder_ad1.js">
</script>
</td>
<td align=right width=2 height="56"> </td>
</tr>
</table>
<table border=0 cellpadding=0 cellspacing=0 width=760 align="center">
<tbody>
<tr valign=bottom>
<td rowspan=2 width=172><img height=32 src="/pcedu/images/pcedu_lo.gif"
width=172 border="0"></td>
<td height=30 rowspan=2>
<table cellpadding=0 cellspacing=0 width="588" bgcolor="#FFA000" background="/pcedu/images/e_menu5.gif" border="0">
<tbody>
<tr valign="bottom">
<td height="17">
<script language="JavaScript" src="/pcedu/script/title_empolder.js">
</script>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr></tr>
<tr bgcolor="#303880">
<td colspan=2 height=1 valign=bottom><img height=1
src="/pcedu/images/blank.gif" width=1></td>
</tr>
<tr>
<td colspan=2 height=5 valign=bottom><img height=5
src="/pcedu/images/blank.gif" width=1></td>
</tr>
</tbody>
</table>
<table width="760" cellspacing="0" cellpadding="0" align="center" height="614">
<tr>
<td width="170" height="616" valign="top" rowspan="2">
<table border="0" width="170" height="100%"
cellspacing="1" bgcolor="#000000">
<tr bgcolor="#F8F8D2">
<td width="100%" valign="top" height="307">
<script language="JavaScript" src="/pcedu/script/left_empolder.js">
</script>
</td>
</tr>
</table>
</td>
<td width="8" height="308"><img src="/pcedu/images/blank.gif" width="1" height="1"></td>
<td valign="top" height="444" width="582">
<table width="582" border="0" cellspacing="0" cellpadding="0" height="1" background="/images/line5.gif">
<tr>
<td height="1"></td>
</tr>
</table>
<!-- #BeginEditable "content" -->
<table width="582" border="0" cellspacing="8" cellpadding="0" background="/images/bg6.gif">
<tr>
<td valign="top">
<table width="100%" border="0" cellspacing="8" cellpadding="0" background="/images/point.gif">
<tr>
<td height="4" colspan="3"></td>
</tr>
<tr>
<td height="22" colspan="3">
<div align="center" class="title">JAVA程序員必讀:基礎(chǔ)篇(2)面向?qū)ο缶幊谈拍?lt;/div>
</td>
</tr>
<tr valign="bottom">
<td width="90" height="18">
<div align="right" class="gray"> </div>
<div class="gray"></div>
</td>
<td height="18">
<div align="center"><font color="#666666">編譯:ZSC/太平洋網(wǎng)絡(luò)學(xué)院</font></div>
</td>
<td width="90">
<div align="right" class="gray"><a href="mailto:tntst@pconline.com.cn">[責(zé)編:爆破手]</a></div>
</td>
</tr>
<tr valign="bottom">
<td colspan="3" height="0"></td>
</tr>
</table>
<p><b><span class="article">2.4實(shí)例和類成員</span></b></p>
<b><span class="article">2.4.5 對(duì)象和類</span></b>
<p class="article"> 你可能會(huì)注意到對(duì)象和類看起來很相似。在現(xiàn)實(shí)世界中,類和對(duì)象之間的區(qū)別經(jīng)常是讓程序員困惑的源泉。在現(xiàn)實(shí)世界中,很明顯,類不能是它們描述的對(duì)象本身。然而,在軟件中很困難來區(qū)分類和對(duì)象。有部分原因是軟件對(duì)象只是現(xiàn)實(shí)世界中的電子模型或者是抽象概念。但是也因?yàn)閷?duì)象通常有時(shí)是指類和實(shí)例。</p>
<p></p>
<p class="article"><b>2.5什么是繼承</b></p>
<p class="article"> 一個(gè)類可以從它的父類繼承狀態(tài)和行為。繼承為組織和構(gòu)造軟件程序提供了一個(gè)強(qiáng)大的和自然的機(jī)理。</p>
<p class="article"> 總得說來,對(duì)象是以類得形式來定義得。你可能現(xiàn)在已經(jīng)可以從它類知道許多對(duì)象了。即使你如知道,如果我告訴你它是一輛自行車,你就會(huì)知道它有兩個(gè)輪子和腳踏板等等。面向?qū)ο笙到y(tǒng)就更深入一些了,它允許類在其它類中定義。比如,山地自行車、賽車以及串座雙人自行車都是各種各樣的自行車。在面向?qū)ο蠹夹g(shù)中,山地自行車、賽車以及串座雙人自行車都是自行車類的子類。同樣地,自行車類是山地自行車、賽車以及串座雙人自行車的父類。這個(gè)父子關(guān)系可以如圖9所示:</p>
<p></p>
<p class="article"><img src="../images/10717/Image47.gif" width=365 height=281></p>
<p class="article">(圖9)</p>
<p class="article"> 每一個(gè)子例從父類中繼承了狀態(tài)。山地自行車、賽車以及串座雙人自行車共享了這些狀態(tài):速度等。同樣,每一個(gè)子類繼承類從父類的方法,山地自行車、賽車以及串座雙人自行車共享了這些行為:剎車、改變腳踏速度等等。</p>
<p class="article"></p>
<p align="center" class="article"><a href="10719_3.htm">[上一頁]</a>
<a href="10720_1.htm">[下一頁]</a></p>
</td>
</tr>
<tr bgcolor="#FF6600">
<td height="1"></td>
</tr>
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0" background="/images/point.gif">
<tr>
<td colspan="2">
<p align="center" class="basicfont"><br>
如果您有什么疑問或看法請(qǐng)到 <a href="http://home.pconline.com.cn/cgi-bin/newbbs/bbs_login.cgi?loginname=guest&loginpasswd=guest" target="_blank" class="blue">精彩論壇</a>
發(fā)表意見<br>
</p>
<p align="center" class="basicfont"><font color=#ff0000><b class="article">未經(jīng)同意
不得轉(zhuǎn)載</b></font></p>
<p align="center" class="basicfont"> <span class="basicfont"><a href="javascript:history.back(-1)" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('image3','','/images/lefton.gif',1)"><img src="/images/LEFTOFF.GIF" border="0" name="image3" alt="返回" width="19" height="22"></a>
<a href="#top" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('image2','','/images/topon.gif',1)"><img src="/images/TOPOFF.GIF" name="image2" border="0" alt="頁首" width="22" height="22"></a></span></p>
</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- #EndEditable -->
<table width="582" border="0" cellspacing="0" cellpadding="0" height="1" background="/images/line5.gif">
<tr>
<td height="1"></td>
</tr>
</table>
<img src="/images/blank.gif" width="1" height="24"><br>
<script
src=/script/hotfiles.js>
</script>
</td>
</tr>
</table>
<hr noshade size="2" width="760">
<p align="center">
<script language="JavaScript" src="/pcedu/script/title_edu.js">
</script>
<br>
<br>
版權(quán)所有©2000 太平洋電腦網(wǎng)<br>
<font face="Arial, Helvetica, sans-serif">
<script>
document.write("<a href=http://best.netease.com/cgi-bin/view/viewbasic.cgi?exp target=_blank><img src=http://best.netease.com/cgi-bin/log.cgi?user=exp&refer="+escape(document.referrer)+"&cur="+escape(document.URL)+" border=0 alt='網(wǎng)易中文排行榜' width=1 height=1></a>");
</script>
<a href=mailto:webmaster@pconline.com.cn>webmaster@pconline.com.cn </a>
<script language="">document.write("<a href=http://best.netease.com/cgi-bin/view/viewbasic.cgi?pconline1 target=_blank><img src=http://best.netease.com/cgi-bin/log.cgi?user=pconline1&refer="+escape(document.referrer)+"&cur="+escape(document.URL)+" border=0 width=1 height=1 ></a>");</script>
<script language="">
document.write("<a href=http://count.pconline.com.cn/admin/index.php target=_blank><img src=http://count.pconline.com.cn/count.php?user=pcedu&refer="+escape(document.referrer)+" border=0 width=0 height=0 alt='' ></a>");
</script>
</font></p>
</body>
<!-- #EndTemplate -->
</html>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -