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

当前位置:首页 > java题库

java题库

  • 62 次阅读
  • 3 次下载
  • 2025/6/27 20:21:17

283 线程中, wait 的作用:释放已持有的锁,进入等待队列。

284 线程中, notify 的作用:唤醒wait 队列中的第一个线程并把它移入锁申请队列。 285 线程中, notifyAll 的作用:唤醒wait 队列中的所有的线程并把它们移入锁申请队列。

五、程序分析题:

1. 编译并运行下面的程序,分析程序运行的结果,如果程序有错,请说明错误的原因。

访问权限知识点 class A { private int x; private void print() { System.out.println(x) } }

class B { void test() { A a = new A(); a.x = 100; a.print(); }

public void static main(String args[]){ B b = new B(); b.test(); } }

2. 编译并运行下面的程序,分析程序运行的结果,如果程序有错,请说明错误的原因。

访问权限知识点 package abc; class A { protected int x; protected void print() { System.out.println(x); } }

package xyz; import abc.A;

class B extends A { void test(A a, B b) { a.x = 100; a.print(); b.x = 100; b.print(); }

public void static main(String args[]){

B b = new B(); b.test(); }

}

3. 分析下面程序错误的原因,并改错(静态成员知识点) class Test {

public void print(int x) { System.out.println(x); }

public static void main(String args[]) { int x = 3; print(x); } }

4. 编译并运行下面的程序,分析结果(隐藏、重载、覆盖知识点) class Base{

public void print(){

System.out.println(\ System.out.println(\ }

int x =2; }

public class Abs extends Base{ int x =6;

public void print(){

System.out.println(\ System.out.println(\ }

public static void main(String argv[]){ Abs a = new Abs(); a.print(); } }

5. 编译并运行下面程序,分析结果(抽象方法、抽象类、多态等知识点) abstract class Base{

abstract public void myfunc(); public void amethod(){

System.out.println(\ method\ } }

public class Abs extends Base{

public static void main(String argv[]){ Abs a = new Abs(); a.amethod(); }

public void myfunc(){

System.out.println(\ }

public void amethod(){ myfunc(); } }

6. 编译并运行下面程序,分析结果(继承,多态知识点) class Base{

int x =10;

public void amethod(){

System.out.println(\ method\ } }

public class Abs extends Base{ int x = 100;

public void amethod(){

System.out.println(\ method\ System.out.println(\ x); }

public static void main(String argv[]){ Base a = new Abs(); a.amethod(); } }

7. 编译并运行下面程序,分析结果(继承,多态知识点) class Base{

int x =10;

public void amethod(){

System.out.println(\ method\ } }

public class Abs extends Base{ public void amethod(){

System.out.println(\ method\ System.out.println(\ x); }

public void fun(){

System.out.println(\ }

public static void main(String argv[]){ Base a = new Abs(); a.amethod(); a.fun(); } }

8. 编译并运行下面程序,分析结果(无错,注意构造方法调用次序,先基类再派生类) class Base{ int x;

public Base(){ x =10;

System.out.println(\ } }

public class Abs extends Base{ int y;

public Abs (){ y = 100;

System.out.println(\ }

public static void main(String argv[]){ Abs a = new Abs(); System.out.println(\ +a. x ); System.out.println(\ + a.y ); } }

9. 编译并运行下面程序,分析结果(构造方法,基类无参构建方法没定义) class Base{ int x;

public Base(int i){ x =i;

System.out.println(\ } }

public class Abs extends Base{ int y;

public Abs (){ y = 1;

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

共分享92篇相关文档

文档简介:

283 线程中, wait 的作用:释放已持有的锁,进入等待队列。 284 线程中, notify 的作用:唤醒wait 队列中的第一个线程并把它移入锁申请队列。 285 线程中, notifyAll 的作用:唤醒wait 队列中的所有的线程并把它们移入锁申请队列。 五、程序分析题: 1. 编译并运行下面的程序,分析程序运行的结果,如果程序有错,请说明错误的原因。 访问权限知识点 class A { private int x; private void print() { System.out.println(x) } } class B { void test() { A a = new A(); a.x = 100; a.print(); } publi

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