1:
What results from attempting to compile and run the following code?
public class Ternary
{
public static void main(String args[])
{
int a = 5;
System.out.println("Value is - " + ((a < 5) ? 9.9 : 9));
}
}
Choices:
A.prints: Value is - 9
B.Compilation error
C. prints: Value is - 5
D.None of these
2: Which of the following statements are true?
A.The automatic garbage collection of the JVM prevents programs from ever running out of memory
B.A program can suggest that garbage collection be performed and force it
C.Garbage collection is platform independent
D.An object becomes eligible for garbage collection when all references denoting it are set to null.
3:public class Parent {
int change() {…}
}
class Child extends Parent {
}
Which methods can be added into class Child?
A.public int change(){}
B.abstract int chang(){}
C.private int change(){}
D.none
4:Which of the following statements are not legal?
A.long l = 4990;
B.int i = 4L;
C.double d = 34.4;
D.double t = 0.9F.
5:软件生命周期的瀑布模型把软件项目分为3个阶段、8个子阶段,以下哪一个是正常的开发顺序?
A.计划阶段、开发阶段、运行阶段
B.设计阶段、开发阶段、编码阶段
C.设计阶段、编码阶段、维护阶段
D.计划阶段、编码阶段、测试阶段
6:
What will be the result of executing the following code?
// Filename; SuperclassX.java
package packageX;
public class SuperclassX
{
protected void superclassMethodX()
{
}
int superclassVarX;
}
// Filename SubclassY.java
1.package packageX.packageY;
2.
3.public class SubclassY extends SuperclassX
4.{
5.SuperclassX objX = new SubclassY();
6.SubclassY objY = new SubclassY();
7.void subclassMethodY()
8.{
9.objY.superclassMethodX();
10.int i;
11.i = objY.superclassVarX;
12.}
13.}
Choices:
A.Compilation error at line 5
B.Compilation error at line 9
C.Runtime exception at line 11
D.None of these
7:A class design requires that a particular member variable must be accessible for direct access by any subclasses of this class. but otherwise not by classes which are not members of the same package. What should be done to achieve this?
A.The variable should be marked public
B.The variable should be marked private
C.The variable should be marked protected
D.The variable should have no special access modifier
8:Math.round(11.5)等於多少?
A.11
B.12
C.11.5
D.none
9:
What is the result when you compile and run the following code?
public class Test
{
public void method()
{
for(int i = 0; i < 3; i++)
{
System.out.print(i);
}
System.out.print(i);
}
}
Choices:
A.0122
B.0123
C.Compilation error
D.None of these
10:
What happens when you try to compile and run the following program?
class Mystery{
String s;
public static void main(String[] args){
Mystery m=new Mystery();
m.go();
}
void Mystery(){
s=”constructor”;
}
void go(){
System.out.println(s);
}
}
A.this code compliles but throws an exception at runtime
B.this code runs but nothing appears in the standard output
C.this code runs and “constructor” in the standard output
D.this code runs and writes ”null” in the standard output
11:在下述选项时,没有构成死循环的程序是
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;
12:
What is the result when you compile and run the following code?
public class ThrowsDemo
{
static void throwMethod()
{
System.out.println("Inside throwMethod.");
throw new IllegalAccessException("demo");
}
public static void main(String args[])
{
try
{
throwMethod();
}
catch (IllegalAccessException e)
{
System.out.println("Caught " + e);
}
}
}
Choices:
A.Compilation error
B.Runtime error
C.Compile successfully, nothing is printed.
D.Inside throwMethod. followed by caught:java.lang.IllegalAccessExcption: demo
13: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.
14:Which statement about the garbage collection mechanism are true?
A.Garbage collection require additional programe code in cases where multiple threads are running.
B.The programmer can indicate that a reference through a local variable is no longer of interest.
C.The programmer has a mechanism that explicity and immediately frees the memory used by Java objects.
D.The garbage collection mechanism can free the memory used by Java Object at explection time.
15:
下述程序代码中有语法错误的行是( )。
int i,ia[10],ib[10]; /*{dy}行*/
for (i=0;i<=9;i++) /*第2行*/
ia[i]=0; /*第3行*/
ib=ia; /*第4行*/
A.第1行
B.第2行
C.第3行
D.第4行
16:
What will happen when you attempt to compile and run the following code?
class Base
{
int i = 99;
public void amethod()
{
System.out.println("Base.amethod()");
}
Base()
{
amethod();
}
}
public class Derived extends Base
{
int i = -1;
public static void main(String argv[])
{
Base b = new Derived();
System.out.println(b.i);
b.amethod();
}
public void amethod()
{
System.out.println("Derived.amethod()");
}
}
Choices:
A.Derived.amethod() -1 Derived.amethod()
B.Derived.amethod() 99
C.Compile time error
D.Derived.amethod()
17:在软件生命周期中,下列哪个说法是不准确的?
A.软件生命周期分为计划、开发和运行三个阶段
B.在计划阶段要进行问题焉醛和需求分析
C.在开发后期要进行编写代码和软件测试
D.在运行阶段主要是进行软件维护
18:
public class X{
public Object m(){
Object o = new Float(3.14F);//line 3
Object [] oa = new Object[1];//line 4
oa[0] = o;//line 5
o=null;//line 6
return oa[0];//line 7
}
}
When is the Float object, created in line 3,eligible for garbage collection?
A.just after line 5.
B.just after line 6
C.just after line 7(that is,as the method returns)
D.never in this method
19: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[])
20:
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
简答题
21:作用域public,private,protected,以及不写时的区别。
22:在hibernate中,一个持久化的实例有哪几种状态?
23:任何一个自然数m的立方均可写成m个连续奇数之和。例如:
1^3=1
2^3=3+5
3^3=7+9+11
4^3=13+15+17+19
编程实现:输入一自然数n,求组成n3的n个连续奇数。
24:Java 的通信编程,编程题(或问答),用JAVA SOCKET编程,读服务器几个字符,再写入本地显示?
25:用 100 元钱买 100 支笔,其中钢笔 3 元 / 支,圆珠笔 2 元 / 支,铅笔 0.5 元 / 支,问钢笔、圆珠笔和铅笔可以各买多少支 ?
26:lucene的底层数据结构。
27:使用tomcat部署应用程序 遇到过java.lang.OutOfMemoryError 吗?如何解决的。
28:编写一个在二叉排序树中查找大小为第k的元素的算法。
29:应用服务器与WEB SERVER的区别?
30:硬盘文件系统设计,及磁盘整理算法。
文章来源:笔试网 www.bishiwang.com—专业的笔试、面试资料搜索网站 |