Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Bad Programming Practices 101 (e-book) this week in the Beginning Java forum!

Christy Smith

Greenhorn
+ Follow
since Aug 15, 2001
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 Christy Smith

Hi, All,
I just passed my programmer exam and ready to try the developer exam. I am really puzzled by the process of the developer exam. Could someone explain it to me or point me to a web site that has detailed explaination. For my understanding, you would have an unlimited amount of time to do the project assignment. Then there is an essay exam related to the project assignment?
Thanks
Congratulations...
I took the exam today as well. For one of question, it told me to choose two, but I thought there were no correct answer. Do you know how do we verify that?
16 years ago
Java allows final instance variable to be initialized in the constructor before it is used. In addition, final instance variable needs to be initialized explicitly. If you change the code to the following:
1. class A {
2. final int y;
3. public static void main(String args[]) {new A();}
4. A() { //y= 5;}
5. }
The following compilation error will show up:
variable y might not have been initialized
Bill, I believe that the compiler would only give an error if there is statement after the for loop. Otherwise, there is no unreachable code. Correct me if I am wrong...
good luck... wishing myself luck as well^_^
Hi Guys,
I am puzzled by the answer to this question.
Question is :
Question 44)
Given a reference called
t
to to a class which extends Thread, which of the following will cause it to give up cycles to allow another thread to execute.
1) t.yield();
2) yield()
3) yield(100) //Or some other suitable amount in milliseconds
4) yield(t);
Answer provided is:
Answer to Question 44)
Objective 7.1)
yield is a static method inherited from object and causes whatever thread is currently executing to yield its cycles.
2) yield()
I thought the answer would be 1, since t is a reference to Thread, and yield() is a static method of the Thread class. yield() might work if it is called in a subclass of Thread. Right??
Antti,
Would you please clarify the order the code is executed for me. I know that static initialize gets executed first, then what?
Thanks
Hi, all,
Here are some sample questions. Please take a look at them, and provide the answers. I have done them, just want to verify the answer some other ranchers. Thanks.

Q-2
Sample Code
String readString() {
char buf[] = new char[80];
Reader in = new InputStreamReader(System.in);
in.read(buf, 0, 80);
return new String(buf);
}
What is wrong with method readString()?
Choice 1
all IO methods must be declared public
Choice 2
an InputStreamReader object can not be bound to standard input
Choice 3
logic to catch exceptions for the InputStream statements is missing
Choice 4
String objects can not be instantiated with a character array
Choice 5
you can not cast InputStreamReader into Reader
Q-3
class A {
int i, j, k;
public A() { i=3; }
public A(int i1) { i = i1; }
public A(int i1, int k1) {
this(i1);
k = k1;
}
}


What is wrong with class A?
Choice 1
there are multiple methods named A()
Choice 2
nothing
Choice 3
a method can not have the same name as its class
Choice 4
all methods must declare return datatypes
Choice 5
methods can not invoke other methods in their own class

Q-4
for(int i=0;i<22;i++) {
if(i<10) {
int j= 2 + i;
}
System.out.println("i: " + i + " j: " + j);
}


What is wrong with the above code?
Choice 1
you can not declare integer i inside the for-loop declaration
Choice 2
variable j is referenced outside its scope
Choice 3
you can not declare variables inside a for-loop
Choice 4
you can not print integer values without converting them to strings
Choice 5
the syntax of the "if" statement is incorrect
Q-5
for(int i=0;i<22;i++) {
if(i<10) {
int j= 2 + i;
}
System.out.println("i: " + i + " j: " + j);
}


What is wrong with the above code?
Choice 1
you can not declare integer i inside the for-loop declaration
Choice 2
variable j is referenced outside its scope
Choice 3
you can not declare variables inside a for-loop
Choice 4
you can not print integer values without converting them to strings
Choice 5
the syntax of the "if" statement is incorrect
Q-6
If memory may be running low, what could free some up?
Choice 1
invoke System.garbageCollection()
Choice 2
reduce the priority of less important threads
Choice 3
invoke System.gc()
Choice 4
make more methods synchronized
Choice 5
call destroy() on any objects you no longer need

In addition, I believe that you can only put one component inside a scrollpane. Correct me as well!
All the wrapper class are immutable, like String, the object once created cannot be changed. If the object's value is changed, a new object is created instead.
Ernest, I believe for question#2, the code is okay, no compilation error is generated. Please correct me if I am wrong.
I don't belive it would throw a runtime exception while executing on the UNIX / LINUX. new File(" ") does not really check for anything, right? It just creates a new file object.
But do you need to know the range for float and double? they are really hard to memorize.
Thanks
Hi, All
Does the certification exam test about reserved words at all?
I believe that reserved words and keywords are different, right?
also is strictfp a reserved words?
Thanks,
Could some explain to me what is "forward reference"?
Also, are panel and applet ocntainers that must be attached to a parent container??
Can you add a frame on top of another frame (Besides the internal frame)?
Thanks...