返回列表 发帖

一套公司笔试题,大家可以看看

选择题  
1:Which modifier should be applied to a method for the lock of object this to be obtained prior to excution any of the method body?  
A.synchronized  
B.abstract  
C.final  
D.static 2:public class OuterClass { private double d1 = 1.0;   
//insert code here }   
You need to insert an inner class declaration at line 3. Which two inner class declarations are valid?   

public class OuterClass {
private double d1 = 1.0;
//insert code here
}
You need to insert an inner class declaration at line 3. Which two inner class declarations are
valid?A.class InnerOne{ public static double methoda() {return d1;} }  
B.public class InnerOne{ static double methoda() {return d1;} }  
C.private class InnerOne{ double methoda() {return d1;} }  
D.static class InnerOne{ protected double methoda() {return d1;} } 3:以下的C程序代码片段运行后C和d的值分别是多少  
Int a =1,b =2;  
Int c,d;  
c =(a&b)&&a;  
d =(a&&b)&a;  

A.0,0  
B.0,1  
C.1,0  
D.1,1 4:给出下面的代码片断。。。下面的哪些陈述为错误的? 1) public void create() {   
2) Vector myVect; 3) myVect = new Vector();   
4) }   
给出下面的代码片断。。。下面的哪些陈述为错误的?
1) public void create() {
2) Vector myVect;
3) myVect = new Vector();
4) }A.第二行的声明不会为变量myVect分配内存空间。  
B.第二行语句创建一个Vector类对象。  
C.第三行语句创建一个Vector类对象。  
D.第三行语句为一个Vector类对象分配内存空间 5:Give the following java source fragement: //point x   
public class Interesting{ //do something   
} Which statement is correctly Java syntax at point x?   

Give the following java source fragement:
//point x
public class Interesting{
//do something
}
Which statement is correctly Java syntax at point x? A.public class MyClass{//do other thing…}  
B.static int PI=3.14  
C.class MyClass{//do something…}  
D.none 6:Which fragments are not correct in Java source file?  
A.package testpackage; public class Test{//do something...}  
B.import java.io.*; package testpackage; public class Test{// do something...}  
C.import java.io.*; class Person{// do something...} public class Test{// do something...}  
D.import java.io.*; import java.awt.*; public class Test{// do something...} 7:What will be the result of executing the following code?   
// Filename; SuperclassX.java   
package packageX;   
public class SuperclassX   
{   
protected void superclassMethodX()   
{   
}   
int superclassVarX;   
}   
   
// Filename SubclassY.java   
1.package packageX.packageY;   
2.   
3.public class SubclassY extends SuperclassX   
4.{   
5.SuperclassX objX = new SubclassY();   
6.SubclassY objY = new SubclassY();   
7.void subclassMethodY()   
8.{   
9.objY.superclassMethodX();   
10.int i;   
11.i = objY.superclassVarX;   
12.}   
13.}   
Choices:   
What will be the result of executing the following code?  

// Filename; SuperclassX.java

package packageX;  

public class SuperclassX

{

protected void superclassMethodX()

{

}

int superclassVarX;

}  



// Filename SubclassY.java

1.package packageX.packageY;

2.

3.public class SubclassY extends SuperclassX

4.{

5.SuperclassX objX = new SubclassY();

6.SubclassY objY = new SubclassY();

7.void subclassMethodY()

8.{

9.objY.superclassMethodX();

10.int i;

11.i = objY.superclassVarX;

12.}

13.}  

Choices:A.Compilation error at line 5  
B.Compilation error at line 9  
C.Runtime exception at line 11  
D.None of these 8:Give the following code: public class Example{   
public static void main(String args[] ){ int l=0;   
do{ System.out.println(“Doing it for l is:”+l);   
}while(--l>0) System.out.println(“Finish”);   
} }   
Which well be output:   
Give the following code:
public class Example{
public static void main(String args[] ){
int l=0;
do{
System.out.println(“Doing it for l is:”+l);
}while(--l>0)
System.out.println(“Finish”);
}
}
Which well be output: A.Doing it for l is 3  
B.Doing it for l is 1  
C.Doing it for l is 2  
D.Doing it for l is 0 9:在下述选项时,没有构成死循环的程序是  
A.int i=100 while (1) { i=i%100+1; if (i>100) break; }  
B.for (;;);  
C.int k=1000; do { ++k; }while(k>=10000);  
D.int s=36; while (s);--s;
10.
What will happen when you attempt to compile and run the following code?   
class Base   
{   
int i = 99;   
public void amethod()   
{   
  System.out.println("Base.amethod()");   
  }   
  Base()   
{   
  amethod();   
  }   
}   
public class Derived extends Base   
{   
int i = -1;   
   
public static void main(String argv[])   
{   
  Base b = new Derived();   
  System.out.println(b.i);   
  b.amethod();   
  }   
  public void amethod()   
{   
  System.out.println("Derived.amethod()");   
  }   
}   
Choices:   
What will happen when you attempt to compile and run the following code?  

class Base  

{

int i = 99;  

public void amethod()

{

  System.out.println("Base.amethod()");

  }

  Base()

{

  amethod();

  }

}  

public class Derived extends Base

{

int i = -1;

   

public static void main(String argv[])

{

  Base b = new Derived();

  System.out.println(b.i);

  b.amethod();

  }  

  public void amethod()

{

  System.out.println("Derived.amethod()");

  }  

}  

Choices:A.Derived.amethod() -1 Derived.amethod()  
B.Derived.amethod() 99  
C.Compile time error  
D.Derived.amethod() 11:使用 JDBC 可以做到的是  
A.把二进制代码传送到任何关系数据库中  
B.把 Java 源代码传送到任何关系数据库中  
C.把表单信息传送到任何关系数据库中  
D.很容易地把 SQL 语句传送到任何关系数据库中 12:Select valid identifier of Java:   
Select valid identifier of Java:
A.%passwd  
B.3d_game  
C.$charge  
D.this 13:Math.round(-11.5)等於多少?  
A.-11  
B.-12  
C.-11.5  
D.none 14:What will be printed when you execute the following code?   
class X {   
  Y b = new Y(); X()   
{ System.out.print("X");   
  } }   
  class Y   
{ Y()   
  { System.out.print("Y");   
  } }   
  public class Z extends X   
{ Y y = new Y();   
  Z() {   
  System.out.print("Z"); }   
  public static void main(String[] args) {   
  new Z(); }   
}   
Choices:   
What will be printed when you execute the following code?  

class X  
{
  Y b = new Y();
  X()  
{  
  System.out.print("X");  
  }
}  

class Y  
{
  Y()  
  {  
  System.out.print("Y");  
  }
}  

public class Z extends X  
{
  Y y = new Y();  
  Z()  
{  
  System.out.print("Z");  
  }  
  public static void main(String[] args)  
  {
  new Z();
  }
}  

Choices:
A.Z  
B.YZ  
C.XYZ  
D.YXYZ 15:Which code fragments would correctly identify the number of arguments passed via command line to a Java application, exclude the name of the class that is being invoke.  
A.int count = args.length;  
B.int count = args.length-1;  
C.int count=0; while(args[count]!=null) count++;  
D.int count=0;while (!(args[count].equals(“”))) count++; 16:Which is the most appropriate code snippet that can be inserted at line 18 in the following code?   
(Assume that the code is compiled and run with assertions enabled)   
1. import java.util.*;   
2.   
3. public class AssertTest   
4. {   
5. private HashMap cctld;   
6.   
7. public AssertTest()   
8. {   
9. cctld = new HashMap();   
10. cctld.put("in", "India");   
11. cctld.put("uk", "United Kingdom");   
12. cctld.put("au", "Australia");   
13. // more code...   
14. }   
15. // other methods ....   
16. public String getCountry(String countryCode)   
17. {   
18. // What should be inserted here?   
19. String country = (String)cctld.get(countryCode);   
20. return country;   
21. }   
22. }   
Which is the most appropriate code snippet that can be inserted at line 18 in the following code?

(Assume that the code is compiled and run with assertions enabled)

1. import java.util.*;

2.  

3. public class AssertTest

4. {

5. private HashMap cctld;

6.   

7. public AssertTest()

8. {

9. cctld = new HashMap();

10. cctld.put("in", "India");

11. cctld.put("uk", "United Kingdom");

12. cctld.put("au", "Australia");

13. // more code...  

14. }

15. // other methods ....   

16. public String getCountry(String countryCode)

17. {

18. // What should be inserted here?

19. String country = (String)cctld.get(countryCode);

20. return country;

21. }

22. }A.assert countryCode != null;  
B.assert countryCode != null : "Country code can not be null" ;  
C.assert cctld != null : "No country code data is available";  
D.assert cctld : "No country code data is available"; 17:public class Parent {  
  int change() {…}  
}  

class Child extends Parent {  

}  

Which methods can be added into class Child?  
A.public int change(){}  
B.abstract int chang(){}  
C.private int change(){}  
D.none 18:Which of the following statements are not legal?  

A.long l = 4990;  
B.int i = 4L;  
C.double d = 34.4;  
D.double t = 0.9F. 19:What is the result when you compile and run the following code?   
public class Test   
{   
public void method()   
{   
for(int i = 0; i < 3; i++)   
  {   
  System.out.print(i);   
  }   
  System.out.print(i);   
}   
}   
Choices:   
What is the result when you compile and run the following code?  

public class Test

{  

public void method()

{

for(int i = 0; i < 3; i++)

  {

  System.out.print(i);

  }

  System.out.print(i);

}

}  

Choices:A.0122  
B.0123  
C.Compilation error  
D.None of these 20:Which method you define as the starting point of new thread in a class from which new the thread can be excution?  
A.public void start()  
B.public void run()  
C.public void runnable()  
D.public static void main(String args[])  
简答题  
21:请阐述一下你对JAVA多线程中“锁”的概念的理解。 22:什么是异常?试列出三个系统定义的运行时异常类。 23:用最简单的方法判断一个数是否是2的指数次幂。 24:100位以上的超大整数的加法(主要考虑数据结构和加法的实现)。 25:class Something { int I;   
  public void doSomething() { System.out.println("I = " + i);   
  } }   
代码是否有错?为什么。   
class Something {
  int I;
  public void doSomething() {
  System.out.println("I = " + i);
  }
}
代码是否有错?为什么。26:用 JDBC 编写能实现数据库连接和断开的程序段。 27:循环的有序数组(比如1,2,3,4,5,-3,-2,-1这种数列)里查找一个数。 28:abstract class和interface有什么区别? 29:多线程有哪些状态? 30:找出两个字符串中最大子字符串,如\"abractyeyt\",\"dgdsaeactyey\"的最大子串为\"actyet\"
分享到: QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友

哎,英文不行真是寸步难行啊,

TOP

什么时候把答案也发上来看看

TOP

好长啊。

TOP

答案才是重点

TOP

返回列表