第一范文网 - 专业文章范例文档资料分享平台

java面向对象试题

来源:用户分享 时间:2025/10/19 7:26:02 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

方法的是:()。

A.public Product(){}

B.public Product(String name){} C.public void Product(){}

D.public void Product(String name){}

28.下列代码的运行结果是( ) public class Test{ private int num;

private static Test test; public Test(int num){ this.num = ++ num; }

static{

int num = 16;

test = new Test(num); ++ test.num; }

public static void main(String[] args){ test = new Test(13);

System.out.println(test.num); } } A. 14 B. 15 C. 16 D. 17

29. (多选题)请看下列代码: public class Tetromino {

protected int move(int x) { return 0; } }

class T extends Tetromino { <插入代码> }

在<插入代码>处填入选项中的代码,使T类没有编译错误的是: A.public int move(int x) { return 0; }

。()

B.private int move(int x) { return 0; } C.private int move(long x) { return 0; } D.protected long move(int x) { return 0; }

30.仔细分析下列代码,请指出错误的行( )。 public class SomeThing{ private String str;

public int addOne(final int x){ return ++x; } }

A.public class SomeThing B.private String str;

C.public int addOne(final int x) D.return ++x;

31.(多选题)下列关于JVM的内存结构描述正确的是: A.类的各种信息在堆中保存

B.栈用于存放程序运行过程当中所有的局部变量 C.堆一般用于存储使用new关键字创建的对象 D.类是JVM的内存结构

32.下列代码的运行结果是( )

public static void main(String[] args){ String str = \ str += 42;

System.out.print(str); }

A. 42 B. 420 C. 462 D. 42042

33. (多选题)请看下列代码: public class Foo {

static void alpha() { /* more code here */}

。()

void beta() { /* more code here */} }

下列说法正确的是:()。

A.Foo.beta()是调用beta方法的正确方式 B.Foo.alpha()是调用alpha方法的正确方式 C.beta方法可以直接调用alpha方法 D.alpha方法可以直接调用beta方法

34.查看如下代码: public class Foo {

public void method(String str,int age){} }

下列选项中,和 Foo 类中 method 方法重载的方法是()。 A. public int method(String str,int age){} B. public void method(int year,String s){} C. public int method(int year,String s){} D. public int method(String str){}

35.下列代码的输出结果是:()。 public class StaticFoo { int num; static int x;

public static void main(String[] args) { StaticFoo foo1 = new StaticFoo (); foo1.num++; foo1.x++;

StaticFoo foo2 = new StaticFoo (); foo2.num++; foo2.x++;

StaticFoo foo3 = new StaticFoo (); foo3.num++; foo3.x++;

StaticFoo.x++;

System.out.print(foo3.num+\ System.out.println(foo3.x); } }

A.3,3 B.1,3 C.3,4 D.1,4

36. 下面关于interface,叙述错误的是:( ) A.一个interface可以继承多个interface B.接口中的方法可以由private修饰

C.interface中可以定义static final 常量 D.interface中可以无任何方法定义

37.下列代码的输出结果是: ( )。 public class A { public void info(){

System.out.println(\ } }

public class B extends A{ public void info(){

System.out.println(\ }

public static void main(String[] args) { A a=new B(); a.info(); } } A. B info

搜索更多关于: java面向对象试题 的文档
java面向对象试题.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c6sluq65prv9vfqx3d4pq7px008twst015aq_4.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top