sun认证java程序员_SUN认证Java2程序员考试(SCJP) 试题解析(2)
【shitiku.jxxyjl.com--JAVA认证试题集锦】
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
点评: 在java中代码重用有两种可能的方式,即组合(“has a”关系)和继承(“is a”关系)。“has a”关系是通过定义类的属性的方式实现的;而“is a”关系是通过类继承实现的。本例中选项a、b、c体现了“is a”关系;选项d、e体现了“has a”关系。
例题6:
which two statements are true for the class java.util.treeset? (choose two)
a. the elements in the collection are ordered.
b. the collection is guaranteed to be immutable.
c. the elements in the collection are guaranteed to be unique.
d. the elements in the collection are accessed using a unique key.
e. the elements in the collection are guaranteed to be synchronized
解答:a, c
点评:treeset类实现了set接口。set的特点是其中的元素惟一,选项c正确。由于采用了树形存储方式,将元素有序地组织起来,所以选项a也正确。
例题7:
true or false: readers have methods that can read and return floats and doubles.
a. ture
b. false
解答:b
点评: reader/writer只处理unicode字符的输入输出。float和double可以通过stream进行i/o.
例题8:
what does the following paint() method draw?
1. public void paint(graphics g) {
2. g.drawstring(“any question”, 10, 0);
3. }
a. the string “any question?”, with its top-left corner at 10,0
b. a little squiggle coming down from the top of the ;component.
解答:b
点评:drawstring(string str, int x, int y)方法是使用当前的颜色和字符,将str的内容显示出来,并且最左的字符的基线从(x,y)开始。在本题中,y=0,所以基线位于最顶端。我们只能看到下行字母的一部分,即字母‘y’、‘q’的下半部分。
本文来源:https://shitiku.jxxyjl.com/javarenzhengshitijijin/6468.html
相关试题
- java 将日期转化为格林时间_JAVA题库:格林模拟试题二(上)(4)
- [java 将日期转化为格林时间]JAVA题库:格林模拟试题二(下)(8)
- sun认证java程序员|SUN认证Java2程序员考试(SCJP) 试题解析(1)
- java 将日期转化为格林时间_JAVA题库:格林模拟试题三(上)(1)
- [java 将日期转化为格林时间]JAVA题库:格林模拟试题二(下)(6)
- 【java二级考试历年真题】JAVA认证历年真题:SCJP认证套题解析
- java 将日期转化为格林时间|JAVA题库:格林模拟试题二(上)(1)
- java二级考试历年真题_JAVA认证历年真题:SCJP认证套题解析
- java 将日期转化为格林时间|JAVA题库:格林模拟试题二(下)(3)
- java 将日期转化为格林时间_JAVA题库:格林模拟试题二(下)(1)
-
java二级考试历年真题_JAVA认证历年真题:SCJP认证套题解析详细阅读
41、which of the following statements are legal?a long l = 4990;b int i = 4l;c float f = 1 1;d double d = 34 4;e double t = 0 9f (ade)题目:下面的哪些声明是...
-
java 将日期转化为格林时间|JAVA题库:格林模拟试题二(下)(3)详细阅读
question 36)which of the following are java key words1)double2)switch3)then4)instanceofquestion 37)what will be output by the following line?system ou...
-
java 将日期转化为格林时间_JAVA题库:格林模拟试题二(下)(1)详细阅读
question 31)what will happen when you attempt to compile and run the following codeimport java io *;class base{ public void amethod()throws filenot...
-
java 将日期转化为格林时间|JAVA题库:格林模拟试题二(下)(2)详细阅读
question 33)what will happen when you attempt to compile and run this code demonstration of event handlingimport java awt *;import java awt event *;p...
-
[java 将日期转化为格林时间]JAVA题库:格林模拟试题三(上)(3)详细阅读
question 10)which of the following statements are true?1) a byte can represent between -128 to 1272) a byte can represent between -127 to 1283) a byte...
-
java二级考试历年真题|JAVA认证历年真题:SCJP认证套题解析详细阅读
1 which of the following range of short is correct? a -27 -- 27-1 b 0 -- 216-1 c ?215 -- 215-1 d ?231 -- 231-1 翻译 下面哪些是short型的取值范围。 答案 c 解析 短整型的数...
-
[sun认证java程序员]SUN认证Java2程序员考试(SCJP) 试题解析(3)详细阅读
what happens when you try to compile and run the following application? choose all correct options 1 public class z { 2 public static void ma...
-
【java 将日期转化为格林时间】JAVA题库:格林模拟试题二(下)(4)详细阅读
question 40)which of the following statements are correct?1) if multiple listeners are added to a component only events for the last listener added wi...
-
java 将日期转化为格林时间_JAVA题库:格林模拟试题二(上)(2)详细阅读
question 4)what will happen when you attempt to compile and run this code?class base{ abstract public void myfunc(); public void another...
-
java二级考试历年真题|JAVA认证历年真题:SCJP考试真题和解析详细阅读
例题1: choose the three valid identifiers from those listed below a idolikethelongnameclass b $byte c const d _ok e 3_case 解答:a, b, d 点评...