编程资料集中营
 | 网站首页 | 文章中心 | 编程资料2 | 软件下载 | BT下载 | 八卦星闻 | 音乐在线 | 在线游戏 | 免费电影 | 给我留言 | 
Question 1: Given the following class definition:-Java技术
          ★★★
【字体:
Question 1: Given the following class definition:-Java技术 进入问吧

本站地址:http://www.bajiao123.com

作者:admin    文章来源:网络    点击数:    更新时间:2006-12-27    
来源:WEB开发资源联盟(http://cnpoint.com/)
作者:phpcms
原文:Question 1: Given the following class definition:(http://cnpoint.com/framwwork/2006/1101/content_4536.htm)

Question 1: Given the following class definition:
class A {
   protected int i;
   A(int i) {
      this.i = i;
   }
}
Which of the following would be a valid inner class for this class?
Select all valid answers.
a)
class B {
}
b)
class B extends A {
}
c)
class B {
   B() { 
      System.out.println("i = " + i);
   }
}
d)
class B {
   class A {
   }
}
e)
class A {
}
answer
--------------------------------------------------------------------------------
Question 2: What statements are true concerning the method notify() that is used in conjunction with wait()?
Select all valid answers.
a) if there is more than one thread waiting on a condition, only the thread that has been waiting the longest is notified
b) if there is more than one thread waiting on a condition,there is no way to predict which thread will be notifed
c) notify() is defined in the Thread class
d) it is not strictly necessary to own the lock for the object you invoke notify() for
e) notify() should only be invoked from within a while loop
answer
--------------------------------------------------------------------------------
Question 3: Given the following class:
class Counter {
   public int startHere = 1;
   public int endHere = 100;
   public static void main(String[] args) {
      new Counter().go();
   }
   void go() {
      // A
      Thread t = new Thread(a);
      t.start();
   }
}
What block of code can you replace at line A above so that this program will count from startHere to endHere?
Select all valid answers.
a)
Runnable a = new Runnable() {
   public void run() {
      for (int i = startHere; i <= endHere; i++) {
         System.out.println(i);
      }
   }
};
b)
a implements Runnable {
   public void run() {
      for (int i = startHere; i <= endHere; i++) {
         System.out.println(i);
      }
  }
};
c)
Thread a = new Thread() {
   public void run() {
      for (int i = startHere; i <= endHere; i++) {
         System.out.println(i);
      }
   }
};
answer
--------------------------------------------------------------------------------
Question 4: What is written to the standard output given the following statement:
System.out.println(4 | 7);
Select the one right answer.
a) 4
b) 5
c) 6
d) 7
e) 0

[1] [2] [3] [4] [5] [6] [7] [8] [9] [10]  ... 下一页  >> 

   

进入问吧

Question 1: Given the following class definition:-Java技术

本站地址:http://www.bajiao123.com

文章录入:admin    责任编辑:admin 
高级搜索
编程资料集中营