面试啦 - 提供专业面试问题及答案、面试技巧、助您成功面试!
您的当前位置:首页 > 面试题库 > IT面试题 > JAVA程序员 > 正文

掌上明珠Java程序员面试总结

1. 分配一个5列6行的字符串数组.
2. 写出下面这段程序的输出
try
{
int i=0;
int i2=3/i;
}catch(ArithmeticException ae){
System.out.println(“数学计算错误”);
}catch(Exception e){
System.out.println(“通用错误”);
}finally{
System.out.println(“计算完成”);
}
3. 我们希望下面这段程序能顺序打出0到9十个数字,请指出错误:
public class Demo{
ArralList queue=new ArrayList();
int nextID=0;
Object lock=new Object();

public static void main(String[] args)
{
new Demo().start();
}
public void start()
{
new Producer().start();
new Producer().start();
new Consumer().start();
new Consumer().start();
}
class Producer implements Runnable{
public void run()
{
while(nextID<10)
{
queue.add(new Integer(nextID++));
synchronized(lock){
try{
lock.notifyAll();
}catch(Exception e){
}
}
try{
Thread.sleep(1000);
}catch(InterruptedException e){
}
}

}
}
class Consumer implements Runnable{
public void run(){
while(true){
if(queue.size()==0)
{
synchronized(lock)
{
try{
lock.wait();
}
catch(Exception e){
}
}
}
System.out.println(queue.remove(0));
}
}

}
}

4. 完成下面的程序,把一个int值保存到byte数组中(高位在前).
int i=13223; byte[] b=new byte[4];
5. 请说明Map(映射表)和Set(集合)这两种数据结构的异同点.
6. 有一个GBK编码的文本文件c:/a.txt(<32k),请写出一段程序,读取它的内容显示在标准输出上.
7. 请完成下面的排序算法
public interface Comparable{
//Compare to another instance
//@return >0 if this is larger,=0 if equal, <0 if this is smaller.
public int compareTo(Object o);
}
public static void sort(Comparable[] arr){
…………
}
词条:java面试题 java程序员面试题
上一篇:Ejb技术面试题 下一篇:25道Java面试题集合
与该文相关的文章

温馨提示:如果您对面试网有任何建议,请通过网站联系邮箱向我们反馈,感谢各位的建议与支持!