一、选择题(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
4) Interfaces are the Java approach to addressing its lack of multiple inheritance, but require implementing classes to create the functionality of the Interfaces.
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
3) The default type for a numerical literal with decimal component is a float.
4) You can modify the value in an Instance of the Integer class with the setValue method
Question 3)
Which of the following are true statements?
1) I/O in Java can only be performed using the Listener classes
2) The RandomAccessFile class allows you to move directly to any point a file.
3) The creation of a named instance of the File class creates a matching file in the underlying operating system only when the close method is called.
4) The characteristics of an instance of the File class such as the directory separator, depend on the 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?
1) The automatic garbage collection of the JVM prevents programs from ever running outof memory
2) A program can suggest that garbage collection be performed but not force it
3) Garbage collection is platform independent
4) An object becomes eligible for garbage collection when all references denoting it are set to null.
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 need to read in the lines of a large text file containing tens of megabytes of data. Which of the following would be most suitable for reading in such a 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)
Which statement is true?
1)An anonymous inner class may be declared as final.
2)An anonymous inner class can be declared as private.
3)An anonymous inner class can implement multiple interfaces .
4)An anonymous inner class can access final variables in any enclosing scope.
5)Construction of an instance of a static inner class requires an instance of the enclosing outer class.
Question 14)
public class Foo{
public static void main(String sgf[]){
StringBuffer a = new StringBuffer(“A”);
StringBuffer b = new StringBuffer(“B”);
operate(a,b);
System.out.println(a+”,”+b); }
static void operate(StringBuffer x,StringBuffer y){
x.append(y);
y=x; }}
What is the result?
1)The code compiles and prints “A.B”.
2)The code compiles and prints “A.A”.
3)The code compiles and prints “B.B”.
4)The code compiles and prints “AB.B”.
5)The code compiles and prints “AB.AB”.
Question 15)
Which of the following thread state transitions are valid?
1) From ready to running.
2) From running to ready.
3) From running to waiting.
4) From waiting to running.
5) From waiting to ready.
6) From ready to waiting.
Question 16)
What is the result of attempting to compile and run the following program?
public class Test {
private int i = j;
private int j = 10;
public static void main(String args[]) {
System.out.println((new Test()).i);
}
}
1) Compiler error complaining about access restriction of private variables of Test.
2) Compiler error complaining about forward referencing.
3) No error – The output is 0;
4) No error – The output is 10;
Question 17)
Which two cannot directly cause a thread to stop executing?
1)exiting from a synchronized block
2)calling the wait method on an object
3)calling the notify method on an object
4)calling a read method on an InputStream object
5)calling the 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); // This is listener registration
setSize(300, 300);
setVisible(true); }
public void windowClosing(WindowEvent e) {
System.exit(0); }
public static void main(String args[]) {
CloseWindow CW = new CloseWindow(); } }
1) Compile time error
2) Run time error
3) Code compiles but frames does not listen to WindowEvents
4) Compile and runs successfully
Question 19)
Which statements describe guaranteed behavior of the garbage collection and finalization mechanisms?
1) Objects are deleted when they can no longer be accessed through any reference.
2) The finalize() method will eventually be called on every object.
3) The finalize() method will never be called more than once on an object.
4) An object will not be garbage collected as long as it is possible for an active part of the program to access it through a reference.
5) The garbage collector will use a mark and sweep algorithm.
Question 20)
A class design requires that a member variable should be accessible only by same package,which modifer word should be used?
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)
2.6 RuntimeException与Exception的区别,并列举你所知道的RuntimeException类。(5)
2.7 ArrayList和Vector,HashMap,Hashtable哪些是线程安全的。HashMap和Hashtable哪个可以用null作为key和value。(5)
2.8 抽象类与接口的相同与不同的描述?(5)
2.9 请把”ab”,”ef”,”cd”,”ij”,”gh”这5个字符串按给定的顺序加入到一个List对象,然后对该List对象进行快速排序,并打印结果(用java代码实现)。(5)
2.10 拷贝c:temp.txt文件为c:temp2.txt文件(用java代码实现)(5)
2.11 JNDI的全称是什么,简单描述它的用途。(5)
2.12 JDBC中Statement和PreparedStatement有什么不同?简要说明PreparedStatement对性能的影响(5)
2.13 请完成程序,查询table1表中field1字段的值是1的纪录,并将查询结果定位到查询结果中的第三行并打印第三行的vcField的值,field1字段类型是number(用java代码实现)。 (5)
2.14 线程有哪两种实现方法? (5)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)