K Abhijit

Ranch Hand
+ Follow
since Mar 03, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
3
Received in last 30 days
0
Total given
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by K Abhijit

there are multiple way you can handle this issue.

[MODERATOR ACTION: Deleted fully coded solution.]

K Abhijit, please remember that this site is NotACodeMill, and LetThemDoTheirOwnHomework. Thank you!
6 years ago

Now My Question is Since , serialVersionUID field is of type static final long , then why it gets serialized in Serialization of Object ,
Is this the one exception to the general serialization rule that, static fields are not serialized. ? Please advise



YES its is an exception::
Now you would say WHY this is an exception
The answer lies in 'WHAT IT DOES FOR CLASS' and HOW ITS HANDLED IN JAVA

serialVersionUID:
It's version that serialization run time associates with each serializable class which is used during deserialization to verify that the sender and receiver of a serialized object have loaded classes for that object that are compatible with respect to serialization.
If the receiver has loaded a class for the object that has a different serialVersionUID than that of the corresponding sender's class, then deserialization will result in an InvalidClassException

Logically thinking considering OBJECT Serialization Policy USAGE of this variable ; IT HAS to be CLASS Level NOT INSTANCE Level. (if you understand its usage you would agree this statement)

BUT THIS VERSION ID of the sender class (instance) which is getting serialized should also be available on Remote serializable runtime to CONFIRM /VALIDATE the version of incoming (serialized) INSTANCE Of class
so it SHOULD BE PART OF SERIALIZED package


HENCE IT IS SERIALIZABLE

hope it answers your doubt
cheers
6 years ago
looks at this code:



somehow I see Comparator is used by TreeSet Object while checking for contains(..)
8 years ago
Thanks Rob, looks more connected now with this logic....

but this is huge leap; this analogy would make a significance difference while using multiple collections like Tree/Hash maps/sets ...
does Sun/Oracle say anything like this in any of their documentations? (i didn't find any )
8 years ago
Actually that's what I meant....may be there was a room for improvement in a stating it; So let me re-iterate

When we DON'T use new operator then INTERN pool is referred and if that LITERAL not found in pool, Object is constructed...

in this case particularly , it would NEVER be the case since all Objects have already been constructed.....

anyway thanks for correction
8 years ago
looks at this code:



somehow I see Comparator is used by TreeSet Object while checking for contains(..)
8 years ago


String name = message[1]; -------------------------------------------------------------------------------------------- refer pt 1
String address = message[2]; .......................................upto 30 values;

and then we are using these String references to create an object of bean class using setter methods.

myBean.setName(name); --------------------------------------------------------------------------------------------- refer pt 2
myBean.setAddress(address);



Please note that @ Ref pt 1 as well as pt 2 you ARE NOT CERATING any String object; your are decaring REFERENCES (pointers) to String Obejct.

String Object is constructed ONLY IF WE USE NEW operator like new String("TEST"); else String INTERN pool is used....
I see NO problem what so ever unless in setXXX(String s) you are creating a String Object using NEW operator.


8 years ago
This is what Oracle (sounds odd right , but still its a fact ) defines for wait(long) method

http://download.oracle.com/javase/1.4.2/docs/api/java/lang/Object.html#wait(long)


Thread T becomes disabled for thread scheduling purposes and lies dormant until one of four things happens:

•Some other thread invokes the notify method for this object and thread T happens to be arbitrarily chosen as the thread to be awakened.
•Some other thread invokes the notifyAll method for this object.
•Some other thread interrupts thread T.
The specified amount of real time has elapsed, more or less. If timeout is zero, however, then real time is not taken into consideration and the thread simply waits until notified.

So what I can see here, if the specified time (should be > 0 ) lapsed then Thread becomes eligible for scheduling purposes

the question is "After calling this method, when will the thread A become a candidate to get another turn at the CPU ?"
it is not asking when Thread A would be RUNNING state, so correct answer is A, I don't see any ambiguity


8 years ago
@Bala: is your class (where ou have added the logger) is singlton ?
if YES, we CAN add Logger as instance variable
if NO then keep it static else there would be performance degradation ....

Also check the memoery foot print keeping loggers as static / instance.
Since LIFE (SCOPE ) of the STATIC variable would be different than the INSTANCE varaible; you MAY see some difference !

May I ask you few questions?
Have you ACTUALLY seen any performance improvement after defining loggers as INSTANCE fields?
Which Log api are you using? (hopefully Apache )
what is the appender size you have configured
is Appender on local drive or on network?

8 years ago
@Stephan van Hulst : You are right; I was wrong !

Luigi Plinge wrote: Other than lowercase letters, a pattern might contain '?' which represents exactly one character (so "a?b" matches "aab", "abb", "acb" etc).



Problem statement is very much clear.. thanks for correcting me..
8 years ago
interesting post; thanks Ujwala

initially thought that the Post Title and description is not in sync.. crazy one...but when thought a bit and saw the post of Rob, got some more idea what could be the query for...

Well Ujwala, if you can elaborate your question, it would be great !

Rob Spoor
These two last lines should both print out the same value but it doesn't.



this is interesting we need to check why?
8 years ago
can you try runnig the code for following input


String file="A";
String pattern="A*";
System.out.println(match.minimalChanges(file,pattern));


Output is 1
Expected : Zero
8 years ago
how can you have 6 ears in one application ? you can't have ear inside ear ....
http://www.bea-weblogic.com/can-i-have-an-ear-file-packaged-inside-another-ear-file.html

Assuming you are talking about thr 6 six different ear...

well i know this is a workaround but you can use some property file...


8 years ago
Are you looking for any realtime project or just for learning purpose?

There are many databases that support this feature; well I can tell you what i have worked on
Use Oracle 9.2 onwards (i think even 8 should also support but i never worked on that)
declare that XML column you want to store as String as CLOB
use Oracle driver (say ojdbc.jar) and use normal JDBC api

let me know incase you need any specific information


8 years ago
Ans A is correct

The Thread A would be placed in READY queue if
1. Any other thread invokes notify on B OR
2. after time interval passed to wait methods gets lapsed.. (here it 2 secs)

Ans B should not be correct as LOCK on B has nothing to with Eligibility of A to get placed in ready queue, since we have invoked wait (A is not BLOCKED for any I/O operations)

8 years ago