freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

[工學(xué)]jaa程序設(shè)計(jì)(編輯修改稿)

2025-02-15 11:03 本頁(yè)面
 

【文章內(nèi)容簡(jiǎn)介】 )。 =32。 ()。 ( )。 } } ? 保護(hù)變量和保護(hù)方法 ? 允許類(lèi)本身、子類(lèi)(相同包或不同包中)以及相同包中的其他類(lèi)訪問(wèn) package 。 class A2 { protected int x。 public A2(int a) { x=a。 } protected void protectedF( ) { (this is a protected function!+x=+x)。 } } public class B2 { public static void main (String args[ ]) { A2 a2=new A2(100)。 =38。 ( )。 } } package 。 public class A3 { protected int x。 public A3(int y) { x=y。 } protected void printX( ) { (x=+x)。 } } import .*。 public class B3 extends A3 { public B3(int y) { super(y)。 } void f ( A3 a, B3 b) { =70。 ( )。 =80。 ( )。 } public static void main (String args[ ]) { B3 bb=new B3(15)。 A3 aa=new A3(27)。 bb. f (aa, bb)。 } } E:\ A protected int x。 protected void f( )。 B protected int y。 protected void g( )。 Other =3。 ( )。 =2。 ( )。 x=3。 f( )。 =2。 ( )。 =3。 ( )。 ? 若類(lèi) A、 B同包 ? B類(lèi)的方法 可 直接訪問(wèn)或通過(guò) B對(duì)象名訪問(wèn) B類(lèi)從 A類(lèi) 繼承下來(lái) 的 protected成員變量和 B類(lèi) 新增 的protected成員變量 ?在主類(lèi) Other(與 A、 B同包)中通過(guò) B對(duì)象名 可 訪問(wèn) B類(lèi)從 A類(lèi) 繼承下來(lái) 的 protected成員變量和 B類(lèi) 新增 的 protected成員變量 ? B類(lèi)和 Other類(lèi)的方法 可以 通過(guò) A對(duì)象名訪問(wèn) A的protected成員變量 A protected int x。 protected void f( )。 B protected int y。 protected void g( )。 Other =3。 ( )。 =2。 ( )。 x=3。 f( )。 =2。 ( )。 =3。 ( )。 ? 若類(lèi) A、 B異包 ? B類(lèi)的方法 可 直接訪問(wèn)或通過(guò) B對(duì)象名訪問(wèn) B類(lèi)從 A類(lèi)繼承下來(lái)的 protected成員變量和 B類(lèi)新增的protected成員變量 ?在主類(lèi) Other(與 B同包)中通過(guò) B對(duì)象名 可 訪問(wèn) B類(lèi)新增的 protected成員變量,但 不可 訪問(wèn) B類(lèi)從 A類(lèi)繼承下來(lái)的 protected成員變量 ? B類(lèi)和 Other類(lèi)的方法 不可 通過(guò) A對(duì)象名訪問(wèn) A的protected成員變量 ? 友好變量和友好方法 ? 允許同類(lèi)或同一包中的類(lèi)訪問(wèn) package 。 class A2 { int x。 public A2(int a) { x=a。 } void f( ) { (this is a friend function!+x=+x)。 } } public class B2 { public static void main (String args[ ]) { A2 a2=new A2(100)。 =38。 ( )。 } } package 。 public class A3 { int x。 public A3(int y) { x=y。 } void printX( ) { (x=+x)。 } public void outputX( ) { (“x=”+x)。 } } import .*。 public class B3 extends A3 { public B3(int y) { super(y)。 } static void f ( A3 a, B3 b) { =70。 ( )。 =80。 ( )。 ( )。 ( )。 } public static void main (String args[ ]) { B3 bb=new B3(15)。 A3 aa=new A3(27)。 f (aa, bb)。 } } E:\ A:所有類(lèi) B:包中的類(lèi) C:所有 子類(lèi) D:本類(lèi) 類(lèi) 屬性與 方法 public protected private 默認(rèn) public 默認(rèn) A B D D B+C B B B 對(duì)象 ? 創(chuàng)建對(duì)象 ? 對(duì)象的聲明 類(lèi)名 對(duì)象名 。 ? 為聲明的對(duì)象分配內(nèi)存 對(duì)象名 =new 類(lèi)名 (實(shí)參表 ) 。 ? 若類(lèi)中無(wú)構(gòu)造函數(shù),系統(tǒng)調(diào)用 默認(rèn)構(gòu)造函數(shù) ? 若類(lèi)中已定義構(gòu)造函數(shù),系統(tǒng)不提供默認(rèn)構(gòu)造函數(shù) ? 若類(lèi)的成員變量在類(lèi)定義體中沒(méi)有指定初值,構(gòu)造函數(shù)也沒(méi)有進(jìn)行初始化操作,則基本數(shù)據(jù)類(lèi)型的成員變量由系統(tǒng)給定 默認(rèn)初值 Person p。 p p=new Person ( )。 0 null null null age name sex job p 0xfb3c ? 使用對(duì)象 對(duì)象名 .成員變量名 。 對(duì)象名 .成員方法名 ( 實(shí)參列表 )。 Point p1=new Point ( 17, 29 )。 17 29 p1 Point p2=new Point ( 6, 23 )。 0xFD9B 6 23 p2 p1=p2。 0xFD3A 0xFD9B p1 方法的參數(shù)傳遞 ? 參數(shù)傳值 ? 基本數(shù)據(jù)類(lèi)型參數(shù)的傳值 ? 向參數(shù)傳遞的值的級(jí)別不可以高于該參數(shù)的級(jí)別 ? 引用類(lèi)型參數(shù)的傳值 ? 傳遞的是變量中存放的引用,而不是變量所引用的實(shí)體 ? 可變參數(shù) ? 聲明方法時(shí)不給出參數(shù)列表中從某項(xiàng)直至最后一項(xiàng)參數(shù)的名字和個(gè)數(shù),但這些參數(shù)的類(lèi)型必須相同 public void f ( double a, int … x)。 示例 ? 參數(shù)代表可通過(guò)下標(biāo)運(yùn)算表示參數(shù)列表中的 具體參數(shù) x[0] x[1] …… ? 參數(shù)的個(gè)數(shù) class A5 { public double f ( double a, int ... x) { double result=0。 int sum=0。 for (int i=0。 i。 i++) { sum+=x[i]。 } result=a*sum。 return result。 } } public class B5 { public static void main ( String args[ ] ){ A5 a=new A5( )。 double r=(,12,23,6,79)。 (result is:+r)。 } } 轉(zhuǎn)向 class Point { int x。 int y。 public Point ( int xx,int yy ) { x=xx。 y=yy。 } } class A4 { void f ( int x, Point p ) { x=80。 =15。 =26。 (in function+x=+x)。 (in function +the position of point is:+( ++,++))。 } } 值傳遞 引用傳遞 public class B4 { public static void main(String args[]) { int x1=60。 Point p1=new Point(43,29)。 A4 a=new A4( )。 (before the function execution +x=+x1)。 (before the function execution + the position of point is:+(++,++))。 (x1,p1)。 (after the function execution +x=+x1)。 (after the function execution + the position of point is:+(++,++))。 } } 返回 this關(guān)鍵字 ? 可出現(xiàn)在實(shí)例方法和構(gòu)造方法中,但不能出 現(xiàn)在類(lèi)方法中 ? 由于句柄 通過(guò)編譯器 秘密傳遞,故要在方法 內(nèi)部獲得句柄必須使用 this關(guān)鍵字 ? 當(dāng)方法的形參與類(lèi)的成員變量同名時(shí),需用 this指明成員變量名 ? 可在構(gòu)造函數(shù)內(nèi)部通過(guò) this調(diào)用同類(lèi)的另一構(gòu) 造函數(shù) ? 不能在一個(gè)構(gòu)造函數(shù)中通過(guò) this調(diào)用 兩個(gè) 構(gòu)造函數(shù) ? 對(duì)另一構(gòu)造函數(shù)的調(diào)用必須置于 最起始處 public class Apple { double price。 void setPrice(double price) { =price。 } Apple inc( ) { price=price+1。 return this。 } void print( ) { (“price=”+price)。} void incAndPrint( ) { inc( )。 print( )。 } } Apple a=new Apple( )。 ()。 (a,)。 ( ).inc( ).print( )。 ( )。 ( )。 ( )。 示例 public class Apple{ double price。 String strain。 public Apple(double p){ price=p。 (Only initialize the price domain!)。 } public Apple(String s){ //構(gòu)造函數(shù)的重載 strain=s。 (Only initialize the strain domain!)。 } public Apple(double p,String strain){ this(p)。 //this(strain)。 =strain。 (Initialize two domains!
點(diǎn)擊復(fù)制文檔內(nèi)容
教學(xué)課件相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖片鄂ICP備17016276號(hào)-1