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


31. short answer:  
the decimal value of i is 12, the octal i value is:  

32. short answer:  
the decimal value of i is 7, the hexadecimal i value is:  

33. give the following class:  
public class example{  
string str=new string(“good”);  
char ch[]={‘a’,’b’,’c’};  
public static void main(string args[]){  
example ex=new example();  
ex.change(ex.str,ex.ch);  
system.out.println(ex.str+”and”+ex.ch[0] +ex.ch[1] +ex.ch[2]);  
}  
public void change(string str,char ch[]){  
str=”test ok”;ch[0]=’g’;  
}  
}  
which is the output:  
a. good and abcb. good and gbcc. test ok and abcd. test ok and gbc  

34. which code fragments would correctly identify the number of arguments passed via command line to a java application, exclude the name of the class that is being invoke.  
a. int count = args.length;b. int count = args.length-1;  
c. int count=0; while(args[count]!=null)  
count++;  
d. int count=0;while  
(!(args[count].equals(“”))) count++;  

35. filteroutputstream is the parent class for bufferedoutputstream, dataoutputstream and printstream. which classes are valid argument for the constructor of a filteroutputstream?  
a. inputstreamb. outputstreamc. file  
d. randomaccessfile e. streamtokenizer  

36. given this skeleton of a class currently under construction:  
public class example{  
int x,y,z;  

public example (int a, int b) {  
//lots of complex computation  
x=a; y=b;  
}  
public example(int a, int b, int c){  
// do everything the same as single argument  
// version of constructor  
// including assignment x=a, y=b, z=c  
z=c;  
}  
}  
what is the most concise way to code the “do everything…” part of the constructor taking two arguments?  
short answer:  

37. which correctly create a two dimensional array of integers?  
a.int a[][] = new int[][];  
b.int a[10][10] = new int[][];  
c.int a[][] = new int[10][10];  
d.int [][]a = new int[10][10];  
e.int []a[] = new int[10][10];

38. which are correct class declarations? assume in each case that the text constitutes the entire contents of a file called fred.java?  
a.public class fred{  
public int x = 0;  
public fred (int x){  
this.x=x;  
}  
}  
b.public class fred{  
public int x = 0;  
public fred (int x){  
this.x=x;  
}  
}  
c.public class fred extends mybaseclass, myotherbaseclass{  
public int x = 0;  
public fred(int xval){  
x=xval;  
}  
}  
d.protected class fred{  
private int x = 0;  
private fred (int xval){  
x=xval;  
}  
}  
e.import java.awt.*;  
public class fred extends object{  
int x;  
private fred(int xval){  
x = xval;  
}  
}  

39. 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  
e.the variable should be marked private and an accessible method provided

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

责任编辑:小草

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