Java认证模拟题:onlyfortrainning
来源:优易学  2011-11-28 14:28:14   【优易学:中国教育考试门户网】   资料下载   IT书店

 

1 1. which modifier should be applied to a method for the lock of object this to be obtained prior to execution any of the method body?  
a. synchronizedb. abstractc. finald. statice. public  

12. the following code is entire contents of a file called example.java,causes precisely one error during compilation:  
1)class subclass extends baseclass{  
2) }  
3)class baseclass(){  
4) string str;  
5) public baseclass(){  
6) system.out.println(“ok”);}  
7) public baseclass(string s){  
str=s;}  
9)}  
10)public class example{  
11) public void method(){  
12) subclass s=new subclass(“hello”);  
13) baseclass b=new baseclass(“world”);  
14) }  
15) }  

which line would be cause the error?  
a. 9b. 10c. 11d.12  
13. which statement is correctly declare a variable a which is suitable for refering to an array of 50 string empty object?  
a. string [] ab. string a[]c. char a[][]d. string a[50]f. object a[50]  

14. give the following java source fragment:  
//point x  
public class interesting{  
//do something  
}  
which statement is correctly java syntax at point x?  
a. import java.awt.*;b.package mypackage;c. static int pi=3.14  
d. public class myclass{//do other thing…}e. class myclass{//do something…}  

15. give this class outline:  
class example{  
private int x;  
//rest of class body…  
}  
assuming that x invoked by the code java example, which statement can made x be directly accessible in main() method of example.java?  
a. change private int x to public int xb. change private int x to static int x  
c. change private int x to protected int xd. change private int x to final int x  

16. a class design requires that a member variable should be accessible only by same package, which modifier word should be used?  
a. protectedb. publicc. no modifierd. private

17. which modifier should be applied to a declaration of a class member variable for the value of variable to remain constant after the creation of the object?  

18. which is corrected argument of main() method of application?  
a. string argsb. string ar[]c. char args[][]d. stringbuffer arg[]  

19. “the employee object is a person, an employee has appointment store in a vector, a hire date and a number of dependent”  
short answer: use shortest statement declare a class of employee.  

20. give the following class definition inseparate source files:  
public class example{  
public example(){//do something}  
protected example(int i){//do something}  
protected void method(){//do something}  
}  
public class hello extends example{//member method and member variable}  
which methods are corrected added to the class hello?  
a. public void example(){}b. public void method(){}  
c. protected void method(){}d. private void method(){}  

21. float s=new float(0.9f);  
float t=new float(0.9f);  
double u=new double(0.9);  
which expression’s result is true?  
a. s= =tb. s.equals(t)c. s= =ud. t.equals(u)  

22. give following class:  
class aclass{  
private long val;  
public aclass(long v){val=v;}  
public static void main(string args[]){  
aclass x=new aclass(10l);  
aclass y=new aclass(10l);  
aclass z=y;  
long a=10l;  
int b=10;  
}  
}  
which expression result is true?  
a. a= =b;b. a= =x;c. y= =z;d. x= =y;  
e. a= =10.0;  

23. string s=”example string”;  
which operation is legal?  
a. s>;>;>;=3;b. int i=s.length();c. s[3]=“x”;  
d. string short_s=s.trim();e. string t=“root”+s;  

24. 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 will not compile  
b.this code compile but throws an exception at runtime  
c.this code runs but nothing appears in the standard output  
d.this code runs and “constructor” in the standard output  
e.this code runs and writes ”null” in the standard output  

25. what use to position a button in a frame ,only width of button is affected by the frame size, which layout button well be set ?  
a. flowlayout;b. gridlayout;c. north of borderlayout  
d. south of borderlayoute. east or west of borderlayout

26. what use to position a button in a frame, size of button is not affected by the frame size, which layout button will be set?  
a. flowlayout;b. gridlayout;c. north of borderlayout  
d. south of borderlayoute. east or west of borderlayout  

27. select valid identifier of java:  
a. usernameb. %passwdc. 3d_gamed. $chargee. this  

28. which are java keyword?  
a. gotob. nullc. falsed. nativee. const  

29. give the following java class:  
public class example{  
static int x[]=new int[15];  
public static void main(string args[]){  
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.  

30. 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.  

上一页  [1] [2] [3] 下一页

责任编辑:小草

文章搜索:
 相关文章
热点资讯
热门课程培训