logo资料库

软通动力面试题(大量代码实战测试).doc

第1页 / 共196页
第2页 / 共196页
第3页 / 共196页
第4页 / 共196页
第5页 / 共196页
第6页 / 共196页
第7页 / 共196页
第8页 / 共196页
资料共196页,剩余部分请下载后查看
JAVA基础部分面试题库
10)请定义一个二维数据,大小为3*5
18)基本数据类型有哪些
31)面向对象的三个基本特征
45)简述接口和内部类、抽象类的特点
50)String的常用方法有哪些,试说出5种
55)java中可以类多继承吗?接口可以多继承吗
57)什么是方法的重写,重写时有哪些注意事项
58)set集合中不允许出现重复的对象,请问我们使用什么方法来判断两个对象是否相同
59)请说明list、set、map的特点和区别
74)awt中的核心类有那几个
75)gui编程中都有哪些事件需要我们处理
76)请说出tcp/ip的参考模型
77)请说出OSI的参考模型
98)JDBC调用数据库的基本步骤
102)如果一个事务在执行过程这个出现异常状况,我们如何来处理
116)forward 和redirect的区别
119)servlet的init()方法和service()方法的区别
Java EE 高级部分
JSP
选择题(100题)
简答题(9题)
Servlet
选择题(41题)
简答题(17题)
Struts
选择题(62题)
简答题(3题)
Spring
选择题(15题)
简答题(18题)
Hibernate
选择题(37题)
简答题(6题)
Ajax
选择题(11题)
简答题(30题)
Web Service
选择题(7题)
简答题(1题)
JSF
选择题(8题)
简答题(0题)
EJB
选择题(45题)
简答题(11题)
WEB服务器
选择题(3题)
简答题(12题)
XML
选择题(70题)
简答题(3题)
其他相关
OOAD
选择题(60题)
简答题(0题)
Other
选择题(11题)
简答题(5题)
软通动力信息技术有限公司 JAVA 基础部分面试题库 第一部分:选择题 1) 哪个不是面向对象的特征 (d ) a) 封装性 b) 继承性 c) 多态性 d) 健壮性 2) 编译 JAVA 文件的命令是( b)。 a) b) c) d) Java Javac Javadb Javaw 3) JAVA 源文件的扩展名是( c)。 a) b) c) d) Class exe java dll 4) JAVA 内部使用的编码格式是(c )。 a) b) c) d) UTF-8 ASCII UNICODE ISO8859-1 5) 下列变量名称不合法的是( d) a) b) c) d) Index $bc3& _cccde 34#bc5 6) 下边对基本数据类型的说明正确的是( c) a) b) c) Int 可以自动转换为 BYTE 类型 DOUBLE 类型的数据占用 2 个字节 JAVA 中一共有 4 类 8 种基本数据类型
软通动力信息技术有限公司 d) JAVA 中一共有 3 类 8 种基本数据类型 7) 下列不是 JAVA 关键字的是(c ) a) b) c) d) goto if count private 8) 下列变量声明中正确的是( ) Float f = 3.13 Boolean b = 0 Int number = 5 a) b) c) Int x d) Byte a = x 9) public void go() { String o = ""; z: for(int x = 0; x < 3; x++) { for(int y = 0; y < 2; y++) { if(x==1) break; if(x==2 && y==1) break z; o = o + x + y; } } System.out.println(o); } 程序的执行结果是( ) a) b) c) d) e) f) 00 0001 000120 00012021 Compilation fails. An exception is thrown at runtime 10) class Payload { private int weight; public Payload (int w) { weight = w; } public void setWeight(int w) { weight = w; } public String toString() { return Integer.toString(weight); } } public class TestPayload {
软通动力信息技术有限公司 static void changePayload(Payload p) { /* insert code */ } public static void main(String[] args) { Payload p = new Payload(200); p.setWeight(1024); changePayload(p); System.out.println("p is " + p); } Insert code 处写入哪句话, 可以使程序的输出结果是 420( ) } } a) b) c) d) e) p.setWeight(420); p.changePayload(420); p = new Payload(420); Payload.setWeight(420); p = Payload.setWeight(420); 11) void waitForSignal() { Object obj = new Object(); synchronized (Thread.currentThread()) { obj.wait(); obj.notify(); }这个程序片段的运行结果是什么( ) a) b) c) d) normally. This code can throw an InterruptedException. This code can throw an IllegalMonitorStateException. This code can throw a TimeoutException after ten minutes. Reversing the order of obj.wait() and obj.notify() might cause this method to complete 12) public class Threads2 implements Runnable { public void run() { System.out.println("run."); throw new RuntimeException("Problem"); } public static void main(String[] args) { Thread t = new Thread(new Threads2()); t.start(); System.out.println("End of method."); } } 运行结果是什么,请选择 2 个( ) a) b) java.lang.RuntimeException: Problem run. java.lang.RuntimeException: Problem
c) d) e) End of method. java.lang.RuntimeException: Problem End of method. run. java.lang.RuntimeException: Problem run. java.lang.RuntimeException: Problem End of method. 13) 下边哪 2 句话的描述是正确的( ) 软通动力信息技术有限公司 a) b) It is possible for more than two threads to deadlock at once The JVM implementation guarantees that multiple threads cannot enter into a deadlocked Deadlocked threads release once their sleep() method's sleep duration has expired. Deadlocking can occur only when the wait(), notify(), and notifyAll() methods are used It is possible for a single-threaded application to deadlock if synchronized blocks are used state. c) d) incorrectly. e) incorrectly. f) f a piece of code is capable of deadlocking, you cannot eliminate the possibility of deadlocking by inserting invocations of Thread.yield(). 14) public class Threads2 implements Runnable { public void run() { System.out.println("run."); throw new RuntimeException("Problem"); } public static void main(String[] args) { Thread t = new Thread(new Threads2()); t.start(); System.out.println("End of method."); } }程序运行结果是,选择 2 个( ) a) b) c) d) java.lang.RuntimeException: Problem run. java.lang.RuntimeException: Problem End of method End of method. java.lang.RuntimeException: Problem End of method. run. java.lang.RuntimeException: Problem 15) void waitForSignal() { Object obj = new Object(); synchronized (Thread.currentThread()) { obj.wait(); obj.notify(); } }下列那句描述是正确的( ) a) b) c) This code can throw an InterruptedException. This code can throw an IllegalMonitorStateException. This code can throw a TimeoutException after ten minutes.
d) This code does NOT compile unless "obj.wait()" is replaced with "((Thread) obj).wait()". 软通动力信息技术有限公司 16) 11. class PingPong2 { synchronized void hit(long n) { for(int i = 1; i < 3; i++) System.out.print(n + "-" + i + " "); } } public class Tester implements Runnable { static PingPong2 pp2 = new PingPong2(); public static void main(String[] args) { new Thread(new Tester()).start(); new Thread(new Tester()).start(); } . public void run() { pp2.hit(Thread.currentThread().getId()); } }运行结果是( ) a) b) c) d) The output could be 5-1 6-1 6-2 5-2 The output could be 6-1 6-2 5-1 5-2 The output could be 6-1 5-2 6-2 5-1 The output could be 6-1 6-2 5-1 7-1 17) 1. public class Threads4 { public static void main (String[] args) { new Threads4().go(); } public void go() { Runnable r = new Runnable() { public void run() { System.out.print("foo"); } }; Thread t = new Thread(r); t.start(); t.start(); } }运行结果是( ) a) b) c) d) Compilation fails. An exception is thrown at runtime. The code executes normally and prints "foo". The code executes normally, but nothing is printed. 18) 11. public class Barn { public static void main(String[] args) { new Barn().go("hi", 1);
软通动力信息技术有限公司 new Barn().go("hi", "world", 2); } public void go(String... y, int x) { System.out.print(y[y.length - 1] + " "); } }运行结果是( ) a) b) c) d) hi hi hi world Compilation fails An exception is thrown at runtime. 19) 10. class Nav{ . public enum Direction { NORTH, SOUTH, EAST, WEST } } public class Sprite{ // insert code here }哪句代码放到 14 行,程序可以正常编译( ) a) b) c) d) Direction d = NORTH; Nav.Direction d = NORTH; Direction d = Direction.NORTH; Nav.Direction d = Nav.Direction.NORTH; 20) 11. public class Rainbow { public enum MyColor { RED(0xff0000), GREEN(0x00ff00), BLUE(0x0000ff); private final int rgb; MyColor(int rgb) { this.rgb = rgb; } public int getRGB() { return rgb; } }; public static void main(String[] args) { // insert code here } }哪句代码放到 19 行,程序可以正常编译( ) a) b) c) d) MyColor skyColor = BLUE; MyColor treeColor = MyColor.GREEN; Compilation fails due to other error(s) in the code. MyColor purple = MyColor.BLUE + MyColor.RED; 21) 5. class Atom { Atom() { System.out.print("atom "); } }
软通动力信息技术有限公司 class Rock extends Atom { Rock(String type) { System.out.print(type); } } public class Mountain extends Rock { Mountain() { super("granite "); new Rock("granite "); } public static void main(String[] a) { new Mountain(); } }运行结果是( ) a) b) c) d) Compilation fails atom granite granite An exception is thrown at runtime. atom granite atom granite 22) 1. interface TestA { String toString(); } public class Test { public static void main(String[] args) { 4System.out.println(new TestA() { public String toString() { return "test"; } }); } }运行结果是( ) a) b) c) d) test null An exception is thrown at runtime. Compilation fails because of an error in line 1. 23) 11. public static void parse(String str) { try { float f = Float.parseFloat(str); } catch (NumberFormatException nfe) { f = 0; } finally { 17. System.out.println(f); } } public static void main(String[] args) { parse("invalid"); }运行结果是( ) a) b) c) 0.0 Compilation fails. A ParseException is thrown by the parse method at runtime
软通动力信息技术有限公司 d) A NumberFormatException is thrown by the parse method at runtime 24) 1. public class Blip { protected int blipvert(int x) { return 0; } } class Vert extends Blip { // insert code here }下列哪 5 个方法放到代码第五行,可以让程序编译正确,选择 5 个 ( ) a) b) c) d) e) f) g) public int blipvert(int x) { return 0; } private int blipvert(int x) { return 0; } private int blipvert(long x) { return 0; } protected long blipvert(int x) { return 0; } protected int blipvert(long x) { return 0; } protected long blipvert(long x) { return 0; } protected long blipvert(int x, int y) { return 0; } 25) 1. class Super { private int a; protected Super(int a) { this.a = a; } } ... class Sub extends Super { public Sub(int a) { super(a); } public Sub() { this.a = 5; } }下列哪 2 条语句是正确的( ) a) b) c) d) e) Change line 2 to: public int a; Change line 2 to: protected int a; Change line 13 to: public Sub() { this(5); } Change line 13 to: public Sub() { super(5); } Change line 13 to: public Sub() { super(a); } 26) package test; class Target { public String name = "hello"; }如果可以直接修改和访问 name 这个变量,下列哪句话是正确的 a) b) c) d) any class only the Target class any class in the test package any class that extends Target 27) 11. abstract class Vehicle { public int speed() { return 0; } class Car extends Vehicle { public int speed() { return 60; }
分享到:
收藏