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

当前位置:首页 > Java习题三1剖析

Java习题三1剖析

  • 62 次阅读
  • 3 次下载
  • 2025/6/1 12:19:26

{

System.out.println(\

System.out.println(\}

}

public class Teacher extends Person {

int salary;

public void printValue() {

// doing the same as in the parent method printValue() // including print the value of name and department. System.out.println(\} }

下面的哪些表达式可以加入printValue()方法的\部分。 ① printValue();

② this.printValue(); ③ person.printValue(); ④ super.printValue(). 22.给出下面的不完整的方法:

1)

2) { success = connect(); 3) if (success==-1) {

4) throw new TimedOutException(); 5) } 6)}

TimedOutException 不是一个RuntimeException。下面的哪些声明可以被加入第一行完成此方法的声明。

① public void method()

② public void method() throws Exception

③ public void method() throws TimedOutException ④ public void method() throw TimedOutException ⑤ public throw TimedOutException void method()

23.定义一个类名为\的类,并且该类可被一个工程中的所有类访问,那么该类的正确声明应为:

① private class MyClass extends Object ② class MyClass extends Object ③ public class MyClass

④ public class MyClass extends Object 24.哪个关键字可以抛出异常?

① transient ② finally ③ throw

④ static

25.System类在哪个包中? ① java.util ② java.io ③ java.awt ④ java.lang

26.运行下列程序,会产生什么结果:

class Outer1 {

private int a;

void foo(double d,final float f)

{

String s;

final boolean b; class Inner

{

void methodInner()

{

System.out.println(\ } } }

public static void main(String args[]) {

Outer1 me=new Outer1(); me.foo(123,123);

System.out.println(\ } } outer

27.下列方法属于java.lang.Math类的有(方法名相同即可):

① random() ② abs() ③ sqrt() ④ sin()

28.下面程序的运行结果是什么?

public class Test extends TT {

public static void main(String args[])

{

Test t = new Test(\ }

public Test(String s)

{

super(s);

System.out.println(\}

public Test() {

this(\ } }

class TT {

public TT()

{

System.out.println(\ }

public TT(String s)

{

this();

System.out.println(\ }

}

What a pleasure! I am Tom

How do you do?

29.给定下面的未完成的代码片断:

public class Example {

int x,y;

public Example(int a)

{

… x = a; }

public Example(int a, int b)

{

//和上面一个参数的构造方法做同样的操作,包括赋值 x=a y = b; } }

如果要用最简捷的一行代码实现\和上面一个参数的…\请写出你认为最合适的一行代码:

30.final, finally, finalize的区别?

31.abstract class和interface有什么区别?

32.Static Nested Class 和 Inner Class的不同? 33.接口是否可继承接口? 抽象类是否可实现(implements)接口? 抽象类是否可继承实体类

(concrete class)?(抽象类是否可继承实体类,但前提是实体类必须有明确的构造函数) 34.数组有没有length()这个方法? String有没有length()这个方法? 35.Constructor是否可被override?

36.是否可以继承String类?不能public final class String

37.try {}里有一个return语句,那么紧跟在这个try后的finally {}里的code会不会被执行,什么时候被执行,在return前还是后? 38.abstract class Name

{

private String name;

public abstract boolean isStupidName(String name) {}//抽象方法只声明不实现,所以没有{}而加; }

是否有错,若有,说明错误原因 39.public class Something

{

void doSomething ()

{

private String s = \ int l = s.length(); } }

是否有错,若有,说明错误原因 40.abstract class Something

{

private abstract String doSomething (); }不能是private的,其他三种都可以 是否有错,若有,说明错误原因 41.public class Something

{ public int addOne(final int x) {

return ++x; } }

是否有错,若有,说明错误原因 42.public class Something

{

public static void main(String[] args)

{

Other o = new Other(); new Something().addOne(o); }

public void addOne(final Other o)

{

搜索更多关于: Java习题三1剖析 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

{ System.out.println(\System.out.println(\} } public class Teacher extends Person { int salary; public void printValue() { // doing the same as in the parent method printValue() // including print the value of name and department. System.out.println(\} } 下面的哪些表达式可以加入printValue()方法的\部分。 ① printValue(); ② this.printValue(); ③ person.

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价: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