第一篇:Java程序员岗前测试
软件企业程序员入职参考测试题
班级_________
姓名_________(共61题,对52%即通过,时间61分钟)1 下列哪些是JAVA语言中合法的标识符:
A
fieldname B
super C
3number D #number E $number 下面那些是JAVA的关键字:
A final B Abstract C
Long D
static 下面代码会输出什么结果:
public class Test{ public static void main(String[] args){
Test o = new Test();
o.amethod();} public void amethod(){ int oi = 012;System.out.println(oi);} } A B 012 C D 10.0 在编译和运行下面代码时会发生什么:
public class Test{ public static void main(String[] args){
int[] i = new int[5];
System.out.println(i[5]);} } A 编译错误 B 运行时错误 C 输出0 D 输出“null” 下列哪些数组的声明或初始化是正确的:
A
String srt[];B String str[5] = new String[5];
C String str[] =
new
String[]{“s1”,”s2”,”s3”,”s4”,”s5”};
D String str[] = {“s1”,”s2”,”s3”,”s4”,”s5”};下列代码会输出什么:
public class Test{ static int j =20;public static void main(String[] args){
int i =10;
Test p =new Test();p.amethod(i);System.out.println(i);System.out.println(j);}
public void amethod(int x){ x=x*2;j=j*2;} } A
编译错误 B 20 和 40 C 10 和 40 D 10 和 20 编译和运行以下代码会发生什么:
public class Test{
public static void main(String[] args){
System.out.println(5 | 7);} }
A 编译错误 B 运行期异常 C 输出5 D 输出7 E 输出2 下列哪个语句是错误的:
A
float f = 11.1;
B double d = 5.3E12;C double d = 3.14159;D double d = 3.14D;下面代码会输出什么:
int i = 16;int j = 17;
System.out.println(i >> 1);System.out.println(j >> 1);A 8和8 B 7和7 C 8和9 D 7和8 10 以下代码会输出什么:
System.out.println(010 | 4);A 14 B 0 C 6 D 12 请看下列代码:
String s = “hello”;String t = “hello”;
Char c[] = {„h‟,‟e‟,‟l‟,‟l‟,‟o‟};选项中哪些返回true: A s.equals(t);B t.equals(c);C s == t;D t.equals(new String(“hello”));E t == c;请看下列代码:
class Test{ public static void main(String[] args){
int s = 10;
s >>= 10;
System.out.println(“s=” + s);
} } 选择正确的答案: A 编译错误 B 运行错误 C 0 D 1 请看以下代码:
public static void main(String[] args){ Float f = new Float(4.2f);Float c;Double d = new Double(4.2);float f1 = 4.2f;c = f;} 下列哪些是正确的: A f.equals(d);B c == f;C c == d;D c.equals(f);下面的代码哪些是正确的定义了一个抽象类:
A class Test{
abstract void grow1();} B abstract Test{
abstract void grow1();
} C class abstract Test{ abstract void grow1();} D abstract class Test{ abstract void grow1();} E abstract class Test{ abstract void grow1(){ }
} 下面哪些是JAVA中合法的修饰符:
A private B public C protected D protect E
friend 编译和运行以下代码时会发生什么:
public class Test{ private int i;public static void main(String[] args){
Test s = new Test();
s.amethod();
}
public static void amethod(){ System.out.println(i);} }
A 输出0 B 没有输出 C 编译错误 D 运行错误 试图编译和运行以下代码时会发生什么:
class Test{ protected int i=99;}
public class Ab{ private int i = 1;public static void main(String[] args){ Ab a = new Ab();a.hallow();} abstract void hallow(){ System.out.println(i);} } A 编译错误
B 编译通过并输出99 C 编译通过并输出1 D 编译通过但运行时没有输出 试图编译和在控制台上输入java Test hello there运行以下代码时会发生什么: public class Test{ String[] myArg;public static void main(String[] args){
myArg = args;} public void amethod(){ System.out.println(args[1]);} } A 编译错误
B 编译通过并输出hello C 编译通过并输出there D 以上都不对 以下代码有什么错误?选出所有正确的答案:
final class Test{ private int a = 1;int b = 2;} class Second extends Test{ public void method(){ System.out.println(a + b);} } A println方法应该传入String类型的参数
B a是私有的,所以除了Test类以外别的类不能访问
C Second不能继承Test D
final不是一个关键字下列哪些选项可以放置在×××处:
public class OuterClass{ private String s = “I am outer class member variable”;
class InnerClass{
private String s1 = “I am inner class variable”;
public void innerMethod(){
System.out.println(s);
System.out.println(s1);}
} //inner class
public static void outerMethod(){
//×××
inner.innerMethod();}
}//outerclass
A OuterClass.InnerClass inner = new OuterClass().new InnerClass();
B InnerClass inner = new InnerClass();C new InnerClass();D 以上选项都不对编译和运行以下代码会发生什么:
public class Test{ public static void main(String[] args){
Test h = new Test();}
protected Test(){ for(int i=0;i<10;i++){
System.out.println(i);
} } }
A 编译错误:构造方法不能声明成protected B 运行时错误:构造方法不能声明成protected C 编译通过并输出0到10 D 编译通过并输出0到9 编译和运行以下代码会发生什么:
class Test{ public static void main(String[] args){ try{
byte x = 5;
byte y = x *2;System.out.println(y);}catch(Exception e){ System.out.println(“exception”);}//catch }//main }//class Test A 编译错误
B 输出exception C 5 D 10 E 15 F 20 G 25 下列哪些语句在编译时不会有警告或错误:
A float f = 1.3;B char c = “a”;C byte b = 257;D boolean b = null;E int i = 10;一个类中带有一个成员变量,如果不希望这个成员变量被除了自己之外的其他任何类访问,那么这个变量应该使用哪个修饰符修饰: A private B public C transient D final E abstract 一个整型变量x的二进制值为:1001 1100,如下语句执行之后z的值是: int y = 1 << 7;int z = x & y;A 1000 0001 B 1000 0000 C 0000 0001 D 1001 1101 E 1001 1100 下面程序运行的时候将会产生哪些输出:
public class Test {
public static void main(String args[]){
double d =-2.9;
int i =(int)d;
i *=(int)Math.ceil(d);
i *=(int)Math.abs(d);
System.out.println(i);
} }
A 12 B 18 C 8 D 12 E 27 请看下面的代码:
void looper(){
int x = 0;
one:
while(x < 10){
two:
System.out.println(++x);
if(x > 3)
break two;
} }
选择所有有效的答案:
A 代码编译成功 B 代码编译错误
C 代码执行后将会打印处数字0 D 将会打印数字1和2 E 将会打印数字3
看下面的代码,将会打印出什么结果:
int m = 0;
while(m++ < 2)
System.out.println(m);
A 0 B 1 C 2 D 3
E 什么都没有,而且会产生一个异常错误 29 查看如下申明:
char[] c = new char[100];c[50]的内容是什么: A 50 B 49 C 'u0000' D 'u0020' E 在赋值之前是null 以下代码的输出结果是什么:
Boolean b1 = new Boolean(true);Boolean b2 = new Boolean(true);if(b1 == b2)
if(b1.equals(b2))
System.out.println(“a”);
else
System.out.println(“b”);
else
if(b1.equals(b2))
System.out.println(“c”);
else
System.out.println(“d”);
选出正确的答案: A a B b C c D d
给出以下代码:
switch(m){ case 0:System.out.println(“0”);break;case 1:System.out.println(“1”);break;case 2:System.out.println(“2”);break;case 3:System.out.println(“3”);
break;default:System.out.println(“other”);}
当m是何值时会输出2,选出所有可能的答案:A 0 B 1 C 2 D 3 E 4 F 以上都不对
参考以下代码块
outer: for(int i = 1;i <3;i++)
{ inner: for(j = 1;j < 3;j++)
{ if(j==2)
continue outer;
System.out.println(“i = ” +i “, j = ” + j);
}
}
下列哪些会被输出到控制台 A i = 1, j = 1 B i = 1, j = 2 C i = 1, j = 3 D i = 2, j = 1 E i = 2, j = 2
查看以下代码:
class Test{ public static void main(String[] args){
try{
return;
}catch(Exception e){
System.out.println(“Exception”);
}finally{ System.out.println(“Finally”);} } }
会发生什么:
A 编译错误,main方法不能返回任何值 B 打印出“Exception”
C 打印出“Exception”和“Finally” D 打印出“Finally”
如果s1的定义为:String s1 = “phenobarbital”;
那么执行如下代码后s2的值是什么: String s2 = s1.substring(3, 5);A null B “eno” C “enoba” D “no”
看如下代码:
class A {}
class B extends A {} class C extends A {} public class Q3ae4 {
public static void main(String args[]){
A x = new A();
B y = new B();
C z = new C();
// insert statement here
} } 在insert statement here处插入如下选项中的代码,哪些代码会引起程序运行产生runtime异常: A x = y;B z = x;; C y =(B)x。D z =(C)y;; E y =(A)y;;
查看如下代码:
1: public void aMethod { 2: 3:
if(Condition){ 4:
5:
} 6: 7: } 如果上面代码中的Condition为true应该抛出MyException类型的异常,那么哪些答案的描述是正确的:
A在第4行添加throw new Exception();
B在第4行添加throws new MyException()。C在第6行添加throw new MyException(); D在第2行添加throws new Exception(); E 在第1行添加throws MyException
译和运行以下代码时会发生什么:
public class Test{
static void throwMethod(){
System.out.println(“inside ThrowMethod”);
throw new IllegalAccessException(“demo”);
} //throwMethod public static void main(String[] args){ try{
throwMethod();}catch(IllegalAccessException e){ System.out.println(“Caught “ + e);
}//catch }//main }
选出正确的答案 A 编译错误。B 运行时错误
C 编译通过,但没输出
D 输出Inside throwMethod 接着输出caught: java.lang.IllegalAccessException:demo
给出以下代码:
public static void main(String[] args){ int i = 1;int j = 10;
do{ if(i >j)
continue;
j--;}while(++i < 6);
System.out.println(“i=” +i+” j=” + j);
}//main
下列哪些会被输出: A i=4 j=5 B i=5 j=6 C i=5 j=5 D i=4 j=6 E i=6 j=5
39当运行下面程序时会发生什么: class Tester{ int var;Tester(double var){
this.var =(int)var;
}
Tester(int var){ this(“hello”);}
Tester(String s){ this();System.out.println(s);}
Tester(){ System.out.println(“good-bye”);}
public static void main(String[] args){ Tester t = new Tester(5);} }
选出所有正确答案 A 没有任何输出 B 输出“hello” C 输出5 D 输出“hello”和”good-bye” E 输出“good-bye”和”hello”
40给出下列代码 public class Base{ int w,x,y,z;public Base(int a,int b){
x = a;
y = b;} public Base(int a,int b,int c,int d){ //设置x = a;y = b w =d;z =c;} } 在//设置x = a;y = b处可以添加什么代码,选出所有正确的答案:
A Base(a,b);B x =a,y =b;C x =a;y=b;D this(a,b);41 如果你试图编译以下代码并执行B类中的main方法时会发生什么,选择唯一的正确答案
class A {
int i;
A(int i){
this.i = i * 2;
} }
class B extends A {
public static void main(String[] args){
B b = new B(2);
}
B(int i){
System.out.println(i);
} } A 实例变量i被设置为4 B 实例变量i被设置为2 C 实例变量i被设置为0
D 编译出错
42编译和运行以下代码会发生什么
1.class A {
2.public int i=5;
3.A(int initi){ i = initi;}
4.public static void main(String[] args){ 5.final A theA = new A(10);6.theA.i = 15;
7.System.out.println(theA.i);8.} 9.}
A 第六行编译出错 B 程序输出”5”;C 程序输出”10”;D 程序输出”15”;
43关于try、catch、finally块,下列描述正确的是:
A try块后面必须总是跟着catch块
B try块后面可以跟catch块或者finally块,也可以两者都有。
C catch必须总是和try块关联。
D 如果没有try块的话,finally块永远不可以单独出现。
E 上面没有一个是正确的
44查看下面的代码,编译个运行该代码将会产生什么结果:
public static void main(String args[]){ int a = 5;
System.out.println(cube(a));}
int cube(int theNum){
return theNum * theNum * theNum;}
A 因为cube在java.lang.Math类中已经定义了,所以编译错误
B 因为cube不是静态类型的,所以编译错误。C 编译成功,但是会抛出算术异常 正常运行,打印出”125”
D 正常运行,打印出”125”
45定义一个八进制的值17,下面哪些方法是正确的:
A private final int theNumber = 0x17;B private final int theNumber = 017;C public int theNumber = 017;
D public int theNumber =(octal)17;E
public int THE_NUMBER = 017;
给定如下接口:
interface A {
int method1(int i);
int method2(int j);} 下面哪些类实现了这个接口而且不是抽象类: A class B implements A {
int method1(){ }
int method2(){ } }
B class B {
int method1(int i){ }
int method2(int j){ } }
C class B implements A {
int method1(int i){ }
int method2(int j){ } }。
D class B extends A {
int method1(int i){ }
int method2(int j){ } }
E class B implements A {
int method2(int j){ }
int method1(int i){ } }。
编译和运行以下代码时会发生什么:
class Mystery{
String s;
public static void main(String[] args){
Mystery m = new Mystery();
m.go();}//main void Mystery(){ s = “constructor”;} void go(){ System.out.println(s);} }//Mystery 选出正确答案 A 编译错误
B 运行时抛出异常 C 运行时没有任何输出 D 运行时输出”constructor” E 运行时输出”null”
48编译以下代码时会发生什么错误:
class A{ private int x;public static void main(String[] args){
new B();}
class B{ B(){
System.out.println(x);
} } }
A 类B试图访问它外部类A里面的私有变量
B 类A在没有创建A的实例前试图创建一个类B的实例。
C 类B的构造方法必须被申明成public
49试图编译和运行以下代码时会发生什么
1.class Fish { }
2.class Shark extends Fish { } 3.class Guppy extends Fish { } 4.5.public class Ocean {
6.public static void main(String[] args){ 7.Fish f = new Shark();8.Guppy g =(Guppy)f;9.}
10.}
A 第七行编译出错.B 第八行编译出错
C
第七行运行时抛出异常 D
第八行运行时抛出异常 E
程序正确运行
如果下面的代码段被成功编译和执行,将会显示什么结果:
class Test{
public static void main(String [] args){
Base b = new Subclass();
System.out.println(b.x);
System.out.println(b.method());
} } class Base{
int x = 2;
int method(){
return x;
} }
class Subclass extends Base{
int x = 3;
int method(){
return x;
} }
A 什么都没有,因为对象b没有使用正确的方法构造对象,所以代码编译错误 B 2 3。C 2 2 D 3 3 E 3 2
51下面哪些方法申明能够被放在注释处,选出所有正确的答案
class Base{ public void aMethod(int i){} } public class Scope extends Base{ public static void main(String[] args){} //注释 } A void aMethod(int i)throws Exception{} B void aMethod(long i)throws Exception{} C void aMethod(long i){} D public void aMethod(int i)throws Exception
52给出以下代码:
public class Test{ public static void test(){
this.print();} public static void print(){ System.out.println(“Test”);}
public static void main(String[] args){ test();}
}
编译和运行这个类时会发生什么: A 输出Test
B 运行时异常,因为对象没有创建出来 C 没有任何输出
D 运行时异常,因为找不到test方法
E 运行时异常,因为this变量只能在一个实例中使用
F 编译错误,因为在test方法中使用this变量。
53给出以下代码:
class Happy{ public int getLength(){
System.out.println(“int version”);
return 1;} }
class Life extends Happy{ public long getLength(){
System.out.println(“long version”);
return 1;}
public static void main(String[] args){ Happy e = new Life();e.getLength();} }
下列正确的是: A 输出int version B 输出 long version C 编译错误 D 运行期异常 E 没有输出
查看下面的代码:
class Tree{}
class Pine extends Tree{} class Oak extends Tree{} public class Forest
{ public static void main(String[] args)
{ Tree tree = new Pine();
if(tree instanceof Pine)
System.out.println(“Pine”);
if(tree instanceof Tree)
System.out.println(“Tree”);
if(tree instanceof Oak)
System.out.println(“Oak”);
else System.out.println(“Oops”);
} } 选择所有会被打印出来的内容: A Pine。B Tree。C Forest D Oops。
E 没有打印任何内容
55什么情况下一个线程会停止执行
a)一个具有更高优先级的线程开始执行的时候 b)线程的wait方法被调用 c)线程的yield方法被调用 d)线程pause方法被调用 e)线程的sleep方法被调用
给定下面的类:
class Counter {
public int startHere = 1;
public int endHere = 100;
public static void main(String[] args){
new Counter().go();
}
void go(){
// A
Thread t = new Thread(a);
t.start();
} } 哪几个答案可以被放在//A处,使得程序执行的时候能够从startHere数到endHere: A.Runnable a = new Runnable(){
public void run(){
for(int i = startHere;i <= endHere;i++){
System.out.println(i);
}
} }。
B.a implements Runnable {
public void run(){
for(int i = startHere;i <= endHere;i++){
System.out.println(i);
}
} };
C.Thread a = new Thread(){
public void run(){
for(int i = startHere;i <= endHere;i++){
System.out.println(i);
}
} }。
57试图编译和运行以下代码时会发生什么? class Test implements Runnable{ int i = 0;public int run(){
while(true){
i++;System.out.println(“i=”+i);
} } }
选出正确的答案
A 编译成功,run方法打印出i的值
B 编译成功,调用start方法后打印出i的值 C 编译错误
D 编译错误,因为while的参数不能是true
给出下面代码,会输出什么结果? class ValHold{ public int i = 10;}
public class ObParm{
public static void main(String argv[]){ ObParm o = new ObParm();o.amethod();}
public void amethod(){ int i = 99;
ValHold v = new ValHold();v.i=30;
another(v,i);
System.out.println(v.i);}//End of amethod public void another(ValHold v, int i){ i=0;v.i = 20;ValHold vh = new ValHold();v = vh;System.out.println(v.i+ “ ”+i);}//End of another } A 10,0, 30 B 20,0,30 C 20,99,30 D 10,0,20
public class test{ private static int j = 0;private static boolean methodB(int k){
j += k;
return true;
} public static void methodA(int i){
boolean b;
b = i < 10 | methodB(4);
b = i < 10 | methodB(8);} public static void main(String[] args){ methodA(0);System.out.println(j);} }
编译和运行时会发生什么?
A 输出“0” B 输出 “4” C 输出 “8” D 输出 “12” E 编译错误
class Test {
public static void main(String[] args){
Thread t = new Thread(new RunHandler());
t.start();
} } 下列选项中哪些是正确的:
A RunHandler 必须实现.Runnable接口 B RunHandler 必须继承Thread类
C
RunHandler必须提供一个run(),它的访问权限应该是public,返回类型是void
D RunHandler 必须提供一个init方法
61查看以下代码,编译和运行时会发生什么 public class Bground extends Thread{ public static void main(String argv[]){
Bground b = new Bground();
b.run();
}
public void start(){
for(int i = 0;i <10;i++){
System.out.println(“Value of i = ” + i);
}
} }
A 编译错误 B 运行错误
C 编译成功,输出0到9 D 编译成功,但没输出。
62在下面代码的注释处加入什么代码会输出“running” class Test implements Runnable{ public static void main(String[] args){
Test rt = new Test();
Thread t = new Thread(rt);//注释
}
public void run(){ System.out.println(“running”);}
void go(){ start(1);}
void start(int i){ } }
A System.out.println(“running”);B rt.start();C rt.go();D rt.start(1);
第二篇:JAVA程序员基本测试题目
PART 1: The essential of java 1.Given the following code, what test would you need to put in place of the comment line? //place test here to result in an output of the string Equal
public class EqTest{ public static void main(String argv[]){
EqTest e=new EqTest();
}
EqTest(){
String s=“Java”;
String s2=“java”;
//place test here {
System.out.println(“Equal”);
}else
{
System.out.println(“Not equal”);
}
} }
A)if(s==s2)B)if(s.equals(s2)C)if(s.equalsIgnoreCase(s2))D)if(s.noCaseMatch(s2))
2.Given the following code how could you invoke the Base constructor that will print out the string “base constructor”;
class Base{
Base(int i){ System.out.println(“base constructor”);
}
Base(){
} }
public class Sup extends Base{
public static void main(String argv[]){ Sup s= new Sup();//One
}
Sup()
{ //Two
}
public void derived()
{ //Three
} }
A.On the line After //One put Base(10);B.On the line After //One put super(10);C.On the line After //Two put super(10);D.On the line After //Three put super(10);
3.What is the value of seasons.length for the following array?
String[] seasons = {“winter”, “spring”, “summer”, “fall”, };
A.undefined
B.3
C.4
D.5
4.When you use the new keyword to create an object, where is it created? A.Heap
B.Garbage collector
C.Queue
D.Stack
5.What will happen if you attempt to compile and run the following code?
class Base {} class Sub extends Base {} class Sub2 extends Base {} public class CEx{
public static void main(String argv[]){ Base b=new Base();Sub s=(Sub)b;
} }
A.Compile and run without error B.Compile time Exception C.Runtime Exception
6.An overridden method can be in the same class.A.True
B.False
7.Given the following code
import java.io.*;public class Th{
public static void main(String argv[]){ Th t = new Th();t.amethod();
}
public void amethod(){ try{
ioCall();}catch(IOException ioe){}
} } What code would be most likely for the body of the ioCall method A.public void ioCall(){ DataInputStream din = new DataInputStream(System.in);din.readChar();}
B.public void ioCall()throw IOException{ DataInputStream din = new DataInputStream(System.in);din.readChar();} C.public void ioCall()throws IOException{ DataInputStream din = new DataInputStream(System.in);din.readChar();}
D.public void ioCall throws IOException(){ DataInputStream din = new DataInputStream(System.in);din.readChar();
}
8.How do you force the garbage collector to run? A.Call System.gc()
B.Call Runtime.gc()
C.Either A or B
D.There is nothing you can do
9.When multiple methods exist within the same class with different method signatures, this is known as what? A.Method overloading
B.Overriding methods
C.Message passing
D.A headache
10.What's printed when the following program is executed: class PrintMe {
public void do(int character){
System.out.println(character+character);
}
public static void main(String args[]){
new PrintMe().do('A');
} }
A.AA
B.130(The ASCII value of A is 65)
C.Does not compile
11.What will be printed out if you attempt to compile and run the following code?
int i=9;switch(i){ default: System.out.println(“default”);case 0: System.out.println(“zero”);break;case 1: System.out.println(“one”);case 2: System.out.println(“two”);}
A.default B.default, zero C.error default clause not defined D.no output displayed
12.What will be the result of attempting to compile and run the following code?
abstract class MineBase { abstract void amethod();static int i;} public class Mine extends MineBase { public static void main(String argv[]){ int[] ar=new int[5];for(i=0;i < ar.length;i++)System.out.println(ar[i]);} }
A.a sequence of 5 0's will be printed B.Error: ar is used before it is initialized C.Error: Mine must be declared abstract D.IndexOutOfBoundes Error
Part 2.The essential of jdbc 1.If you need to use a stored procedure with output parameters, which of the following statement type should be used to call the procedure?
A.Statement
B.PreparedStatement
C.CallableStatement
2.Which of the following will not cause a JDBC driver to be loaded and registered with the DriverManager?
A.Class.forName(driverString);
B.new DriverClass();
C.Include driver name in jdbc.drivers system property
D.None of the above 3.From which object do you ask for DatabaseMetaData?
A.Connection
B.ResultSet
C.DriverManager
D.Driver
4.If one intends to work with a ResultSet, which of these PreparedStatement methods will not work?
A.execute()
B.executeQuery()
C.executeUpdate()
5.Can a ResultSet be reliably returned from a method that creates a Statement and executes a query?
A.Yes
B.No
6.How can I use JDBC to create a database?
A.Include create=true at end of JDBC URL
B.Execute “CREATE DATABASE jGuru” SQL statement
C.Execute “STRSQL” and “CREATE COLLECTION jGuru” SQL statements
D.Database creation is DBMS specific
7.Which character is used to represent an input parameter in a CallableStatement?
A.%
B.*
C.?
D.#
8.Which one of the following will not get the data from the first column of ResultSet rs, returned from executing the following SQL statement: SELECT name, rank, serialNo FROM employee.A.rs.getString(0);
B.rs.getString(“name”);
C.rs.getString(1);
9.Which of the following can you do with a JDBC 2.0 database driver that you cannot with a JDBC 1.x driver?
A.Batch multiple statements, to be sent to the database together
B.Scroll through result sets bi-directionally
C.Work with SQL3 data types directly
D.All of the above
10.Which class contains the transaction control methods setAutoCommit, commit, and rollback?
A.Connection
B.Statement
C.ResultSet
Part 3.The essential of xml
1.There is a way of describing XML data, how?
A.XML uses XSL to describe data
B.XML uses a description node to describe data C.XML uses a DTD to describe the data.D.XML uses a SCHEMA to describe the data.2.What is the correct syntax of the declaration which defines the XML version?
A. B. C.
3.Which one is this a correct XML document? A.
第三篇:java程序员
如何迅速成为Java高手[Tomjava原创]
很多网友问我学习Java有没有什么捷径,我说“无他,唯手熟尔”。但是我却很愿意将自己学习的一些经验写出来,以便后来者少走弯路,帮助别人是最大的快乐嘛!
要想学好Java,首先要知道Java的大致分类。我们知道,自从Sun推出Java以来,就力图使之无所不包,所以Java发展到现在,按应用来分主要分为三大块:J2SE,J2ME和J2EE,这也就是Sun ONE(Open Net Environment)体系。J2SE就是Java2的标准版,主要用于桌面应用软件的编程;J2ME主要应用于嵌入是系统开发,如手机和PDA的编程;J2EE是Java2的企业版,主要用于分布式的网络程序的开发,如电子商务网站和ERP系统。J2SE开发桌面应用软件比起VC,VB,DEPHI这些传统开发语言来说,优势好象并不明显。J2ME对于初学者来说,好象又有点深奥,而且一般开发者很难有开发环境。所以现在应用最广泛又最好学的就是J2EE了。J2EE又包括许多组件,如Jsp,Servlet,JavaBean,EJB,JDBC,JavaMail等。要学习起来可不是一两天的事。
那么又该如何学习J2EE呢?当然Java语法得先看一看的,I/O包,Util包,Lang包你都熟悉了吗?然后再从JSP学起。如果你学过HTML,那么事情要好办的多,如果没有,那你快去补一补HTML基础吧。其实JSP中的Java语法也不多,它更象一个脚本语言,有点象ASP。然后你就该学一学Servlet了。Servlet就是服务器端小程序,他负责生成发送给客户端的HTML文件。JSP在执行时,也是先转换成Servlet再运行的。虽说JSP理论上可以完全取代Servlet,这也是SUN推出JSP的本意,可是Servlet用来控制流程跳转还是挺方便的,也令程序更清晰。接下来你应该学习一下Javabean了,可能你早就看不管JSP在HTML中嵌Java代码的混乱方式了,这种方式跟ASP又有什么区别呢?还好,SUN提供了Javabean可以把你的JSP中的Java代码封装起来,便于调用也便于重用。接着就是EJB了,EJB就是Enterprise JavaBean,看名字好象它是Javabean,可是它和Javabean还是有区别的。它是一个体系结构,你可以搭建更安全、更稳定的企业应用。它的大量代码已由中间件(也就是我们常听到的Weblogic,Websphere这些J2EE服务器)完成了,所以我们要做的程序代码量很少,大部分工作都在设计和配置中间件上。至于JDBC,就不用我多说了,你如果用java编过存取数据库的程序,就应该很熟悉。还有,如果你要用Java编发送电子邮件的程序,你就得看看Javamail了。
好了,对Java和J2EE有了一些基本概念之后,你就应该编一些程序了,千万不要纸上谈兵哦。最好找一些有实例且带光盘的书来看,这样看到好的程序就可以直接Ctrl+C再Ctrl+V,也不用劳您老大架再亲自把它再输一遍吧,再说直接复制还不用怕出错,何乐而不为呢!还有就是要经常上一些好的Java编程文章,有好的文章要Cut下来,有问题尽管问,只要问题不是太傻,一般高手都会回答你的。下面介绍几个好的Java方面的编程网站:
CSDN论坛 http:///那里Java资料比较全;
java.com.cnhttp://.cn/看这域名就知道有多牛,注册用户快接近一万了,同时在线人数也在一千左右,人气很旺的;
IBM的开发者网络http://IBM永远的蓝色巨人;
那么我书也看了,程序也做了,别人问我的问题我都能解决了,是不是就成为高手了呢?当然没那么简单,这只是万里长征走完了第一步。不信?那你出去接一个项目,你知道怎么下手吗,你知道怎么设计吗,你知道怎么组织人员进行开发吗?你现在脑子里除了一些散乱的代码之外,可能再没有别的东西了吧!你现在最缺的是实际的工作经验,而不是书本上那些
凭空想出来的程序。所以你快去找一份Java的编程工作来做吧(如果是在校学生可以去做兼职啊),在实践中提高自己,那才是最快的。不过你得祈祷在公司里碰到一个高手,而且他还愿意不厌其烦地教你,这样好象有点难哦!
还有一个办法就是读开放源码的程序了。我们知道开放源码大都出自高手,他们设计合理,考虑周到,再加上有广大的程序员参与,代码的价值自然是字字珠叽,铿锵有力(对不起,偶最近《金装四大才子》看多了)。学Java必读的两个开源程序就是Jive和Pet Store.。Jive是国外一个非常著名的BBS程序,完全开放源码。论坛的设计采用了很多先进的技术,如Cache、用户认证、Filter、XML等,而且论坛完全屏蔽了对数据库的访问,可以很轻易的在不同数据库中移植。论坛还有方便的安装和管理程序,这是我们平时编程时容易忽略的一部份(中国程序员一般只注重编程的技术含量,却完全不考虑用户的感受,这就是我们与国外软件的差距所在)。Jive的资料在很多网站上都有,大家可以找来研究一下。相信你读完代码后,会有脱胎换骨的感觉。遗憾的是Jive从2.5以后就不再无条件的开放源代码,同时有licence限制。不过幸好还有中国一流的Java程序员关注它,外国人不开源了,中国人就不能开源吗?这里向大家推荐一个汉化的Jive版本—J道。Jive(J道版)是由中国Java界大名鼎鼎的banq在Jive 2.1版本基础上改编而成, 全中文,增加了一些实用功能,如贴图,用户头像和用户资料查询等,而且有一个开发团队在不断升级。你可以访问banq的网站http:///去下载,或到同济技术论坛的服务器上ftp://nro.shtdu.edu.cn去下,安装上有什么问题,可以到论坛上去提问。Pet Store.(宠物店)是SUN公司为了演示其J2EE编程规范而推出的开放源码的程序,应该很具有权威性,想学J2EE和EJB的朋友不要错过了。
你一定会高兴地说,哈哈,原来成为Java高手就这么简单啊!记得Tomjava也曾碰到过一个项目经理,号称Java很简单,只要三个月就可以学会。其实说这种话的人就如当年小日本号称“三个月拿下中国”一样大言不惭。不是Tomjava泼你冷水,你现在只是学到了Java的骨架,却还没有学到Java的精髓。接下来你得研究设计模式了。设计模式是高级程序员真正掌握面向对象核心思想的必修课。设计模式并不是一种具体“技术”,它讲述的是思想,它不仅仅展示了接口或抽象类在实际案例中的灵活应用和智慧,让你能够真正掌握接口或抽象类的应用,从而在原来的Java语言基础上跃进一步,更重要的是,设计模式反复向你强调一个宗旨:要让你的程序尽可能的可重用。关于设计模式的资料,还是向大家推荐banq的网站http:///,他把GOF的23种模式以通俗易懂的方式诠释出来,纯Java描述,真是经典中的经典。有时间再研究一下MVC结构(把Model-View-Control分离开的设计思想)吧,现在很流行的Structs就是它的一种实现方式,不过Structs用起来实在是很繁,我们只要学习其精髓即可,我们完全可以设计自己的MVC结构。然后你再研究一下软件Refactoring(重整)和极限XP编程,相信你又会上一个台阶。
做完这些,你不如整理一下你的Java代码,把那些经典的程序和常见的应用整理出来,再精心打造一番,提高其重用性和可扩展性。你再找几个志同道合的朋友成立一个工作室吧,你可以去承接一些项目做了,一开始可能有些困难,可是你有技术积累,又考虑周全,接下项目来可以迅速作完,相信大家以后都会来找你的,所以Money就哗啦啦的来了。。。当然你也可以参加一些开源项目,一方面可以提高自己,另一方面也是为中国软件事业做贡献嘛!开发者在互联网上用CVS合作开发,用QQ,MSN,E-mail讨论联系,天南海北的程序员分散在各地却同时开发同一个软件,是不是很有意思呢?
下面介绍两个好的开源项目网站:
湖北省软件公共开发平台http://gro.clinux.org/
共创联盟http://cosoft.org.cn/
哇,好高兴哦,我终于成为高手了!非也,非也。古人云:“识时务者为俊杰”。你知道计算
机界现在的发展形势吗?你知道微软的.NET蓝图和SUN ONE计划之间的明争暗斗吗?你知道计算机技术将向何处发展吗?其实从各大计算机厂商最近的动作,都可以看出来“Web服务将是下一代互联网应用的制高点”,而微软的.NET蓝图和SUN ONE计划的斗争焦点,也就是Web服务。Web服务就是一个崭新的分布式计算模型,它是一系列标准的综合(XML,SOAP,UDDI,WSDL和WSFL等)。它使得不同语言编写的软件能够轻易的集成起来,使网络资源和Web站点变成一种服务而不是混乱的垃圾场。不远的将来,我们就可以在家里点击一下鼠标,就可以完成出门旅游的全部准备工作,包括定飞机票,定旅游线路,定好房间等。请注意,这所有的一切都是Web站点间自动完成的,再也不用象现在一样,表面上是电子商务,实际上很多环节都是人工操作。也许你会觉得这是天方夜谈,不过就近的说,你也很有可能承接一个项目,要集成两个企业的ERP系统。很有可能上游企业的系统是用Dephi编的,而下游企业的系统是用Java编的。你说你是Java高手,大家都看者你怎么做呢。所以啊,你还得学习新技术,如Web服务,而且你Dephi也要懂一点吧(Dephi6现在已经提供Web服务的控件了)。你编的Java系统,可能要和.NET集成,所以你.NET要懂一点吧?到最后,你可能发现你已经成为Java高手了,但很多时间却在搞别的技术。太极张三丰里说,最厉害的招式就是没有招式,可能就是这个道理吧!
因为刚刚兴起,所以网上Web服务的资料不是很多,我还是给大家推荐几个网站吧: 中国UDDI技术联盟http:///developerWorks/cn/xml/index.shtml?csdnIBM可是Web服务的力推者
呜„你费劲千心万苦,总算成为Java高手了,怎叫人不由喜极而泣呢!是啊,真不容易,真不简单,真叫人感动啊!那么打个电话告诉我吧,什么?我的电话号码是多少?昏到,你打电话问不就知道了吗,真是的„„
第四篇:最新JAVA程序员面试试题及智力测试
JAVA程序员面试试题及智力测试Java
面试例题1:击鼠标比赛现在开始!参赛者有拉尔夫、威利和保罗。
拉尔夫10秒钟能击10下鼠标,威利20秒钟能击20下鼠标,保罗5秒钟能击5下鼠标。以上各人所用的时间是这样计算的:从第一击开始,到最后一击结束。
他们是否打平手?如果不是,谁最先击完40下鼠标?
解析:n秒钟击n下鼠标其实是击第一下鼠标时才开始计时的,实际上击n-1下需要n秒钟,那么若击40下鼠标,拉尔夫需要(40-1)/(9/10)=39/0.9秒,威利需要
(40-1)/(19/20)=39/0.95秒,保罗需要(40-1)/(4/5)=39/0.8秒,因此威利先击完。
答案:威利先击完。
面试例题2:100美元哪里去了?
3个朋友住进了一家宾馆。结账时,账单总计3 000美元。3个朋友每人分摊1 000美元,并把这3 000美元如数交给了服务员,委托他代到总台交账。但在交账时,正逢宾馆实施价格优惠,总台退还给服务员500美元,实收2 500美元。服务员从这500美元退款中扣下了200美元,只退还3个客人300美元。3个客人平分了这300美元,每人取回了100美元。这样,3个客人每人实际支付900美元,共支付2 700美元,加上服务员扣的200美元,共计2 900美元,那么这100美元的差额到哪里去了?
答案:这道题纯粹是文字游戏,但是如果你的头脑不够清晰,很可能把你搞糊涂了。客人实际支付2 700美元,就等于总台实际结收的2 500美元加上服务员克扣的200美元。在这2 700美元上加上200美元是毫无道理的,而在这2 700美元上加退回的300美元,这是有道理的,因为这等于客人原先交给服务员的3 000美元。
面试例题3:有一种小虫,每隔2秒钟分裂一次。分裂后的2只新的小虫经过2秒钟后又会分裂。如果最初某瓶中只有一只小虫,那么2秒后变2只,再过2秒后就变4只……2分钟后,正好满满一瓶小虫。假设这个瓶内最初放入2只这样的小虫。
问:经过多少时间后,正巧也是满满的一瓶?
答案:经过1分58秒时间,也正巧是满满一瓶。因为从一只虫蜕变为2只虫只需2秒钟。在瓶内只有一只虫子的情况下,经过2秒钟后就变成2只。这时的情况和瓶内一开始就有2只虫子的情况是一样的。出现这两种情况的时间差是2秒钟。所以,经过1分58秒后,也正好是满满一瓶。
面试例题4:斯芬克斯是古代希腊神话中的带翅膀的狮子女魔。传说她在底比斯附近要人猜谜,猜不出来就要杀人。一次,她要底比斯王子猜谜:“有一种动物,早上4条腿,中午2条腿,晚上3条腿,是什么动物?”聪明的王子说:“是人。”他猜中了。
如果你是现代的斯芬克斯,会提出什么样的问题呢?比如,1和0之间加上什么符号才可以使得到的数比0大又比1小呢?你知道吗?
答案:0.1面试例题5:父亲打电话给女儿,要她替自己买一些生活用品,同时告诉她,钱放在书桌上的一个信封里。女儿找到信封,看见上面写着98,以为信封内有98元,就把钱拿出来,数也没数放进书包里。在商店里,她买了90元的东西,付款时才发现,她不仅没有剩下8元,反而差了4元。回到家里,她把这事告诉了父亲,怀疑父亲把钱点错了。父亲笑着说,他并没有数错,错在女儿身上。
问:女儿错在什么地方?
答案:拿倒了,86看成是98了。
面试例题6:3个孩子翻衣兜,他们把兜里所有的钱都掏出来,看看一共有多少钱。结果一共有320日元。其中有两枚硬币是100日元的,两枚是50日元的,两枚是10日元的。每一个孩子所带的硬币中没有相同的。而且,没带100日元硬币的孩子也没带10日元的硬币,没带50日元硬币的孩子也没带100日元的硬币。你能弄清楚这3个日本孩子原来各自带了什么硬币吗?
答案:第一个小孩:100,50,10;第二个小孩:100,50;第三个小孩:10。
java 面试试题
1,谈谈final, finally, finalize的区别。
答案:final 用于声明属性,方法和类,分别表示属性不可变,方法不可覆盖,类不可继承。finally是异常处理语句结构的一部分,表示总是执行。
finalize是Object类的一个方法,在垃圾收集器执行的时候会调用被回收对象的此方法,可以覆盖此方法提供垃圾收集时的其他资源回收,例如关闭文件等。
2,Anonymous Inner Class(匿名内部类)是否可以extends(继承)其它类,是否可以
implements(实现)interface(接口)?
答案:可以继承其他类或完成其他接口,在swing编程中常用此方式。
3,Static Nested Class 和 Inner Class的不同,说得越多越好。
答案:Static Nested Class是被声明为静态(static)的内部类,它可以不依赖于外部类实例被实例化。而通常的内部类需要在外部类实例化后才能实例化。
4,&和&&的区别。
答案:&是位运算符,表示按位与运算,&&是逻辑运算符,表示逻辑与(and).5,HashMap和Hashtable的区别。
答案:HashMap是Hashtable的轻量级实现(非线程安全的实现),他们都完成了Map接口,主要区别在于HashMap允许空(null)键值(key),由于非线程安全,效率上可能高于Hashtable.6,Collection 和 Collections的区别。
答案:Collection是集合类的上级接口,继承与他的接口主要有Set 和List.Collections是针对集合类的一个帮助类,他提供一系列静态方法实现对各种集合的搜索、排序、线程安全化等操作。
7,什么时候用assert。
答案:1.4新增关键字(语法),用于测试boolean表达式状态,可用于调试程序。
使用方法 assert
另外的使用方式assert < boolean表达式>:
注意编译时要增加-source 1.4 参数,否则报错。]运行时要增加-ea参数,否则assert行被忽略
8,GC是什么? 为什么要有GC?
答案:GC是垃圾收集的意思(Gabage Collection),内存处理是编程人员容易出现问题的地方,忘记或者错误的内存回收会导致程序或系统的不稳定甚至崩溃,Java提供的GC功能可以自动监测对象是否超过作用域从而达到自动回收内存的目的,Java语言没有提供释放已分配内存的显示操作方法。
9,String s = new String(“xyz”);创建了几个String Object?
两个
10,Math.round(11.5)等於多少? Math.round(-11.5)等於多少? 答案:Math.round(11.5)==12
Math.round(-11.5)==-11
round方法返回与参数最接近的长整数,参数加1/2后求其floor.
第五篇:JAVA程序员应聘编程能力测试(英文版)
Q.1 Which color is used to indicate instance methods in the standard “javadoc” format documentation: A.blue B.red C.purple D.orange Java Certification Mock Exam 2/36 Select the most appropriate answer.Q.2 What is the correct ordering for the import, class and package declarations when found in a single file? A.package, import, class B.class, import, package C.import, package, class D.package, class, import Select the most appropriate answer.Q.3 Which methods can be legally applied to a string object? A.equals(String)B.equals(Object)C.trim()D.round()E.toString()Select all correct answers.Q.4 What is the parameter specification for the public static void main method? A.String args [] B.String [] args C.Strings args [] D.String args Select all correct answers.Q.5 What does the zeroth element of the string array passed to the public static void main Java Certification Mock Exam 3/36 method contain? A.The name of the program B.The number of arguments C.The first argument if one is present Select the most appropriate answer.Q.6 Which of the following are Java keywords? A.goto B.malloc C.extends D.FALSE Select all correct answers Q.7 What will be the result of compiling the following code: public class Test { public static void main(String args []){ int age;age = age + 1;System.out.println(“The age is ” + age);} } A.Compiles and runs with no output B.Compiles and runs printing out The age is 1 C.Compiles but generates a runtime error Java Certification Mock Exam 4/36 D.Does not compile E.Compiles but generates a compile time error Select the most appropriate answer.Q.8 Which of these is the correct format to use to create the literal char value a? A.‘a’ B.“a” C.new Character(a)D. 00a Select the most appropriate answer.Q.9 What is the legal range of a byte integral type? A.0-65, 535 B.(–128)–127 C.(–32,768)–32,767 D.(–256)–255 Select the most appropriate answer.Q.10 Which of the following is illegal: A.int i = 32;B.float f = 45.0;C.double d = 45.0;Select the most appropriate answer.Q.11 What will be the result of compiling the following code: Java Certification Mock Exam 5/36 public class Test { static int age;public static void main(String args []){ age = age + 1;System.out.println(“The age is ” + age);} } A.Compiles and runs with no output B.Compiles and runs printing out The age is 1 C.Compiles but generates a runtime error D.Does not compile E.Compiles but generates a compile time error Select the most appropriate answer.Q.12 Which of the following are correct? A.128 >> 1 gives 64 B.128 >>> 1 gives 64 C.128 >> 1 gives –64 D.128 >>> 1 gives –64 Select all correct answers Q.13 Which of the following return true? A.“john” == “john” B.“john”.equals(“john”)C.“john” = “john” Java Certification Mock Exam 6/36 D.“john”.equals(new Button(“john”))Select all correct answers.Q.14 Which of the following do not lead to a runtime error? A.“john” + “ was ” + “ here” B.“john” + 3 C.3 + 5 D.5 + 5.5 Select all correct answers.Q.15 Which of the following are so called “short circuit” logical operators? A.& B.|| C.&& D.| Select all correct answers.Q.16 Which of the following are acceptable? A.Object o = new Button(“A”);B.Boolean flag = true;C.Panel p = new Frame();D.Frame f = new Panel();E.Panel p = new Applet();Select all correct answers.Q.17 Java Certification Mock Exam 7/36 What is the result of compiling and running the following code: public class Test { static int total = 10;public static void main(String args []){ new Test();} public Test(){ System.out.println(“In test”);System.out.println(this);int temp = this.total;if(temp > 5){ System.out.println(temp);} } } A.The class will not compile B.The compiler reports and error at line 2 C.The compiler reports an error at line 9 D.The value 10 is one of the elements printed to the standard output E.The class compiles but generates a runtime error Select all correct answers.Q 18 Java Certification Mock Exam 8/36 Which of the following is correct: A.String temp [] = new String {“j” “a” “z”};B.String temp [] = { “j ” “ b” “c”};C.String temp = {“a”, “b”, “c”};D.String temp [] = {“a”, “b”, “c”};Select the most appropriate answer.Q.19 What is the correct declaration of an abstract method that is intended to be public: A.public abstract void add();B.public abstract void add(){} C.public abstract add();D.public virtual add();Select the most appropriate answer.Q.20 Under what situations do you obtain a default constructor? A.When you define any class B.When the class has no other constructors C.When you define at least one constructor Select the most appropriate answer.Q.21 Given the following code: public class Test { … } Java Certification Mock Exam 9/36 Which of the following can be used to define a constructor for this class: A.public void Test(){… } B.public Test(){… }
C.public static Test(){… }
D.public static void Test(){… } Select the most appropriate answer.Q.22 Which of the following are acceptable to the Java compiler: A.if(2 == 3)System.out.println(“Hi”);B.if(2 = 3)System.out.println(“Hi”);C.if(true)System.out.println(“Hi”);D.if(2!= 3)System.out.println(“Hi”);E.if(aString.equals(“hello”))System.out.println(“Hi”);Select all correct answers.Q.23 Assuming a method contains code which may raise an Exception(but not a RuntimeException), what is the correct way for a method to indicate that it expects the caller to handle that exception: A.throw Exception B.throws Exception C.new Exception D.Don't need to specify anything Select the most appropriate answer.Q.24 What is the result of executing the following code, using the parameters 4 and 0: Java Certification Mock Exam 10/36 public void divide(int a, int b){ try { int c = a / b;} catch(Exception e){ System.out.print(“Exception ”);} finally { System.out.println(“Finally”);} A.Prints out: Exception Finally B.Prints out: Finally C.Prints out: Exception D.No output Select the most appropriate answer.Q.25 Which of the following is a legal return type of a method overloading the following method: public void add(int a){…} A.void B.int C.Can be anything Select the most appropriate answer.Q.26 Java Certification Mock Exam 11/36 Which of the following statements is correct for a method which is overriding the following method: public void add(int a){…} A.the overriding method must return void B.the overriding method must return int C.the overriding method can return whatever it likes Select the most appropriate answer.Q.27 Given the following classes defined in separate files: class Vehicle { public void drive(){ System.out.println(“Vehicle: drive”);} } class Car extends Vehicle { public void drive(){ System.out.println(“Car: drive”);} } public class Test { Java Certification Mock Exam 12/36 public static void main(String args []){ Vehicle v;Car c;v = new Vehicle();c = new Car();v.drive();c.drive();v = c;v.drive();} } What will be the effect of compiling and running this class Test? A.Generates a Compiler error on the statement v= c;B.Generates runtime error on the statement v= c;C.Prints out: Vehicle: drive Car: drive Car: drive D.Prints out: Vehicle: drive Car: drive Vehicle: drive Select the most appropriate answer.Java Certification Mock Exam 13/36 Q.28 Where in a constructor, can you place a call to a constructor defined in the super class? A.Anywhere B.The first statement in the constructor C.The last statement in the constructor D.You can't call super in a constructor Select the most appropriate answer.Q.29 Which variables can an inner class access from the class which encapsulates it? A.All static variables B.All final variables C.All instance variables D.Only final instance variables E.Only final static variables Select all correct answers.Q.30 What class must an inner class extend: A.The top level class B.The Object class C.Any class or interface D.It must extend an interface Select the most appropriate answer.Q.31 In the following code, which is the earliest statement, where the object originally held in e, may be garbage collected: 1.public class Test { Java Certification Mock Exam 14/36 2.public static void main(String args []){ 3.Employee e = new Employee(“Bob”, 48);4.e.calculatePay();5.System.out.println(e.printDetails());6.e = null;7.e = new Employee(“Denise”, 36);8.e.calculatePay();9.System.out.println(e.printDetails());10.} 11.} A.Line 10 B.Line 11 C.Line 7 D.Line 8 E.Never Select the most appropriate answer.Q.32 What is the name of the interface that can be used to define a class that can execute within its own thread? A.Runnable B.Run C.Threadable D.Thread E.Executable Select the most appropriate answer.Q.33 What is the name of the method used to schedule a thread for execution? A.init();B.start();C.run();D.resume();E.sleep();Java Certification Mock Exam 15/36 Select the most appropriate answer.Q.34 Which methods may cause a thread to stop executing? A.sleep();B.stop();C.yield();D.wait();E.notify();F.notifyAll()G.synchronized()Select all correct answers.Q.35 Write code to create a text field able to display 10 characters(assuming a fixed size font)displaying the initial string “hello”: : Q.36 Which of the following methods are defined on the Graphics class: A.drawLine(int, int, int, int)B.drawImage(Image, int, int, ImageObserver)C.drawString(String, int, int)D.add(Component);E.setVisible(boolean);F.setLayout(Object);Select all correct answers.Q.37 Which of the following layout managers honours the preferred size of a component: Java Certification Mock Exam 16/36 A.CardLayout B.FlowLayout C.BorderLayout D.GridLayout Select all correct answers.Q.38 Given the following code what is the effect of a being 5: public class Test { public void add(int a){ loop: for(int i = 1;i < 3;i++){ for(int j = 1;j < 3;j++){ if(a == 5){ break loop;} System.out.println(i * j);} } } } A.Generate a runtime error B.Throw an ArrayIndexOutOfBoundsException C.Print the values: 1, 2, 2, 4 D.Produces no output Select the most appropriate answer.Java Certification Mock Exam 17/36 Q.39 What is the effect of issuing a wait()method on an object A.If a notify()method has already been sent to that object then it has no effect B.The object issuing the call to wait()will halt until another object sends a notify()or notifyAll()method C.An exception will be raised D.The object issuing the call to wait()will be automatically synchronized with any other objects using the receiving object.Select the most appropriate answer.Q.40 The layout of a container can be altered using which of the following methods: A.setLayout(aLayoutManager);B.addLayout(aLayoutManager);C.layout(aLayoutManager);D.setLayoutManager(aLayoutManager);Select all correct answers.Q.41 Using a FlowLayout manager, which is the correct way to add elements to a container: A.add(component);B.add(“Center”, component);C.add(x, y, component);D.set(component);Select the most appropriate answer.Q.42 Given that a Button can generate an ActionEvent which listener would you expect to have to implement, in a class which would handle this event? Java Certification Mock Exam 18/36 A.FocusListener B.ComponentListener C.WindowListener D.ActionListener E.ItemListener Select the most appropriate answer.Q.43 Which of the following, are valid return types, for listener methods: A.boolean B.the type of event handled C.void D.Component Select the most appropriate answer.Q.44 Assuming we have a class which implements the ActionListener interface, which method should be used to register this with a Button? A.addListener(*);B.addActionListener(*);C.addButtonListener(*);D.setListener(*);Select the most appropriate answer.Q.45 In order to cause the paint(Graphics)method to execute, which of the following is the most appropriate method to call: A.paint()B.repaint()C.paint(Graphics)D.update(Graphics)E.None –you should never cause paint(Graphics)to execute Java Certification Mock Exam 19/36 Select the most appropriate answer.Q.46 Which of the following illustrates the correct way to pass a parameter into an applet: A.