作业3

本文详细介绍了Java中的构造方法及其作用,并通过实例解析了方法重载的概念及如何实现。此外,还提供了代码示例帮助理解方法调用过程中变量的作用域及方法覆盖等问题。

1、什么是重载?
重载:发生在同一个类中。两个方法的方法名相同,参数列表不同(参数类型、个数、顺序)
2、什么是构造方法?构造方法的作用是什么?
3、说说下面的方法哪些重载了构造方法?
public class Test{
public Test(int x){}
}
a、public Test(int y){}
b、public Test(String y){}
c、public void Test(String x){}
d、public int Test(int y,String x){}
e、public Test(int y,String x){}
f、public Test(String x,int y){}

4、说出代码执行结果。
public class Test{
public int x = 8;
public void move(int x){
System.out.println(x);
System.out.println(this.x);
}

public static void main(String[] args){
Test t = new Test();
t.move(6);
}
}

5、说出下列代码执行结果
a、public class Test{
public static void main(String[] args){
int j;
System.out.println(j);
}
}

b、public class Test{
static int j;
public static void main(String args){
System.out.println(j);
}
}

c、public class Test{
int j;
public int getNum(){
return this.j;
}
public static void main(String[] args){
System.out.println(getNum());
}
}
d、public class Test{
public String x;
public static void main(String[] args){
Test t = new Test();
String y = "";
System.out.println(t.x.equals(y));
}
}
6、什么继承?继承有什么优点?
7、继承使用什么关键字?
8、一个类可以同时继承多个类吗?所有类的父类是什么?
9、完成QQ登陆界面

转载于:https://www.cnblogs.com/ljjdeblogs/p/5897932.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值