选择题
1: Consider the class hierarchy shown below:
——————————————————————–
class FourWheeler implements DrivingUtilities
class Car extends FourWheeler
class Truck extends FourWheeler
class Bus extends FourWheeler
class Crane extends FourWheeler
———————————————————————-
Consider the following code below:
1.DrivingUtilities du;
2.FourWheeler fw;
3.Truck myTruck = new Truck();
4.du = (DrivingUtilities)myTruck;
5.fw = new Crane();
6.fw = du;
Which of the statements below are true?
Choices:
A.Line 4 will not compile because an interface cannot refer to an object.
B.The code will compile and run.
C.The code will not compile without an explicit cast at line 6, because going down the hierarchy without casting is not allowed.
D.The code will compile if we put an explicit cast at line 6 but will throw an exception at runtime. 2:Which method you define as the starting point of new thread in a class from which new the thread can be excution?
A.public void start()
B.public void run()
C.public void runnable()
D.public static void main(String args[]) 3:Give the following java class: public class Example{
public static void main(String args[]){ static int x[] = new int[15];
System.out.println(x[5]); }
} Which statement is corrected?
Give the following java class:
public class Example{
public static void main(String args[]){
static int x[] = new int[15];
System.out.println(x[5]);
}
}
Which statement is corrected?
A.When compile, some error will occur.
B.When run, some error will occur.
C.Output is zero.
D.Output is null. 4:Math.round(11.5)等於多少?
A.11
B.12
C.11.5
D.none 5:在下述选项时,没有构成死循环的程序是
A.int i=100 while (1) { i=i%100+1; if (i>100) break; }
B.for (;;);
C.int k=1000; do { ++k; }while(k>=10000);
D.int s=36; while (s);–s; 6:Which is the most appropriate code snippet that can be inserted at line 18 in the following code?
(Assume that the code is compiled and run with assertions enabled)
1. import java.util.*;
2.
3. public class AssertTest
4. {
5. private HashMap cctld;
6.
7. public AssertTest()
8. {
9. cctld = new HashMap();
10. cctld.put(“in”, “India”);
11. cctld.put(“uk”, “United Kingdom”);
12. cctld.put(“au”, “Australia”);
13. // more code…
14. }
15. // other methods ….
16. public String getCountry(String countryCode)
17. {
18. // What should be inserted here?
19. String country = (String)cctld.get(countryCode);
20. return country;
21. }
22. }
Which is the most appropriate code snippet that can be inserted at line 18 in the following code?
(Assume that the code is compiled and run with assertions enabled)
1. import java.util.*;
2.
3. public class AssertTest
4. {
5. private HashMap cctld;
6.
7. public AssertTest()
8. {
9. cctld = new HashMap();
10. cctld.put(“in”, “India”);
11. cctld.put(“uk”, “United Kingdom”);
12. cctld.put(“au”, “Australia”);
13. // more code…
14. }
15. // other methods ….
16. public String getCountry(String countryCode)
17. {
18. // What should be inserted here?
19. String country = (String)cctld.get(countryCode);
20. return country;
21. }
22. }A.assert countryCode != null;
B.assert countryCode != null : “Country code can not be null” ;
C.assert cctld != null : “No country code data is available”;
D.assert cctld : “No country code data is available”; 7:给出下面的代码片断。。。下面的哪些陈述为错误的? 1) public void create() {
2) Vector myVect; 3) myVect = new Vector();
4) }
给出下面的代码片断。。。下面的哪些陈述为错误的?
1) public void create() {
2) Vector myVect;
3) myVect = new Vector();
4) }A.第二行的声明不会为变量myVect分配内存空间。
B.第二行语句创建一个Vector类对象。
C.第三行语句创建一个Vector类对象。
D.第三行语句为一个Vector类对象分配内存空间 8:在软件生命周期中,下列哪个说法是不准确的?
A.软件生命周期分为计划、开发和运行三个阶段
B.在计划阶段要进行问题焉醛和需求分析
C.在开发后期要进行编写代码和软件测试
D.在运行阶段主要是进行软件维护 9:Given the following class definition: class A{
protected int i; A(int i){
this.i=i; }
} which of the following would be a valid inner class for this class?
Select valid answer:
Given the following class definition:
class A{
protected int i;
A(int i){
this.i=i;
}
}
which of the following would be a valid inner class for this class?
Select valid answer: A.class B{ }
B.class B extends A{ }
C.class B extends A{ B(){System.out.println(“i=”+i);} }
D.class B{ class A{} } 10:What will be printed when you execute the following code?
class X {
Y b = new Y(); X()
{ System.out.print(“X”);
} }
class Y
{ Y()
{ System.out.print(“Y”);
} }
public class Z extends X
{ Y y = new Y();
Z() {
System.out.print(“Z”); }
public static void main(String[] args) {
new Z(); }
}
Choices:
What will be printed when you execute the following code?
class X
{
Y b = new Y();
X()
{
System.out.print(“X”);
}
}
class Y
{
Y()
{
System.out.print(“Y”);
}
}
public class Z extends X
{
Y y = new Y();
Z()
{
System.out.print(“Z”);
}
public static void main(String[] args)
{
new Z();
}
}
Choices:
A.Z
B.YZ
C.XYZ
D.YXYZ 11:Give the following code: public class Example{
public static void main(String args[] ){ int l=0;
do{ System.out.println(“Doing it for l is:”+l);
}while(–l>0) System.out.println(“Finish”);
} }
Which well be output:
Give the following code:
public class Example{
public static void main(String args[] ){
int l=0;
do{
System.out.println(“Doing it for l is:”+l);
}while(–l>0)
System.out.println(“Finish”);
}
}
Which well be output: A.Doing it for l is 3
B.Doing it for l is 1
C.Doing it for l is 2
D.Doing it for l is 0 12:Use the operator “>>” and “>>>”. Which statement is true?
A.1010 0000 0000 0000 0000 0000 0000 0000 >> 4 give 0000 1010 0000 0000 0000 0000 0000 0000
B.1010 0000 0000 0000 0000 0000 0000 0000 >> 4 give 1111 1010 0000 0000 0000 0000 0000 0000
C.1010 0000 0000 0000 0000 0000 0000 0000 >>> 4 give 0000 0000 0000 0000 0000 0000 0000 0000
D.1010 0000 0000 0000 0000 0000 0000 0000 >>> 4 give 1111 1010 0000 0000 0000 0000 0000 0000 13:What will happen when you attempt to compile and run the following code?
int Output = 10;
boolean b1 = false;
if((b1 == true) && ((Output += 10) == 20))
{
System.out.println(“We are equal ” + Output);
}
else
{
System.out.println(“Not equal! ” + Output);
}
Choices:
What will happen when you attempt to compile and run the following code?
int Output = 10;
boolean b1 = false;
if((b1 == true) && ((Output += 10) == 20))
{
System.out.println(“We are equal ” + Output);
}
else
{
System.out.println(“Not equal! ” + Output);
}
Choices:A.Compilation error, attempting to perform binary comparison on logical data type
B.Compilation and output of “We are equal 10”.
C.Compilation and output of “Not equal! 20”.
D.Compilation and output of “Not equal! 10”. 14:Which statements about Java code security are not true?
A.The bytecode verifier loads all classes needed for the execution of a program.
B.Executing code is performed by the runtime interpreter.
C.At runtime the bytecodes are loaded, checked and run in an interpreter.
D.The class loader adds security by separating the namespaces for the classes of the local file system from those imported from network sources. 15:下述程序代码中有语法错误的行是( )。 int i,ia[10],ib[10]; /*第一行*/
for (i=0;i<=9;i++) /*第2行*/ ia[i]=0; /*第3行*/
ib=ia; /*第4行*/
下述程序代码中有语法错误的行是( )。
int i,ia[10],ib[10]; /*第一行*/
for (i=0;i<=9;i++) /*第2行*/
ia[i]=0; /*第3行*/
ib=ia; /*第4行*/A.第1行
B.第2行
C.第3行
D.第4行
简答题
16:struts2中转换器的实现原理?
17:编写子函数:(1)用冒泡法将一个数组排成升序的函数---SUB1;(2)在升序数组中插入一个数,并且保持该数组仍为升序数组的函数---SUB2。主函数:①输入任意10个正整数给数组;②调用SUB1对数组进行排序;③从键盘输入一个正整数,调用SUB2将其插入该数组。
18:输入三个字符串,把它们按字典排列依从小到大的顺序输出。例如输入:aec,adc,abc 三个字符串,它们按字典排列依从小到大的顺序输出为:abc,adc,aec。
19:spring中定义为Prototype作用域的bean,在什么时候会被spring销毁?
20:Java中的异常处理机制的简单原理和应用。
21:如何判别一个数是unsigned。
22:hibernate中,一个操作单元的范围是多大?
23:tomcat中,什么是DefaultServlet?他的功能是什么?
24:应用服务器与WEB SERVER的区别?
25:Set里的元素是不能重复的,那么用什么方法来区分重复与否呢?
26:With tomcat,Show me a simple cluster configuration example。
评论列表
文章目录