Rajesh R

Greenhorn
+ Follow
since Mar 02, 2001
Merit badge: grant badges
For More
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 Rajesh R

Hi Jane,
This is my original name as it appears in my all records. I cannot change my name for the sake of re-registering(joking).
do you know a definite answer for this question?
thanks, Have a great daY!
Rajesh R

Originally posted by Jane Griscti:
Rajesh R,
Please read the JavaRanch Name Policy and re-register using a name that complies with the rules.
Thanks for your cooperation.


Let's consider like this:
Member of a package are top level classes and interfaces only. (non-static inner classes are not members of a package)
Now before a method is accessible, its class must be accessible. A class, which is declared with any one of the access modifiers- public, protected, or default access, is accessible throughout the package in which this class is declared. Therefore a method, which is declared within this class using any one of the access modifiers- public, protected, or default access is accessible through out this package. [The modifier private is ruled out]
But to be referenced without an instance of a class, the method must also have a static modifier(FYI: static is not an access modifier but is an class-member modifier).
I see "static" modifier is missing in your question. Without this modifier, I think that you cannot call a method from outside this class without an instance of this class.
This is what I think. Please let me know if I overlooked something.

thanks,
Rajesh


Thank you very much Niraj,
But I still think why not the answer is true. For e.g.
Let's consider these two options:
Let's say we haven't enabled the event mask using the enableEvents() method, we added a listener, which will implicitly turn a particular mask on. The instance of the listener /Adapter class provided with addXXXXListener() method is responsible to handle this event. (provided if we have not overriden the processEvent() method!)
On the other hand, if we have turn on the event mask using the enableEvents() method, then we could also override the the processEvent() method to process the events within the extending class itself. In this case, "we may not use a Listener/Adapter class". This is were I had doubt. "May Not".
Could you please consider this and let me know if I am overlooking something?
thanks,
Rajesh
I encountered a question which read something like this:
"If you decides to use Component's enableEvents() method to enable a particular Event Mask, you may not use the particular Adapter class to handle this event" true or false.
I thought it is true, but I was wrong.
Could anyone help me figuring out this. I am little confused with "may or may not" type of questions.
thanks,
Rajesh
I tried:
{
...
setLayout(new GridLayout());
add(textArea);
add(label);
add(button);
...
}
In this case, the TextArea occupies the vertical space fully. But with BoarderLayout, I think that TextArea occupies full space only if button and label are added to East and West.
Also new gridLayout(1,1) works fine. But GridLayout(2,1) does not meet this requirements.
Therefore which one is most suitable answer to this question?
Anyone, please?
Rajesh
1) This method is defined in Thread class.
2) An interrupt request is posted for this thread. It need not immediately react to this request. However, if this thread is waiting, it is awakened and it then throws an interrupted exception.
3) It must be called on the thread.

I am sorry, i want to eliminat one line from my previous email, which is "it aquired the lock on q in first iteration of while loop". Please read my previous email as follows:
Sorry for the confusion.
thanks,
Rajesh
Hi Nithin,
I don't think that both threads are executing synchronized methods concurrently. The object is locked during the execution of synchronized method only. Let us assume that producer thread started first and started its run() method. Then this thread executes the method of q, which is put(). This is the method which is synchronized. Therefore it aquires a lock on the object. When this put method completes and return to "producer.run()" method, it releases the lock on q. Between this iteration and next iteration of "producer.run()" method, the other thread can start execution and aquire a lock on q, meanwhile original producer has to wait.
If this is not something that you want, you need to use a diffrent logic to implement a producer-consumer relationship using wait and notify() method.
I hope I could answer your question.
Rajesh
Hi Nithin,
I don't think that both threads are executing synchronized methods concurrently. The object is locked during the execution of synchronized method only. Let us assume that producer thread started first and started its run() method. it aquired the lock on q in first iteration of while loop. Then this thread executes the method of q, which is put(). This is the method which is synchronized. Therefore it aquires a lock on the object. When this put method completes and return to "producer.run()" method, it releases the lock on q. Between this iteration and next iteration of "producer.run()" method, the other thread can start execution and aquire a lock on q, meanwhile original producer has to wait.
If this is not something that you want, you need to use a diffrent logic to implement a producer-consumer relationship using wait and notify() method.
I hope I could answer your question.
Rajesh
Garbage Collection always confuses me. But that does not stop me from sharing with you my understanding. Please correct me if I am wrong.
c: riddle = "when is a" + first
creates a new String object and the variable riddle holds a reference to this new object.
The assignment of null reference to variable first makes the object refered by first "eligible for Garbage Collection", but there is no guarantee that "which" thread will execute garbage collection and "when".
It could even be possible that garbage collection will not take place at all!(because the main method complete execution and JVM might exit!). However, if garbage collection takes place, it is not necessary that the object should be garbage collected in the same order it was made eligible for garbage collection. I could be garbage collected in any order!
I think this is why there was no answer for this question.
What do you think?
The method fermin increment the formal paramter i not the local variable declared i in main. The scope of the formal parameter is the entire body of the method. Outside the scope it does not exist.
Hi,
Here, there are two threads, One thread called "main", which belongs to the ThreadGroup "main", executing the main method. Another one(your thread), executing the run() method.
You know that the threads keeps the working copies of variables that resides in main memory. "Your thread" does an "assign" to s variable and the "main" thread does a "use" of s variable. As these thread are running concurrently, it can not be predicted whether "use" or assign will take place first.
Assume that "use" took place first, then "main" thread is now having value "Sun" and this keeps printing "sun". But before this method finishes, "your thread" might have assigned a value "moon" to s. If this assignment was the first to take place, then main thread would have started printing "moon" instread of "sun"
Again it is not certain that "sun" or "moon" will be printed 10 times. During the execution the "main" thread( which started with printing "sun"), might have reconciled its working copy of variable s with the main memory, then it will start printing "moon" from then onwards.
The best way to avoid this kind of situation is to syncronize. But this does only gurantee that either "moon" or "sun" will be printed 10 times. You cannot be sure which one!
Please let me know what you think.
thanks,
Rajesh
23 years ago
Congrats!
Raj
23 years ago