Java经典模拟题(onlyfortrainning)(2)

来源:java认证发布时间:2012-11-12 12:47:30java认证视频

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  

上一页1234下一页

视频学习

我考网版权与免责声明

① 凡本网注明稿件来源为"原创"的所有文字、图片和音视频稿件,版权均属本网所有。任何媒体、网站或个人转载、链接转贴或以其他方式复制发表时必须注明"稿件来源:我考网",违者本网将依法追究责任;

② 本网部分稿件来源于网络,任何单位或个人认为我考网发布的内容可能涉嫌侵犯其合法权益,应该及时向我考网书面反馈,并提供身份证明、权属证明及详细侵权情况证明,我考网在收到上述法律文件后,将会尽快移除被控侵权内容。

最近更新

社区交流

考试问答