招聘试题
- 格式:doc
- 大小:37.50 KB
- 文档页数:4
招聘试题11.选择题(3′×10)(1)在java中,100.0 * 0.6 结果等于多少?dA、60.0004B、60C、60.00D、60.0(2)int a = 'A',请问System.out.println(a)打印出什么?aA、65B、AC、aD、97(3)System.out.println(Integer.parseInt("+1"))这句话执行会出现什么异常?aA、NumberFormatExceptionB、NullPointException(4)jsp如何获得客户端的IP地址?aA、request.getRemoteAddr()B、Request.ServerVariables("REMOTE_ADDR")(5)String a=new String("foo");String b=new String("foo");请问System.out.println(a1= =b1)打印出什么?bA、trueB、falseC、1D、0(6)Math.round(11.5)的值是多少?cA、11B、11.5C、12D、12.0(7)请问如下哪个方法可以将MenuBar加入Frame中?bA、setMenu()B、setMenuBar()C、add()D、addMenuBar()(8)Which of the following lines of code will compile without error?(多选)bcA、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路径最大长度是多少?bA、127B、255C、512D、1024(10) Consider the following code:(多选)C D EInteger 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=stIndexOf('d',4),int i2=stIndexOf('d',2),请问i1=_____-1_;i2=__3__。
(5)hashmap和hashtable区别_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)1(10′)假设有"thank","you","very","much"四个字符串,请编写一个将字符串按照首字母进行排序的程序。
2(10′)字符串的操作:写一个方法,实现字符串的反转,如:输入abc,输出cba答案1.选择题1、d2、A3、A4、A5、B6、C7、B8、B、C9、B10、C、E2.填空题1、hello world!,hello2、select top 10 * from A order by age desc3、llo4、3,-15、hashmap允许空值,而hashtalbe不允许;hashtalbe允许线程同步3.改错题1、return this + "@" + this.hashCode();此处导致exception StackOverflowError,将this+去掉2、ht.put("abc",null);此处null不可以,因为hashtable不允许空值,把null换成别的object就可以。
4.编程题1、public 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());}}}注:sortarray和sortvector方法选择其一就可以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;}。