您的位置是:首页 >> 计算机 >> Sun认证 >> 文章阅读

SUN认证Java2程序员考试(SCJP) 试题解析(2)


日期:
2005-4-17 9:33:00
来源:
学习联盟
作者:
不详
编辑
dongfangshuo
Which of the following lines of code will compile without error?  
A.  
int i=0;  
if (i) {  
System.out.println(“Hi”);  
}  
B.  
boolean b=true;  
boolean b2=true;  
if(b==b2) {  
System.out.println(“So true”);  
}  
C.  
int i=1;  
int j=2;  
if(i==1|| j==2)  
System.out.println(“OK”);  
D.  
int i=1;  
int j=2;  
if (i==1 &| j==2)  
System.out.println(“OK”);  
解答:B, C  
点评:选项A错,因为if语句后需要一个boolean类型的表达式。逻辑操作有^、&、| 和 &&、||,但是“&|”是非法的,所以选项D不正确。  

例题5:  
Which two demonstrate a "has a" relationship? (Choose two)  
A. public interface Person { }  
public class Employee extends Person{ }  
B. public interface Shape { }  
public interface Rectandle extends Shape { }  
C. public interface Colorable { }  
public class Shape implements Colorable  
{ }  
D. public class Species{ }  
public class Animal{private Species species;}  
E. interface Component{ }  
class Container implements Component{  
private Component[] children;  
}  
解答:D, E  

此文共有3页 上一页 1 2 3 下一页

关闭窗口

   兆联特别申明
1)除本站特殊规定外,本站所有信息均不拥有版权,仅供学习参考!
2)站内大部分内容注明出处及详细信息,版权归作者所有!如果您觉得不妥请及时与我站联系,我们将立即删除。
3)本站提供的资料您只有阅读权,并不等于您得到文章的所有权,本站反对将我站提供的资料直接使用。