面试的时候记得A(B,a)吧
来源:互联网 发布:百度关键词优化 编辑:程序博客网 时间:2024/06/03 12:36
public class Shape
{
public static void main(String[] args){
Triangle tri = new Triangle();
System.out.println("Triangle is a type of shape? " + tri.isShape());// 继承
Shape shape = new Triangle();
System.out.println("My shape has " + shape.getSides() + " sides."); // 多态
Rectangle Rec = new Rectangle();
Shape shape2 = Rec;
System.out.println("My shape has " + shape2.getSides(Rec) + " sides."); //重载
}
public boolean isShape(){
return true;
}
public int getSides(){
return 0 ;
}
public int getSides(Triangle tri){ //重载
return 3 ;
}
public int getSides(Rectangle rec){ //重载
return 4 ;
}
}
class Triangle extends Shape
{
public int getSides() { //重写,实现多态
return 3;
}
}
class Rectangle extends Shape
{
public int getSides(int i) { //重载
return i;
}
}
{
public static void main(String[] args){
Triangle tri = new Triangle();
System.out.println("Triangle is a type of shape? " + tri.isShape());// 继承
Shape shape = new Triangle();
System.out.println("My shape has " + shape.getSides() + " sides."); // 多态
Rectangle Rec = new Rectangle();
Shape shape2 = Rec;
System.out.println("My shape has " + shape2.getSides(Rec) + " sides."); //重载
}
public boolean isShape(){
return true;
}
public int getSides(){
return 0 ;
}
public int getSides(Triangle tri){ //重载
return 3 ;
}
public int getSides(Rectangle rec){ //重载
return 4 ;
}
}
class Triangle extends Shape
{
public int getSides() { //重写,实现多态
return 3;
}
}
class Rectangle extends Shape
{
public int getSides(int i) { //重载
return i;
}
}
阅读全文
0 0
- 面试的时候记得A(B,a)吧
- 面试问题a+=b 和a=a+b的区别
- 【Best Coder】#29 B GTY's birthday gift(快速幂|mod的时候记得负!)
- H5面试--弹出的a和b分别是什么
- a&&b与a&b的区别
- a.html 的时候,我想跳转到 b.html ,并且是 b.html 的某一个位置
- A b=a;同A b(a);一样调用的是b的拷贝构造函数的证明
- a>b?a:b
- 交换a、b的值temp = a; a = b; b = temp;比a = a^b;b = a^b;a = a^b;快
- 《程序员面试金典》链式A+B
- 链式A+B之程序员面试经典
- [程序员面试金典]-链式A+B
- A+B的问题
- XTU的A+B
- 人见人爱的a^b
- 大数的a+b
- A/B的困扰
- 不一样的A+B
- Connections could not be acquired from the underlying database! 特殊情况
- mysql 建议索引的原因以及优缺点
- Angular2父子组件之间数据传递:@Input和@Output (下)
- 将django rest 与 mongodb结合起来
- 标签和表单
- 面试的时候记得A(B,a)吧
- Angular2父子组件之间数据传递:局部变量获取子组件
- 微信小程序开发系列——5.前端页面开发
- Angular2父子组件之间数据传递:父子组件共享服务通信
- CentOS制作ISO系统镜像笔记
- 【简记】Java Web 内幕——Spring基本概念+基本配置操作
- windows 远程桌面连接 kali linux
- 用时间函数生成随机数
- Angular2父子组件之间数据传递:@ViewChild获取子组件