教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 实用模板 >

mooc课程 java 期末考试试卷(3)

来源:网络收集 时间:2025-09-13
导读: { 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(); ch

{

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字,全部文档内容请下载后查看。喜欢就下载吧 ……
mooc课程 java 期末考试试卷(3).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/452847.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)