云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > java面向对象试题

java面向对象试题

  • 62 次阅读
  • 3 次下载
  • 2025/12/2 22:04:48

方法的是:()。

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面向对象试题 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

方法的是:()。 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);

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com