锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产精品一区二区三区99,婷婷国产v国产偷v亚洲高清,亚洲激情网站http://www.aygfsteel.com/devliu1986/zh-cnThu, 17 Jul 2025 04:11:57 GMTThu, 17 Jul 2025 04:11:57 GMT60- when upcasting .....http://www.aygfsteel.com/devliu1986/archive/2008/05/25/202762.htmldevliudevliuSun, 25 May 2008 11:40:00 GMThttp://www.aygfsteel.com/devliu1986/archive/2008/05/25/202762.htmlhttp://www.aygfsteel.com/devliu1986/comments/202762.htmlhttp://www.aygfsteel.com/devliu1986/archive/2008/05/25/202762.html#Feedback0http://www.aygfsteel.com/devliu1986/comments/commentRss/202762.htmlhttp://www.aygfsteel.com/devliu1986/services/trackbacks/202762.html 1
// codes start
2
class base
{//a base class
3
4
// constructor
5
public base()
{
6
System.out.println("base class construct");
7
}
8
// perform
9
public void perform()
{
10
System.out.println("base class perform");
11
}
12
// destructor
13
public void finalize()
{
14
System.out.println("base class destruct");
15
}
16
}
17
18
19
class subbase extends base
{// derive from base
20
21
// constructor
22
public subbase()
{
23
System.out.println("sub class construct");
24
}
25
// perform
26
public void perform()
{
27
System.out.println("sub class perform");
28
}
29
// destructor
30
public void finalize()
{
31
System.out.println("sub class destruct");
32
}
33
}
34
35
public class casting
{// test casting class
36
// constructor
37
public casting()
{
38
System.out.println("begin casting test");
39
}
40
41
public static void main(String args[])
{
42
base father = new base();
43
subbase son = new subbase();
44
45
father.perform();
46
son.perform();
47
48
father = (base)son; // <1>
49
father.perform();
50
51
son = (subbase)father; // <2>
52
son.perform();
53
54
father = (base)((subbase)father); // <3>
55
father.perform();
56
}
57
}
58
59
// codes end
60
Today ,when i go for a interview ,the project manager asked me this question !
Acturally ,It's just relate to the knowledge of reference && object !
Be carefull ,Nothing !

]]>
主站蜘蛛池模板:
瑞金市|
黔江区|
体育|
台湾省|
山丹县|
巨野县|
伽师县|
呼伦贝尔市|
日土县|
周宁县|
合江县|
刚察县|
仲巴县|
旺苍县|
彝良县|
郑州市|
安溪县|
正镶白旗|
郓城县|
藁城市|
礼泉县|
英德市|
黄浦区|
石家庄市|
若羌县|
上犹县|
墨江|
濮阳县|
图片|
公主岭市|
定安县|
尚义县|
杭州市|
蒙阴县|
陆良县|
陕西省|
陈巴尔虎旗|
余庆县|
图木舒克市|
德惠市|
安徽省|