Sybase的一套比试题(1小时完成)。这个是JAVA版的,大家一起来做做,中文是我为了看清楚自己翻译的,翻译得很烂
请大家多讲讲原理共同提高 而不是简单给出答案 谢谢!题目1: One team tries to buy several bottle of drinks for 27 athletes. In ABC store three empty bottles can be exchanged with one new bottle of drinks. Which of the following numbers is the minimal one that the team should buy for the 27 athletes?(一个队伍想要买几瓶饮料给27名运动员喝。在某商店规定3个空瓶可以换1瓶饮料,那么给27名运动员如果每人喝一瓶的话,最少要买几瓶)
A 17
B 18
C 19
D 20
题目2: How can you create a listener class that receives events when the mouse is moved(single Answer)(单选:如何创建一个听者类,能做到当老鼠开始移动时,接收事件) 
A By extending MouseListener(通过继承为老鼠听者)[不知道extending是不是翻译成继承 ?]
B By implementing MouseListener(通过实现老鼠听者接口)
C By extending Mouse Motion Listener(通过继承老鼠移动听者)
D By implementing Mouse Motion Listener(通过实现老鼠移动听者接口)
E Either by extending Mouse Motion Listener  or extending MouseListener(通过继承为老鼠听者或继承为老鼠移动听者)
F Either by implementing Mouse Motion Listener  or  implementing MouseListener(通过实现老鼠移动听者接口或实现老鼠听者接口)
题目3: You are assign the task of building a panel containing a TextArea at the top, a label directly below it, and a button directly below the label. If the three components are added directly to the panel, which layout manager can be panel use to ensure that the TextArea absorbs all of the free vertical space when the parel is resized? (你被要求实现如下任务:1创建一个面板;2在面板顶部包含一个TextArea,TextArea底下是一个label,label底下是一个button。如果这三个组件直接加到面板,which layout manager can be panel use to ensure that the TextArea absorbs all of the free vertical space when the parel is resized?)[这句话实在不知道咋翻译]
题目4: Which are not containers in Java?(Multiple answer)(多选:下面哪几个不是java所包含的)
A ScollPane
B Canvas
C Scrollbar
D Applet
E Dialog题目5:You need to store elements in a collection that  
guarantees that no duplicates are stored and all elements  
can be access in nature order, which interface provides  
that capability?(你需要存储元素到某种数据结构中,而且要确保元素中在自然队列中没有重复,下面哪个接口能保证这种能力)
A java.uil.Map
B java.util.Collection
C java.util.List
D java.util.SortedSet
E java.util.SortedMap
F java.util.Set
题目6:What will happen when you attempt to compile and run this (当你尝试编译以及运行这段代码时) 
code?abstract class Base{
   abstract public void myfunc();
public class Abs extends Base{
public static void main(String argv[])
{
   Abs a = new Abs();
   a.amethod();
}
public void amethod(){
   System.out.println("A method");;
}
}A The code will compile and run, printing out the words "A  
method"(这段程序能够编译且运行,打印"A method")
B The compiler will complain errors in Base class.(这段程序在Base class编译报错)C The code will compile but complain at run time that the  
Base class has none abstract methods.(这段程序编译通过,运行时会报错说没有抽象方法)
D The compiler will complain errors in Abs class.(这段程序在Abs class编译报错)题目7: Description(下列程序输出结果是什么?阐述原理)
import java.util.*; 
public class Test
{
  private String value = null;
  public Test(String v)
  {
  value = v;
  }
  public boolean equals(Test o)
  {
  if(o==this) return true;
  if(o instanceof Test)
  {
  Test test =(Test) o;
  return value.equals(test.value);
  }
  return false;
  }
  public static void main(String[] args)
  {
  List list = new ArrayList();
  Test test1 = new Test("object");
  Test test2 = new Test("object");
  Test test3 = new Test("object");
  Object test4 = new Test("object");
  list.add(test1);

  System.out.println(list.contains(test2));
  System.out.println(test2.equals(test3));
  System.out.println(test3.equals(test4));  }
}题目8:
Which of the following is NOT true regarding to RuntimeException?(下面关于运行时异常说法错误的是)
A RuntimeException is the superclass of those exceptions that can be thrown during the normal operation of the Java Virtul Machine.(运行时异常是那些异常的一个超类,Java虚拟机)
B A method is not required to declare in its throws clause any subclasses of RuntimeException that might be thrown during the execution of the method but not caught.(一个方法不要求声明抛出他的运行时异常的子句和子类,可以只是执行语句而不去捕捉这些异常)
C An RuntimeException is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch.(一个运行异常是Throwable的一个子类,能指出严重问题,因此一个合理的应用是不应该去捕捉它)
D NullPointerException is one kind of RuntimeException.(NullPointerException是一种运行时异常)题目9: Which of the following items demonstrates the key characteristics of Web 2.0(Web2.0的关键字特征是什么)?
A Centralized
B User centered design
C Open
D Light Weight
题目10: When using the writeObject method to store the state of n  
object, how can you protect sensitive data from being  
accessed in the stored object?(当用writeObject方法储存n个对象的状态时,如何保证敏感数据不被存储对象访问)
A Implement the Object as Exteralizable(实现对象作为序列化)
B Declare the sensitive fields as private transisent(声明敏感域作为私有transisent)
C Declare the sensitive fields as static transisent (声明敏感域作为静态transisent)
D Declare the sensitive fields as protected transisent(声明敏感域作为保护transisent)

解决方案 »

  1.   

    慢慢来吧,这个帖子得精华了
    首先第一题分两种情况,如果可以先从商店里面先拿一瓶凑够三瓶,之后还给他瓶子的话,那么,答案是18瓶。
    如果不允许那样换的话,那么就是19瓶。
    参考我的算法:
    http://blog.csdn.net/lihan6415151528/archive/2008/12/16/3530016.aspx
      

  2.   

    题目7输出结果:
    false
    true
    false
    首先list没有add test2,所以第一个false
    其次执行第二个if语句,value=this.value 值与test.value 相等,所以true
    第三个Object类型的直接return false
      

  3.   

    题目4: Which are not containers in Java?(Multiple answer)(多选:下面哪几个不是java所包含的) 
    A ScollPane 
    B Canvas java.awt
    C Scrollbar  java.awt
    D Applet java.applet
    E Dialog  java.awt毫无疑问选A    java swing包里面那个应该是JScollPane 
      

  4.   

    to 3楼lihan:
    真心求教第二题英文该如何翻译
      

  5.   

    A错是因为ScollPane写错了,如果是ScrollPane也是对的,是java.awt的
    java swing包里面的也应该是javax.swing.JScrollPane
      

  6.   

    很明显mouse不能强奸翻译成老鼠.
      

  7.   

    1 C 2 D  4 A
    5 F 6 C 
    9 B
      

  8.   

    第3题 用BorderLayout即可 记得给JTextArea加到JScrollPane里面
      

  9.   

    题目5:
    要按自然顺序排序为
    D java.util.SortedSet 
    如果是用SortedMap的话key是自然顺序排序 而不是value
      

  10.   

    题目7:
    true
    true
    false
    看重载的equals方法
      

  11.   

    题目8:英文没仔细看
    运行时异常 和Excepiton的区别就是它可以在代码中的任何地方抛出 而不必要在方法开始前抛出
      

  12.   

    第五题 应该是 F ,set集合中不允许有重复的元素出现!
      

  13.   

    第一题 : 买了9瓶  实际得到的是9+4=13瓶饮料和一个空瓶,买了18瓶得到的是 18+8=26瓶和2空瓶 买19瓶得到的是26+1+1 = 28瓶1空瓶。用程序验证如下:
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    int i=1;//买的数
    int j=1;//实际得到的
    int p=1;//空瓶数
    while(j<27){
    i++;
    j++;
    p++;
    if(j%3==0){
    j++;
    p=p-2;
    }
    }
    System.out.println("i="+i);
    System.out.println("j="+j);
    System.out.println("p="+p);
    }