文件名称:1
-
所属分类:
- 标签属性:
- 上传时间:2013-11-05
-
文件大小:3.44kb
-
已下载:0次
-
提 供 者:
-
相关连接:无下载说明:别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容来自于网络,使用问题请自行百度
运行下列程序,分析super关键字的使用,以及父类与子类之间的隐藏和重写关系
class superClass{
int x
superClass( ){
x = 3
System.out.println("in superClass : x = "+x)
}
void doSomething( ){
System.out.println("in superClass.doSomething( )")
}
class subClass extends superClass{
int x
subClass( ){
super( ) //call constructor of superClass
x = 5
System.out.println("in subClass : x = "+x)
}
void doSomething( ){
super.doSomething( ) //call method of superClass
System.out.println("in subClass.doSomething( )")
//call x of superClass
System.out.println("super.x = "+super.x+" sub.x = "+x)
}
}
public class inheritance{
public static void main( String args[ ] ){
subClass subC = new subClass( )
subC.doSomething( )
}
}
-Run the following procedure to use the super keyword analysis, as well as the parent class and subclass relationship between the hidden and rewriting class superClass {int x superClass () {x = 3 System.out.println (" in superClass: x = " +x) } void doSomething () {System.out.println (" in superClass.doSomething () " ) }} class subClass extends superClass {int x subClass () {super () // call constructor of superClass x = 5 System.out.println (" in subClass: x =" +x) } void doSomething () {super.doSomething () // call method of superClass System.out.println (" in subClass.doSomething () " ) // call x of superClass System.out.println (" super.x = " +super.x+" sub.x = " +x) }} public class inheritance {public static void main (String args [] ) {subClass subC = new subClass () subC.doSomething () }}
class superClass{
int x
superClass( ){
x = 3
System.out.println("in superClass : x = "+x)
}
void doSomething( ){
System.out.println("in superClass.doSomething( )")
}
class subClass extends superClass{
int x
subClass( ){
super( ) //call constructor of superClass
x = 5
System.out.println("in subClass : x = "+x)
}
void doSomething( ){
super.doSomething( ) //call method of superClass
System.out.println("in subClass.doSomething( )")
//call x of superClass
System.out.println("super.x = "+super.x+" sub.x = "+x)
}
}
public class inheritance{
public static void main( String args[ ] ){
subClass subC = new subClass( )
subC.doSomething( )
}
}
-Run the following procedure to use the super keyword analysis, as well as the parent class and subclass relationship between the hidden and rewriting class superClass {int x superClass () {x = 3 System.out.println (" in superClass: x = " +x) } void doSomething () {System.out.println (" in superClass.doSomething () " ) }} class subClass extends superClass {int x subClass () {super () // call constructor of superClass x = 5 System.out.println (" in subClass: x =" +x) } void doSomething () {super.doSomething () // call method of superClass System.out.println (" in subClass.doSomething () " ) // call x of superClass System.out.println (" super.x = " +super.x+" sub.x = " +x) }} public class inheritance {public static void main (String args [] ) {subClass subC = new subClass () subC.doSomething () }}
(系统自动生成,下载前可以参看下载内容)
下载文件列表
第一题/.classpath
第一题/.project
第一题/.settings/org.eclipse.jdt.core.prefs
第一题/bin/test/inheritance.class
第一题/bin/test/subClass.class
第一题/bin/test/superClass.class
第一题/src/test/inheritance.java
第一题/src/test/superClass.java
第一题/bin/test
第一题/src/test
第一题/.settings
第一题/bin
第一题/src
第一题
第一题/.project
第一题/.settings/org.eclipse.jdt.core.prefs
第一题/bin/test/inheritance.class
第一题/bin/test/subClass.class
第一题/bin/test/superClass.class
第一题/src/test/inheritance.java
第一题/src/test/superClass.java
第一题/bin/test
第一题/src/test
第一题/.settings
第一题/bin
第一题/src
第一题
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.