CSDN博客

img sweetna

中兴软创笔试题一

发表于2008/12/1 11:07:00  10887人阅读

分类: 笔试试题总汇

招聘试题1

1.选择题(3′× 10)

  (1)java中,100.0 * 0.6 结果等于多少?d

        A60.0004   B60    C60.00    D60.0

    (2)int a = 'A',请问System.out.println(a)打印出什么?a

      A65     BA      Ca       D97

    (3)System.out.println(Integer.parseInt("+1"))这句话执行会出现什么异常?a

           ANumberFormatException        BNullPointException

    (4)jsp如何获得客户端的IP地址?a

Arequest.getRemoteAddr()

BRequest.ServerVariables("REMOTE_ADDR")

    (5)String a=new String("foo");

       String b=new String("foo");

       请问System.out.println(a1= =b1)打印出什么?b

       Atrue          Bfalse  C1              D0

    (6)Math.round(11.5)的值是多少?c

           A11     B11.5         C12     D   12.0

    (7)请问如下哪个方法可以将MenuBar加入Frame?b

      AsetMenu()

      BsetMenuBar()

      Cadd()

      DaddMenuBar()

(8)Which of the following lines of code will compile without error?(多选)bc

A、    

int i=0;

if (i) {

System.out.println(“Hi”);

}

  B.

   boolean b=true;

   boolean b2=true;

   if(b= =b2) {

     System.out.println(“So true”);

   }

C.

int i=1;

int j=2;

if(i==1|| j==2)  System.out.println(“OK”);

D.

int i=1;

int j=2;

if (i==1 &| j==2)  System.out.println(“OK”);

   

(9)Jsp路径太深文件名太长就无法读取文件,jsp路径最大长度是多少?b

           A127          B255          C512          D1024

(10) Consider the following code:(多选) C  D E

Integer s = new Integer(9);

Integer t = new Integer(9);

Long u = new Long(9);

Which test would return true?

A(s==u)

B(s==t)

C(s.equals(t))

D(s.equals(9))

E(s.equals(new Integer(9))

   

2.填空题(4′×5,每题4)

    (1) String s = "Hello";

String s1 = s;

s = s + " world!";

请问s的值是____Hello Would!_ ________s1的值是___Hello_ ________

      

(2)一个数据库表A(name varchar(10),age int),请写出一个SQL语句,按照age排序查出年龄最大的10条记录数 ___select * top 10 from A order by  age  DESC ______________________________________     

 

    (3)String str = "hello world!",请问substring(2,5)的值是__llo_ ______

       

    (4)String str = "abcdef",int i1=str.lastIndexOf('d',4),int i2=str.lastIndexOf('d',2),请问i1=_____-1_ i2=__3__

   

(5)hashmaphashtable区别

_hashmap允许有空值,hashtable不允许,hasptable允许线程同步

______________________________________________________________________   

 

3.改错题(10′×2)

(1)      

interface A {

              int y = 0;

       }

 

       class B {

              int x = 1;

       }

 

       class C extends B implements A {

              public void pX() {

                     System.out.println(y);

       }

 

       public String toString() {

              return this + "@" + this.hashCode();   //去掉this +

       }

 

       public static void main(String[] args) {

              C c = new C();

              c.pX();

              System.out.println(c);

              }

       }

       (2)

       class Test{

        public static void main(String[] args){

          HashMap hm = new HashMap();

         Hashtable ht = new Hashtable();

          hm.put("abc",null);

          System.out.println(hm.get("abc"));

          ht.put("abc",null); 

          System.out.println(ht.get("abc"));

       }}

4.编程题(15′×2)

110′)假设有"thank","you","very","much"四个字符串,请编写一个将字符串按照首字母进行排序的程序。

210′)字符串的操作:写一个方法,实现字符串的反转,如:输入abc,输出cba

 

答案

1.选择题

1、  d

2、  A

3、  A

4、  A

5、  B

6、  C

7、  B

8、  BC

9、  B

10、              CE

2.填空题

1、  hello world!hello

2、  select top 10 * from A order by age desc

3、  llo

4、  3-1

5、  hashmap允许空值,而hashtalbe不允许;hashtalbe允许线程同步

3.改错题

1return this + "@" + this.hashCode(); 

       此处导致exception StackOverflowError,将this+去掉

2、      ht.put("abc",null); 

此处null不可以,因为hashtable不允许空值,把null换成别的object就可以。

 

4.编程题

1public class Testsort {

       public void sortarray(String[] ar){

              Arrays.sort(ar);            

       }

       public void sortvector(Vector vc){

              Collections.sort(vc);

       }

 

       public static void main(String[] args) {

              Testsort ts = new Testsort();

              String ar[] = {"thank","you","very","much"};

              System.out.println("Before sort array");

              for(int i=0;i<ar.length;i++){

                     System.out.println(ar[i]);

              }

              System.out.println("After sort array");

              ts.sortarray(ar);

              for(int i=0;i<ar.length;i++){

                     System.out.println(ar[i]);

              }

             

              Vector vc = new Vector();

              vc.add("thank");

              vc.add("you");

              vc.add("very");

              vc.add("much");

              System.out.println("Before sort vector");

              for(Iterator i = vc.iterator();i.hasNext();)

              {

                     System.out.println(i.next().toString());

              }

              ts.sortvector(vc);

              System.out.println("After sort vector");

              for(Iterator i = vc.iterator();i.hasNext();)

              {

                     System.out.println(i.next().toString());

              }

       }

}

注:sortarraysortvector方法选择其一就可以

 

2  public String reverse(String str){

              StringBuffer str1 =new StringBuffer(str);

              str1.reverse();

              return str1.toString();

       }

       或者

       public String reverse(String str){

              String strtemp = "";

              for(int i=str.length()-1;i>=0;i--){

                     strtemp += str.charAt(i)+"";

              }

              return strtemp;

       }

0 0

相关博文

我的热门文章

img
取 消
img