laura_zpf

Ranch Hand
+ Follow
since Sep 14, 2000
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by laura_zpf

What are the proper ways to initialize the static variables SIZE and MIN_VALUE ?
01: class Base
02: {
03: static final int SIZE;
04: static float MIN_VALUE;
05:
06: Base() { }
07: void test() {
08: System.out.println("Base.test()");
09: }
10:
11:}

Select all valid answers.

a) Add the following lines to Base Class
static {
SIZE = 10;
MIN_VALUE = 10.3f;
}
b) Add the following lines to Base Class
{
SIZE = 10;
MIN_VALUE = 10.3f;
}
c) Add the following lines to Base Class constructor
SIZE = 10;
MIN_VALUE = 10.3f;
d) Modify lines 03 and 04 as
static final int SIZE = 10;
static float MIN_VALUE = 10.3f;
I think d) is right. but in the meanwhile, I have done the test, it shows a) is also right. but who can tell me why?
sorry, I make a mistake. The correct question should be following.
void method X() {
String r = new String("abc");
String s = new String("abc");
r = r+1; //1
r = null; //2
s = s + r; //3
} //4
a.Before statement labeled 1
b.Before statement labeled 2
c.Before statement labeled 3
d.Before statement labeled 4
e.Never.
Is the statement true or false?
Garbage Collection feature of Java ensures that the program never runs out of memory.
I think it is right. But the answer shows me that is wrong.
At what stage in the following method does the object initially referenced by s becomes available for garbage collection. Select the one correct answer.
void method X() {
r = r+1; //1
r = null; //2
s = s + r; //3String r = new String("abc");
String s = new String("abc");
} //4
a.Before statement labeled 1
b.Before statement labeled 2
c.Before statement labeled 3
d.Before statement labeled 4
e.Never.
The answer is d. But I think it should b. Because the two statements String r = new String("abc");String s = new String("abc");, the two "abc" is refer to different memory.The statement:r=r+1 lets r refer to a different memory, so I think the one of the "abc" should be collected.
I always read some questions about which classes are the subclass of one class? for example:Frame, Container, Canvas and Applet are all subclasses of Component (with Canvas and Container being direct or immediate subclasses, while Frame and Applet are further down the hierarchy).
CheckboxGroup is a direct subclass of java.lang.Object.
How can I remember so many classes of Java?
By the way, who know something about CA(certification Authority) and digital signature? Could you dicuss with me?
Given the following sequence of Java statements
1.StringBuffer sb = new StringBuffer("abc");
2.String s = new String("abc");
3.sb.append("def");
4.s.append("def");
5.sb.insert(1, "zzz");
6.s.concat(sb);
7.s.trim();
Which of the following statements are true:
a.The compiler would generate an error for line 1.
b.The compiler would generate an error for line 2.
c.The compiler would generate an error for line 3.
d.The compiler would generate an error for line 4.
e.The compiler would generate an error for line 5.
f.The compiler would generate an error for line 6.
g.The compiler would generate an error for line 7.
The answer is f. But I have checked the documention and I don't find the append() method in the String class.
Thank you! sampaths77! you means this question only correct in the JDK1.0 but not correct for now.
If class b extends class a.
b y; a x = new a(); y=(b)x; The result: compile ok, but run time error.
I know the result. But I don't understand it completely. I think if a is Object and one extends Object, then b can uses any methods in Object class. But why Object can not cast to any other object? Could anyone help me?
I have checked the document, but I do not find that the Container is abstract. It is defined as public class Container extends component.
I have checked the document, but I do not find that the Container is abstract. It is defined as public class Container extends component.
The Container methods add(Component comp) and add(String name, Component comp) will throw an IllegalArgumentException if "comp" is a:
a) button
b) list
c) window
d) textarea
e) container that contains this container
The answer is c),e).
why the window can not add to the container? and by the way, the container aslo can not add to the container?
In the list below, which subclass(es) of Component cannot be directly instantiated:
a) Panel
b) Dialog
c) Container
d) Frame
The answer is Container. But why the Container can not be instantiated directly?
Congratation!
I will take the exam too. Could you pass me some mock exams which you think that is very helpful?
Thank you very much!
My email address is:zhoupinfang@netease.com
or laura_zpf@sina.com
Waiting for your message.

------------------
import java.applet.Applet;
import java.awt.*;
public class Sample extends Applet {
private String text = "Hello World";
public void init() {
add(new Label(text));
}
public Sample (String string) {
text = string;
}
}
It is accessed form the following HTML page:
<html>
<title>Sample Applet</title>
<body>
<applet code="Sample.class" width=200 height=200></applet>
</body>
</html>
What is the result of compiling and running this applet:
A. Prints "Hello World".
B. Generates a runtime error.
C. Does nothing.
D. Generates a compile time error.
Select the most appropriate answer.
The answer is b). I have done the test. I think it should be c).
Could someone help me?
public class EqualsTest{
public static void main(String args[]){
char A='\u0005';
if(A==0x0005L) System.out.println("Equal");
else System.out.println("Not Equal");
}
}
b) The program compiles and prints "Not Equal".
c) The program compiles and prints "Equal".
The answer is c). Could you tell me how to convert unicode char A='\u0005' to usual format? such as \u0005' is equals to 0x0005L. what is the meaning of the 'L' in the format?