ppathak

Greenhorn
+ Follow
since Jul 06, 2000
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by ppathak

Hi Jaya,
well my understanding is:

u get error during compile time, the compiler understands as follows:
variable x is present & it has some value,
variable y(which is not assigned any value).
then comes to print statement, here u r using y, which is not assigned any value, so it pops up that error. if u just declare y, but dont use it i.e put u'r print statement in comments then u will not get error
java is designed in that way, if it were c or something may be u get a segmentation fault or some junk value.
hope this helps
-Preeti Pathak
hi ,
plz post for me too,
my email is :
ppathak@hawaii.edu
thx,
Preeti Pathak
Hi Jayashree!!
i am sure u can get lot of material on web on RPC. just try out some search engine like google.
i would like to give u some idea about it:
RPC is rmote procedure call. it means, if u have a method on some computer, u can just call the method with appropriate paramters as if that method was on local computer.
java's rmi is extended rpc.
if u want to develop whole rpc system b u'r self only by using java , then here is some sketch:
* create a server, this must
- wait for some client,
- client send request say invoke a method , with method name &
parameters
- server extracts method name & parameters then calls that
method, gets return value & send it back to client

* create a client which requests server
- client should send method name & parameters
there r lot of implementation issues which u got to consider b4 implementing .
hope the above is of some help. i will try to check some good site which has ample info abt rpc
regards,
Preeti Pathak
24 years ago
As of now i cn think of 2 ways:
*
If u r reading & wish to write back to same file then i would suggest, u concatenate all the lines which u need in a StringBuffer & then once u r done with reading the file, close it & open it in write mode & write stringbuffer to it.
PS: take care for \n
* write all the lines u need in a temp file , then copy the contents back to the old file
Hi !!
From the way i understand u'r question, i think u r reading frm one file but writing into a different file , right!
i am assuming u have some function which evaluates which line is to be removed & returns true / false. if return value is false then write to file
basically the code will be some thing of this sort
FileReader fr=new FileReader("time.txt");
BufferedReader br=new BufferedReader(fr);
boolean b;
while((str=br.readLine())!=null )
{
b = evaluate(str);// evaluate is a function which determies
// whether line has to be removed or not
if (b==false)
{
// code for appending
}

}
there are many other ways of doing the above.
i hope i am clear
cheers,
Preeti Pathak
Hi!!
the program compiled & ran well.

i think its problem with some classpath for u
regards,
Preeti Pathak
24 years ago
Hi !!
i am not 100% sure , but i think this is the ans:
i tried putting an add method in both Parent & Test , then the Test method is invoked, what it means is :
if u refer variables , then corresponding variables will only be accessed i.e if u say
Parent p = new Test() , & access p.i, where i is a variable
the value in Parent.i is printed not the child &
if u call a method say add which is both Parent & also in Test
and if u write
Parent p = new Test() & if u call
p.add()then the Test add is called.
hope this is clear...
Regards,
Preeti Pathak
24 years ago
Hi !!
iam posting this again bcos i dint see the reply i posted.
well i think:
if u close the o/p stream associated with a socket, the socket also does not close, infact only o/p stream closes i.e u cannot o/p anything, but u can create a new o/p stream to the socket & write .
hope i am clear
regards,
Preeti Pathak
Hi!!
what i think is :
when u write out.close(), it means only the output stream for that socket is closed & not the socket itself, if u wish u can again create a new output stream & attach it to the socket after the out.close() statement
i hope i am clear.
regards,
Preeti Pathak
thx Ankur,
i wonder what is JLS :-).
i dont know if this was posted earlier. if so plz let me know the link.
my q is
byte b=0;
b+=1;
// b = b+1;
b+=1: works & answer 1 is shown
b=b+1: doesnt work, it gives compile time error.
i understand y it gives error for b=b+1
but i dont understand y it gives 1 for b+=1;
could anyone clear this plz.
thx in adv.
i think answers 1,2 r orrect, but answer 3 is not
if answer 3 is valid , then we got to write as
2>>1 instead of 1>>2, bcos 1>>2 gives 0
well even though one thread is active in a single processor, see the following scenario:
consider a thread has some int variable , it reads it & then process it
one more thread which changes that variable & does some other stuff.
now, consider thread1 reads int value, then scheduler decides to run thread2, now thread 2 changes the value,then thread 1 starts again, but thread 1 has old value,
this is what we dont want, one thread using old value other using latest value. hence we got to lock those objects
hope this helps u
i agree finally will always be executed , but only exception is if there is no System.exit(..) stuff b4 finally blk