java小题目
下面是一个源程序中定义的两个类A和B,程序应保存的文件名是 ,在程序横线处填写,将程序补充完整。Public class A B
{
public static void main(String[] x)
{
A a = new A();
a.myfunc2();
}
public void myfunc1()
{ System.out.println(“myfunc1”); }
public void myfunc2()
{
this.myfunc1();
.myfunc2(); //调用父类的方法
}
}
class B
{
abstract public void myfunc1();
public void myfunc2()
{ System.out.println(“myfunc2”); }
bird.java
----------------------------------------------------
class bird {
String s;
bird() {
this.s = "Parrot";
System.out.println("Constructed: " + s);
}
bird(String s) {
this.s = s;
System.out.println("Constructed: " + s);
}
}
OverloadConstruct.java
class OverloadConstruct {
public static void main(String[] args) {
bird b1 = new bird();
bird b2 = new bird("Dove");
bird b3 = new bird();
System.out.println(b1==b3);
System.out.println(b1.equals(b3));
System.out.println("Dove".equals(b2));
}
}
[ 本帖最后由 ykl_bear 于 2009-10-21 08:34 编辑 ]