mooc课程 java 期末考试试卷(3)
{
void test(int i){
System.out.println(“I am an int.”); }
void test(String s){
System.out.println(“I am a string.”);} public static void main(String args[]) {
Test t=new Test(); char ch=“y”; t.test(ch); } }
下列描述哪个正确?
? ? ? ?
A、程序将不会编译,因为空的方法不能被覆盖。
B、命令行t.test(ch);将不会编译,因为没有对应的方法。 C、代码将编译并输出以下结果: I am an String. D、代码将编译并输出以下结果: I am a int. 我的答案:D 错误
11
编译及运行以下代码,下列选项哪个是正确的 public class Sandys{ private int court;
public static void main(String argv[]){ Sandys s = new Sandys(99); System.out.println(s.court); } Sandys(int ballcount){
court=ballcount; } }
? ? ? ?
A、编译错误:the variable court is defined as private
B、编译错误:s is not initialized when the System.out method is called C、编译通过,没有输出 D、编译通过,输出99 我的答案:D
方法与变量使用已完成
1
关于static修饰符,以下哪个选项是正确的。
? ? ? ?
A、被static修饰符修饰的成员变量不能被修改。
B、在方法中创建的static变量,每次方法调用中对它的值做的修改都不能保留下来。 C、一个类的所有类对象共享这个类的static变量。 D、static修饰符只能用于修饰基本类型变量。 我的答案:C
2
方法内的变量:
? ? ? ?
A、一定在方法内所有位置可见 B、可能在方法内的局部可见 C、可以在方法外可见 D、方法外也可用 我的答案:B 错误
3
给出如下代码: class Test{ private int m;
public static void fun(){ // some code... } } 如何使成员变量m 被函数fun()直接访问?
? ? ? ?
A、将private int m 改为protected int m B、将private int m 改为 public int m C、将private int m 改为 static int m D、将private int m 改为 int m 我的答案:C
4
类JOptionPane提供了几个产生标准对话框的方法,它们能够给用户提供有用的信息,具体的有:
? ? ? ?
A、closeDialog() B、openDialog() C、inputDialog() D、outputDialog() 我的答案:D 错误
5
运行下列程序,会产生什么结果: class Outer1{ private int a;
void foo(double d,final float f){ String s; final boolean b; class Inner{
void methodInner(){
System.out.println(“in the Inner“); } } }
public static void main(String args[]) {
Outer1 me=new Outer1(); me.foo(123,123); System.out.println(“outer“); } }
? ? ? ?
A、in the Inner outer B、outer C、in the Inner D、编译不通过 我的答案:B
6
编译及运行以下代码,下列选项哪个是正确的 public class Ref{
public static void main(String argv[]){ Ref r = new Ref(); r.amethod(r); }
public void amethod(Ref r){ int i=99; multi(r);
System.out.println(i); }
public void multi(Ref r){ r.i = r.i*2;
} }
? ? ? ?
A、编译错误 B、输出99 C、输出198 D、运行时出错 我的答案:A
访问权限练习已完成
1
如果任何包中的子类都能访问超类中的成员,那么应使用哪个限定词
?
A、
public
? ? ?
B、private C、protected D、transient 我的答案:A
2
不允许作为类及类成员的访问控制符的是:
? ? ? ?
A、public B、private C、static
D、protected
我的答案:B 错误
3
下面哪个修饰符修饰的方法只能被本类中的其他方法使用
? ?
A、protected B、static
…… 此处隐藏:300字,全部文档内容请下载后查看。喜欢就下载吧 ……相关推荐:
- [实用模板]第八章:法国“新浪潮”与“左岸派”
- [实用模板]2021年北京上半年临床医学检验技师生物
- [实用模板]SAP GUI 7.10客户端安装配置文档
- [实用模板]2001年临床执业医师资格考试综合笔试试
- [实用模板]36机场工作实用英语词汇总结
- [实用模板](一)社会保险稽核通知书
- [实用模板]安全教育主题班会材料
- [实用模板]濉溪县春季呼吸道传染病防控应急演练方
- [实用模板]长沙房地产市场周报(1.30-2.3)
- [实用模板]六年级数学上册典中点 - 图文
- [实用模板]C程序设计(红皮书)习题官方参考答案
- [实用模板]中国证监会第一届创业板发行审核委员会
- [实用模板]桥梁工程复习题
- [实用模板]2011学而思数学及答案
- [实用模板]初中病句修改专项练习
- [实用模板]监理学习知识1 - 图文
- [实用模板]小机灵杯四年级试题
- [实用模板]国贸专业毕业论文模板
- [实用模板]教育学概论考试练习题-判断题4
- [实用模板]2015届高考英语一轮复习精品资料(译林
- 00Nkmhe_市场营销学工商管理_电子商务_
- 事业单位考试法律常识
- 诚信教育实施方案
- 吉大小天鹅食品安全检测箱方案(高中低
- 房地产销售培训资料
- 高一地理必修1复习提纲
- 新概念英语第二册lesson_1_练习题
- 证券公司内部培训资料
- 小学英语时间介词专项练习
- 新世纪英语专业综合教程(第二版)第1册U
- 【新课标】浙教版最新2018年八年级数学
- 工程建设管理纲要
- 外研版 必修一Module 4 A Social Surve
- Adobe认证考试 AE复习资料
- 基于H.264AVC与AVS标准的帧内预测技术
- 《食品检验机构资质认定管理办法》(质
- ABB变频器培训课件
- (完整版)小学说明文阅读练习题及答案
- 深思洛克(SenseLock) 深思IV,深思4,深
- 弟子规全文带拼音