当前位置: 技术问答>java相关
关于scjp的习题,,请大家帮忙看一下,,,最好有解释!!!!谢谢!!
来源: 互联网 发布时间:2015-03-04
本文导语: 7、Given the following code fragment: 1) public void create() { 2) Vector myVect; 3) myVect = new Vector(); 4) } Which of the following statements are true? A. The declaration on line 2 does not allocate memory space for ...
7、Given the following code fragment:
1) public void create() {
2) Vector myVect;
3) myVect = new Vector();
4) }
Which of the following statements are true?
A. The declaration on line 2 does not allocate memory space for the variable myVect.
B. The declaration on line 2 allocates memory space for a reference to a Vector object.
C. The statement on line 2 creates an object of class Vector.
D. The statement on line 3 creates an object of class Vector.
E. The statement on line 3 allocates memory space for an object of class Vector
(ade)
我的观点是b也对,,不知到底对不对????
10.Which of the following statements are true?
A. The equals() method determines if reference values refer to the same object.
B. The == operator determines if the contents and type of two separate objects match.
C. The equals() method returns true only when the contents of two objects match.
D. The class File overrides equals() to return true if the contents and type of two separate objects match.
(ad)
题目:下面的哪些叙述为真。
A. equals()方法判定引用值是否指向同一对象。
B. == 操作符判定两个分立的对象的内容和类型是否一致。
C. equals()方法只有在两个对象的内容一致时返回true。
D. 类File重写方法equals()在两个分立的对象的内容和类型一致时返回true。
严格来说这个问题的答案是不确定的,因为equals()方法是可以被重载的,但是按照java语言的本意来说:如果没有重写
(override)新类的equals(),则该方法和 == 操作符一样在两个变量指向同一对象时返回真,但是java推荐的是使用
equals()方法来判断两个对象的内容是否一样,就像String类的equals()方法所做的那样:判定两个String对象的内容
是否相同,而==操作符返回true的唯一条件是两个变量指向同一对象。从这个意义上来说选择给定的答案。
从更严格的意义来说正确答案应该只有d。
( 我的观点是b ,d正确 )
48. Given the following class:
public class Sample{
long length;
public Sample(long l){ length = l; }
public static void main(String arg[]){
Sample s1, s2, s3;
s1 = new Sample(21L);
s2 = new Sample(21L);
s3 = s2;
long m = 21L;
}
}
Which expression returns true?
A. s1 == s2;
B. s2 == s3;
C. m == s1;
D. s1.equals(m).
( 我的观点是d 也正确 )但是答案只给出了b
不知有没有比较全面的关于equals()和== 操作符的详细解释
26. Which of the following statements about declaration are true?
A. Declaration of primitive types such as boolean, byte and so on does not allocate memory space for the variable.
B. Declaration of primitive types such as boolean, byte and so on allocates memory space for the variable.
C. Declaration of nonprimitive types such as String, Vector and so on does not allocate memory space for the object.
D. Declaration of nonprimitive types such as String, Vector ans so on allocates memory space for the object.
此题,答案有说是c.d,也有是a.d我认为是bc,不懂能不能把正确答案告诉我>
我做这套题错了20个,,现在去考试可不可以???做摸拟题大概多少可以
了???
1) public void create() {
2) Vector myVect;
3) myVect = new Vector();
4) }
Which of the following statements are true?
A. The declaration on line 2 does not allocate memory space for the variable myVect.
B. The declaration on line 2 allocates memory space for a reference to a Vector object.
C. The statement on line 2 creates an object of class Vector.
D. The statement on line 3 creates an object of class Vector.
E. The statement on line 3 allocates memory space for an object of class Vector
(ade)
我的观点是b也对,,不知到底对不对????
10.Which of the following statements are true?
A. The equals() method determines if reference values refer to the same object.
B. The == operator determines if the contents and type of two separate objects match.
C. The equals() method returns true only when the contents of two objects match.
D. The class File overrides equals() to return true if the contents and type of two separate objects match.
(ad)
题目:下面的哪些叙述为真。
A. equals()方法判定引用值是否指向同一对象。
B. == 操作符判定两个分立的对象的内容和类型是否一致。
C. equals()方法只有在两个对象的内容一致时返回true。
D. 类File重写方法equals()在两个分立的对象的内容和类型一致时返回true。
严格来说这个问题的答案是不确定的,因为equals()方法是可以被重载的,但是按照java语言的本意来说:如果没有重写
(override)新类的equals(),则该方法和 == 操作符一样在两个变量指向同一对象时返回真,但是java推荐的是使用
equals()方法来判断两个对象的内容是否一样,就像String类的equals()方法所做的那样:判定两个String对象的内容
是否相同,而==操作符返回true的唯一条件是两个变量指向同一对象。从这个意义上来说选择给定的答案。
从更严格的意义来说正确答案应该只有d。
( 我的观点是b ,d正确 )
48. Given the following class:
public class Sample{
long length;
public Sample(long l){ length = l; }
public static void main(String arg[]){
Sample s1, s2, s3;
s1 = new Sample(21L);
s2 = new Sample(21L);
s3 = s2;
long m = 21L;
}
}
Which expression returns true?
A. s1 == s2;
B. s2 == s3;
C. m == s1;
D. s1.equals(m).
( 我的观点是d 也正确 )但是答案只给出了b
不知有没有比较全面的关于equals()和== 操作符的详细解释
26. Which of the following statements about declaration are true?
A. Declaration of primitive types such as boolean, byte and so on does not allocate memory space for the variable.
B. Declaration of primitive types such as boolean, byte and so on allocates memory space for the variable.
C. Declaration of nonprimitive types such as String, Vector and so on does not allocate memory space for the object.
D. Declaration of nonprimitive types such as String, Vector ans so on allocates memory space for the object.
此题,答案有说是c.d,也有是a.d我认为是bc,不懂能不能把正确答案告诉我>
我做这套题错了20个,,现在去考试可不可以???做摸拟题大概多少可以
了???
|
7、Given the following code fragment:
1) public void create() {
2) Vector myVect;
3) myVect = new Vector();
4) }
B. The declaration on line 2 allocates memory space for a reference to a Vector object.
-----其实Vector等class对象必须用new关键字才能生成 引用,所以B是不对的
10.Which of the following statements are true?
A. The equals() method determines if reference values refer to the same object.
B. The == operator determines if the contents and type of two separate objects match.
C. The equals() method returns true only when the contents of two objects match.
D. The class File overrides equals() to return true if the contents and type of two separate objects match.
---equals()比较对象类型和内容,而==比较两个对象在内存中的位置
48. Given the following class:
public class Sample{
long length;
public Sample(long l){ length = l; }
public static void main(String arg[]){
Sample s1, s2, s3;
s1 = new Sample(21L);
s2 = new Sample(21L);
s3 = s2;
long m = 21L;
}
}
----s3=s2;就表示他们引用同一块内存区域,所以有s3==s2返回true.
而 m 是 long 类型,s1 是一个 Sample 对象 ,所以不会相等 阿
详细解释见上面第10题解答
26. Which of the following statements about declaration are true?
A. Declaration of primitive types such as boolean, byte and so on does not allocate memory space for the variable.
B. Declaration of primitive types such as boolean, byte and so on allocates memory space for the variable.
C. Declaration of nonprimitive types such as String, Vector and so on does not allocate memory space for the object.
D. Declaration of nonprimitive types such as String, Vector ans so on allocates memory space for the object.
---这题我觉得选择b和c,基本类型在声明 时就已经分配内存空间,而对象是必须用new关键字才能生成实例的
/*--by bookbobby(书呆)-+
| |
| 你说爱我只是习惯 |
| 再也不是喜欢 |
| 我给你的爱 |
| 已不再温暖 |
| |
+--by bookbobby(书呆)-*/
1) public void create() {
2) Vector myVect;
3) myVect = new Vector();
4) }
B. The declaration on line 2 allocates memory space for a reference to a Vector object.
-----其实Vector等class对象必须用new关键字才能生成 引用,所以B是不对的
10.Which of the following statements are true?
A. The equals() method determines if reference values refer to the same object.
B. The == operator determines if the contents and type of two separate objects match.
C. The equals() method returns true only when the contents of two objects match.
D. The class File overrides equals() to return true if the contents and type of two separate objects match.
---equals()比较对象类型和内容,而==比较两个对象在内存中的位置
48. Given the following class:
public class Sample{
long length;
public Sample(long l){ length = l; }
public static void main(String arg[]){
Sample s1, s2, s3;
s1 = new Sample(21L);
s2 = new Sample(21L);
s3 = s2;
long m = 21L;
}
}
----s3=s2;就表示他们引用同一块内存区域,所以有s3==s2返回true.
而 m 是 long 类型,s1 是一个 Sample 对象 ,所以不会相等 阿
详细解释见上面第10题解答
26. Which of the following statements about declaration are true?
A. Declaration of primitive types such as boolean, byte and so on does not allocate memory space for the variable.
B. Declaration of primitive types such as boolean, byte and so on allocates memory space for the variable.
C. Declaration of nonprimitive types such as String, Vector and so on does not allocate memory space for the object.
D. Declaration of nonprimitive types such as String, Vector ans so on allocates memory space for the object.
---这题我觉得选择b和c,基本类型在声明 时就已经分配内存空间,而对象是必须用new关键字才能生成实例的
/*--by bookbobby(书呆)-+
| |
| 你说爱我只是习惯 |
| 再也不是喜欢 |
| 我给你的爱 |
| 已不再温暖 |
| |
+--by bookbobby(书呆)-*/