一套英文的Java面试题笔试题

2014-07-15 06:30:01 阅读( 108 )

2285人 收藏本页

标签:Java面试题

一、    选择题:
1.    Which declarations of identifiers are legal?
A.$persons
B.TwoUsers
C.*point
D.this
E._endline
2.    Which statements about inheritance are true?
A.    In Java programming language only allows single inheritance.
B.    In Iava programming language allows a class to implement only one interface.
C.    In Java programming language a class cannot extend a class and implement a interface together.
D.    In Java programming language single inheritance makes code more reliable.
3.    Which keyword should be used to enable interaction with the lcok of an object?The flag allows exclusive access to that object.
A.    transient
B.    synchronized
C.    serialize
D.    static
4.    Which statements about the garbage collection are true?
A.    The program developer must create a thread to be responsible for free the momory.
B.    The garbage collection will check for and free memory no longer needed.
C.    The garbage collection allow the program developer to explicity and immediately free the memory.
D.    The garbage collection can free the memory used java object at expect time.
5.    Which of the following statements about variables and their scopes are true?
A.    Instance variables are member variables of a class.
B.    Instance variables are declared with the static keyword.
C.    Local variables defined inside a method are created when the method is executed.
D.    Local variables must be initialized before they are used.
6.    Which is not a method of the class InputStream?
A.    int read(byte[])
B.    void flush()
C.    void close()
D.    int available()
7.    Which classes can be used as the argument of the constructor of the class FileInputStream?
A.    InputStream
B.    File
C.    FileOutputStream
D.    String
8.    Given the uncompleted method:
1)
2){success=connect();
3}if(success==-1){
4}throw new TimedOutException();
5}}
6}}
TimedOutException is not a RuntimeException.Which can complete the method of declaration when added at line 1?
A.    public void method()
B.    public void method() throws Exception
C.    public void method() throws TimedOutException
D.    public void method() throws TimedOutException
E.    public throw TimedOutException void method()
9.    Which statements about thread are true?
A.    Once a thread is created, it can star running immediately.
B.    To use the start() method makes a thread runnable, but it does not necessarily start immediately.
C.    When a thread stops running because of pre-emptive, it is placed at the front end of the runnable queue.
D.    A thread may cease to be ready for a variety of reasons.
10.    The method resume() is reaponsible for resuming which threads’s execution?
A.    The thread which is stopped by calling method stop()
B.    The thread which is stopped by calling method sleep()
C.    The thread which is stopped by calling method wait()
D.    The thread which is stopped by calling method suspend()

Java试题(一)
一、 选择

1.欲构造ArrayList类的一个实例,此类继承了List接口,下列哪个方法是正确的 ?
A ArrayList myList=new Object();
B List myList=new ArrayList();
C ArrayList myList=new List();
D List myList=new List();

2.paint()方法使用哪种类型的参数?
A Graphics
B Graphics2D
C String
D Color

3.指出正确的表达式
A byte=128;
B Boolean=null;
C long l=0xfffL;
D double=0.9239d;

4.指出下列程序运行的结果
public class Example{
String str=new String(“good”);
char[]ch={‘a’,'b’,'c’};
public static void main(String args[]){
Example ex=new Example();
ex.change(ex.str,ex.ch);
System.out.print(ex.str+” and “);
Sytem.out.print(ex.ch);
}
public void change(String str,char ch[]){
str=”test ok”;
ch[0]=’g';
}
}
A good and abc
B good and gbc
C test ok and abc
D test ok and gbc

5.运行下列程序, 会产生什么结果
public class X extends Thread implements Runable{
public void run(){
System.out.println(“this is run()”);
}
public static void main(String args[])
{
Thread t=new Thread(new X());
t.start();
}
}
A 第一行会产生编译错误
B 第六行会产生编译错误
C 第六行会产生运行错误
D 程序会运行和启动

6.要从文件” file.dat”文件中读出第10个字节到变量C中,下列哪个方法适合?
A FileInputStream in=new FileInputStream(“file.dat”); in.skip(9); int c=in.read();
B FileInputStream in=new FileInputStream(“file.dat”); in.skip(10); int c=in.read();
C FileInputStream in=new FileInputStream(“file.dat”); int c=in.read();
D RandomAccessFile in=new RandomAccessFile(“file.dat”); in.skip(9); int c=in.readByte();

7.容器被重新设置大小后,哪种布局管理器的容器中的组件大小不随容器大小的变化而改变?
A CardLayout
B FlowLayout
C BorderLayout
D GridLayout

8.给出下面代码:
public class Person{
static int arr[] = new int[10];
public static void main(String a[])
{
System.out.println(arr[1]);
}
}

那个语句是正确的?
A 编译时将产生错误;
B 编译时正确,运行时将产生错误;
C 输出零;
D 输出空。

9.哪个关键字可以对对象加互斥锁?
A transient
B synchronized
C serialize
D static

10.下列哪些语句关于内存回收的说明是正确的?
A 程序员必须创建一个线程来释放内存;
B 内存回收程序负责释放无用内存
C 内存回收程序允许程序员直接释放内存
D 内存回收程序可以在指定的时间释放内存对象

11.下列代码哪几行会出错:
1) public void modify() {
2) int I, j, k;
3) I = 100;
4) while ( I > 0 ) {
5) j = I * 2;
6) System.out.println (” The value of j is ” + j );
7) k = k + 1;
8) I–;
9) }
10) }
A line 4
B line 6
C line 7
D line 8

二、多项选择

1.执行下列代码后,哪个结论是正确的 String[] s=new String[10];
A s[10] 为 “”;
B s[9] 为 null;
C s[0] 为 未定义
D s.length 为10

2.下面的表达式哪个是正确的?
A String s=”你好”;int i=3; s+=i;
B String s=”你好”;int i=3; if(i==s){ s+=i};
C String s=”你好”;int i=3; s=i+s;
D String s=”你好”;int i=3; s=i+;

E. String s=null; int i=(s!=null)&&(s.length>0)?s.length():0;

3.选出合理的标识符
A _sys1_lll
B 2mail
C $change
D class

4.哪个布局管理器使用的是组件的最佳尺寸( preferred size)
A FlowLayout
B BorderLayout
C GridLayout
D CardLayout

E.GridBagLayout

5.下列哪个方法可用于创建一个可运行的类?
A public class X implements Runable{ public void run(){ ……} }
B public class X implements Thread{ public void run(){ ……} }
C public class X implements Thread{ public int run(){ ……} }
D public class X implements Runable{ protected void run(){ ……} }

E.public class X implements Thread{ public void run(){ ……} }

6.下面哪个方法可以在任何时候被任何线程调用?
A notify()
B wait()
C notifyAll()
D sleep()

E.yield()

F.synchronized(this)

7.构造BufferedInputStream的合适参数是哪个?
A BufferedInputStream
B BufferedOutputStream
C FileInputStream
D FileOuterStream

E. File

8.下列说法正确的是
A java.lang.Clonable是类

B java.lang.Runnable是接口
C Double对象在java.lang包中
D Double a=1.0是正确的java语句

9.指出正确的表达式
A double a=1.0;
B Double a=new Double(1.0);
C byte a = 340;
D Byte a = 120;

10.定义一个类名为”MyClass.java”的类,并且该类可被一个工程中的所有类访问,那么该类的正确声明应为:
A private class MyClass extends Object
B class MyClass extends Object
C public class MyClass
D public class MyClass extends Object

11.指出下列哪个方法与方法public void add(int a){}为合理的重载方法。
A public int add(int a)
B public void add(long a)
C public void add(int a,int b)
D public void add(float a)

12.如果下列的方法能够正常运行,在控制台上将显示什么?
public void example(){
try{
unsafe();
System.out.println(“Test1″);
}
catch(SafeException e)
{System.out.println(“Test 2″);}
finally{System.out.println(“Test 3″);}
System.out.println(“Test 4″);
}
A Test 1
B Test 2
C Test 3
D Test 4

13.下列哪些情况可以终止当前线程的运行?
A 抛出一个例外时。
B 当该线程调用sleep()方法时。
C 当创建一个新线程时。
D 当一个优先级高的线程进入就绪状态时。

一、 不定项选择

1.short 的取值范围
A -27-1—27-1
B    0- ??-1
C ?23-15–23-1
D ?25-1—25-1

2 int的取值范围

3.一个二进制>>5位和<<5位结果的判断;

4.哪个关键字可以对对象加互斥锁?
A transient
B synchronized
C serialize
D static

5.下列哪些语句关于内存回收的说明是正确的?

6.选出合理的标识符
A #sys1_lll
B 2mail   //必须以”_”或”$”符号开头
C $******(*为其他的字母)
D this

7.下列哪些布局管理器当Frame 的大小改变时候,在里面的按钮位置也会跟着改变
A FlowLayout
B BorderLayout
C GridLayout
D CardLayout

8.对java中的单一继承和实现接口说法的判断
A JAVA只允许单一继承
BJAVA只能实现一个接口
Cjava只能同时继承一个父类和实现一个接口
D

9下面哪些不是java中的值类型
A int
B Boolean
C double
D String

10 main方法的返回类型
A void
B static
C int
D

11下列一段程序说法正确的是
Public class C{        //1
Vetcor v;        //2
v=new Vector();    //3
}
A 2行程序为V分配了一个内存空间
B 2行程序没有为V分配一个引用
C 3行程序为V分配了一个内存空间
D 3行程序没有为V分配一个引用
E 3行程序没有为V分配一个对象

12.指出错误的表达式
A double a=1.0;
B Double a=1.0;
C byte a = 340;
D Byte a = 120;

13 下列对字符串操作错误的是(只是大概的我只记得那个错误的答案)
A String s=”a” a+=”ddd”
B Sring s=”test” s.toUpperCase();
C String s=”aaaa” s[3]=””;
D String s=“abcTest”
s=s-“Test”;

三、 填空题

1.执行下列代码后的结果是什么? int x,a=2,b=3,c=4; x=++a+b+++c++;

2.  包包含了Collection的接口和类的API

3.main方法的声明格式包括

4.下列程序中构造了一个SET并且调用其方法add(),输出结果是
public class A{
public int hashCode(){return 1;}
public Boolean equals(Object b){return true}
public static void main(String args[]){ Set set=new HashSet();
set.add(new A());
set.add(new A());
set.add(new A());
System.out.println(set.size());
}
}

5.下列程序的运行结果是
class A{
class Dog{
private String name;
private int age;
public int step;
Dog(String s,int a)
{
name=s;
age=a;
step=0;
}
public void run(Dog fast)
{
fast.step++;
}
}
public static void main (String args[])
{
A a=new A();
Dog d=a.new Dog(“Tom”,3);
d.step=25;
d.run(d);
System.out.println(d.step);
}
}

四、 编程题

1.编写一个输出”Hello World!”的程序,用两种方式实现(Application、Applet)。

2.写一个冒泡算法排序int []array = {4,3,5,1,2};

3.有下面一段Server段程序,目的是能够同时服务多个客户,客户的请求是一句话(一个 String)。如果这个请求的内容是字符串”plain”的话,服务器仅将”hello”字符串返回给用户。否则将用户的话追加到当前目录的文本文件Memo.txt中(路径为”Memo.txt”),并向用户返回”OK”。注意Server并发的处理多用户,Memo.txt被共享,要求不能出现数据不一致。Server的程序如下文件Server.java:
public class Server{
public static void main(String args[]){
MemoController memoController = new MemoController();
try{
ServerSocket ss = new ServerSocket(1999);
while (true){
Socket s = ss.accept();
try{
UserThread t = new UserThread(s, memoController);
t.start();
}catch(Exception e){
e.printStackTrace();
}
}
}catch(Exception e){
e.printStackTrace();
}finally{
memoController.close();
}
}
}
类UserThread程序如下:
文件UserThread.java:
public class UserThread extends Thread{
Socket s;
MemoController memo;
public UserThread (Socket s, MemoController memo){
this.s = s;
this.memo = memo;
}
public void run(){
try{
BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));
PrintWriter pw = new PrintWriter(new OutputStreamWriter(s.getOutputStream()));
String req = br.readLine();
if (req.equals(“plain”)){
pw.println(“hello”);
}else{
memo.append(req);
pw.println(“OK”);
}
pw.flush();
pw.close();
br.close();
s.close();
}catch(Exception e){
e.printStackTrace();
}
}
}
请根据题目的要求和现有的Server.java, UserThread.java的程序完成类MemoController.java的程序。

5. 翻译一段英文文档(请尽量使用专业术语)。
The object-oriented programm is a new and different way of thinking about programming.
Many people have trouble at first knowing how to approach an OOP project. Now that you understand the concept of an     object, and as you learn to think more in an object-oriented style, you can begin to create “good” designs that take advantage of all the benefits that OOP has to offer. This chapter introduces the ideas of analysis, design, and some ways to approach the problems of developing good object-oriented programs in a reasonable amount of time.

9.public class B{
Public static void main(String[] args){
int  number;
System.out.println(number);
}
}
当你运行以上程序的时候会输出 什么样的结果? (英文)
1)    Null
2)    0
3)    未初始化的变量
4) 以上都不是

1.     Public abstract  Hello{
Private string h;
Public abstract void fine(){}
} 有错误吗?
8. public class A{
Public void amethod(string str){
System.out.println(“ hello world ”+ str);
}
public static void main(String argments)    {
amethod(argments);
amethod(argments[1]);

}

来自IT公司面试手册

下一篇:什么是JDK,举出几个公司开发的JDK。

上一篇:广州喜创信息技术有限公司JAVA 软件工程师笔试题

亲~ 如果您有更好的答案 可在评论区发表您独到的见解。

您想查看更多的信息: 面试题