A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 繁华落幕 中级黑马   /  2015-6-22 22:30  /  462 人查看  /  4 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

本帖最后由 繁华落幕 于 2015-6-24 22:25 编辑

给出以下代码,请问该程序的运行结果是什么?如有问题,请说明原因。
interface Inter {
public static final String s = "接口常量";
public abstract void method();
}
class SubEx implements Inter {
String s = "子类成员变量";
public void method(){
System.out.println("SubMethod");
}
}
class Demo {
public static void main (String[] args) {
Inter in = getInstance();
System.out.println(in.s);
function( in);
}
public static Inter getInstance(){
return new SubEx ();  
}
public static void function (Inter in) {
in.method();
}
}

4 个回复

倒序浏览
结果是 接口常量,SubMethod吗?
回复 使用道具 举报
结果是 接口常量,SubMethod   
回复 使用道具 举报
看看 看看
回复 使用道具 举报
划落间 来自手机 中级黑马 2015-6-23 12:49:37
报纸
用手机看的,全是字母,头疼,不看了。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马