logo资料库

上海德邦物流股份有限公司招聘java面试真题.doc

第1页 / 共9页
第2页 / 共9页
第3页 / 共9页
第4页 / 共9页
第5页 / 共9页
第6页 / 共9页
第7页 / 共9页
第8页 / 共9页
资料共9页,剩余部分请下载后查看
上海
上海德邦物流股份有限公司招聘 java 面试真题 一、选择题(20) [含多选]。(请在正确的答案上打”√”) Question 1) Which of the following statements are true? 1) An interface can only contain method and not variables 2) Interfaces cannot have constructors 3) A class may extend only one other class and implement only one interface Interfaces are but require 4) ance, faces. the implementing Java approach to addressing its lack of multiple classes to create the functionality of the inherit Inter Question 2) Which of the following statements are true? 1) The garbage collection algorithm in Java is vendor implemented 2) The size of primitives is platform dependent The default type for a numerical literal with decimal component is a float 3) . You 4) tValue can modify the value in an Instance of the Integer class with the se method Question 3) Which of the following are true statements? 1) I/O in Java can only be performed using the Listener classes The RandomAccessFile class allows you to move directly to any point a file 2) . 3) e The in creation of the underlying named a operating instance system of only the File class creates a matching fil when the close method is called.
4) The separator, characteristics on depend of the an instance of the File class such as the directory current underlying operating system Question 4) What will happen when you attempt to compile and run the following code class Base{ public void Base(){ System.out.println(“Base”);}} public class In extends Base{ public static void main(String argv[]){ In i=new In();}} 1) Compile time error Base is a keyword 2) Compilation and no output at runtime 3) Output of Base 4) Runtime error Base has no valid constructor Question 5) You have a public class called myclass with the main method defined as follows public static void main(String parm[]){ System.out.println(parm[0]);} If you attempt to compile the class and run the program as follows java myclass hello What will happen? 1) Compile time error, main is not correctly defined 2) Run time error, main is not correctly defined 3) Compilation and output of java
4) Compilation and output of hello Question 6) Which of the following statements are NOT true? 1) If a class has any abstract methods it must be declared abstract itself. 2) When applied to a class, the final modifier means it cannot be sub-classed 3) All methods in an abstract class must be declared as abstract 4) transient and volatile are Java modifiers Question 7) What will happen when you attempt to compile and run the following class? class Base{ Base(int i){ System.out.println(“Base”); } } class Severn extends Base{ public static void main(String argv[]){ Severn s = new Severn(); } void Severn(){ System.out.println(“Severn”); } } 1) Compilation and output of the string ”Severn” at runtime
2) Compilation and no output at runtime 3) Compile time error 4) Compilation and output of the string ”Base” Question 8) Which of the following statements are true? 1) Static methods cannot be overriden to be non static 2) Static methods cannot be declared as private 3) Private methods cannot be overloaded 4) An overloaded method cannot throw exceptions not checked in the base class Question 9) Which of the following statements are true? The automatic garbage collection of the JVM prevents programs from ever run 1) ning outof memory A program can suggest that garbage collection be performed but not force i 2) t 3) Garbage collection is platform independent 4) ng An it object are set to null. becomes eligible for garbage collection when all references denoti Question 10) Given the following code public class Sytch{ int x=2000; public static void main(String argv[]){ System.out.println(“Ms ”+argv[1]+”Please pay $”+x); }
} What will happen if you attempt to compile and run this code with the command line java Sytch Jones Diggle 1) Compilation and output of Ms Diggle Please pay $2000 2) Compile time error 3) Compilation and output of Ms Jones Please pay $2000 4) Compilation but runtime error Question 11) You es a need to data. of read Which in of the lines the of following large a would text file containing tens of megabyt be most suitable for reading in such file 1) new FileInputStream(“file.name”) 2) new InputStreamReader(new FileInputStream(“file.name”)) 3) new BufferedReader(new InputStreamReader(new FileInputStream(“file.name”))); 4) new RandomAccessFile raf=new RandomAccessFile(“myfile.txt”,”+rw”); Question 12) Which of the following statements are true? 1) Constructors cannot have a visibility modifier 2) Constructors are not inherited 3) Constructors can only have a primitive return type 4) Constructors can be marked public and protected, but not private Question 13) statement Which 1)An anonymous 2)An anonymous true? is inner inner class class may can be be declared as declared as final. private.
implement access multiple interfaces . final variables in any enclosing scope. a static inner class requires an instance of t 3)An anonymous 4)An anonymous 5)Construction he enclosing inner inner an of can can class class instance of outer class. Question 14) public class Foo{ public static void main(String sgf[]){ StringBuffer(“A”); StringBuffer(“B”); = = new new StringBuffer a StringBuffer b operate(a,b); System.out.println(a+”,”+b); static void operate(StringBuffer } x,StringBuffer y){ the x.append(y); y=x; }} What is 1)The 2)The 3)The 4)The 5)The code code code code code Question 15) result? compiles compiles compiles compiles compiles and and and and and prints “A.B”. prints “A.A”. prints “B.B”. prints “AB.B”. prints “AB.AB”. following thread state transitions are valid? of Which 1) 2) 3) 4) 5) 6) the From ready From running From running From waiting From waiting From ready to to to to to to running. ready. waiting. running. ready. waiting. Question 16) What is the result of attempting to compile and run the following program? public class Test { private private public int i int j static = = j; 10; void main(String args[]) {
System.out.println((new } Test()).i); } 1) st. 2) 3) 4) Compiler error complaining about access restriction of private variables of Te Compiler error No No error error - - The The complaining about forward referencing. output output is is 0; 10; Question 17) cannot a directly cause a synchronized block thread to stop executing? wait method notify on an object two Which 1)exiting 2)calling 3)calling 4)calling 5)calling from the the a the read method method on on an object an InputStream object setPriority method on a thread object Question 18) Which of the following are correct, if you compile the following code? public class CloseWindow extends Frame implements WindowListener { public CloseWindow() { addWindowListener(this); // setSize(300, 300); setVisible(true); } This is listener registration public void windowClosing(WindowEvent e) { System.exit(0); public static } void main(String args[]) CloseWindow CW = new CloseWindow(); } { } 1) 2) 3) 4) error time time Compile Run Code compiles Compile error and runs but Frames does successfully not listen to WindowEvents Question 19)
Which zation statements describe guaranteed behavior of the garbage collection and finali mechanisms? Objects are deleted when they can no longer be accessed through any referenc 1) e. The 2) The 3) 4) An active 5) The object part of finalize() finalize() method method will will eventually never be be called on every object. called more than once on an object. will not be garbage collected as long as it is possible for an the program to access it garbage collector will use a mark through a and sweep reference. algorithm. that a word should member be variable used? should be accessible only by sam Question 20) A e design class package,which requires modifer 1) protected 2) public 3) no modifer 4) private 二.简答题。(80) (请注意字迹填写工整) 2.1 说明 SQL 语言中的 Select 中的 Having 子句作用。(5) 2.2 解释 Union All 与 Union 的区别。(5) 2.3 现有关系数据库如下 (20) 用 SQL 语言实现以下四小题。 1、 检索没有获得奖学金、同时至少有一门课程成绩在 95 分以上的学生信息,包括学号、姓名、专业。 (5) 2、 检索没有任何一门课程成绩在 80 分以下的所有学生信息,包括学号、姓名、专业。(5) 3、 对成绩得过满分(100 分)的学生,如果没有获得奖学金的,将其奖学金设为 1000 元。(5) 4、 定义学生成绩得过满分(100 分)的课程视图 vwAAA,包括课程号、名称和学分。(5) 2.5 用 java 实现快速排序算法。(5)
分享到:
收藏