Vivek Shinde

Greenhorn
+ Follow
since Jan 09, 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 Vivek Shinde

Hi Everybody
I just passed the programers exam yesterday. I got 61% whew!
I want to thank JavaRanch and everybody who has contributed to the disscussions. They were a great help.
Other then threads an I.O. There were a lot of questions on Object referencing.
Bye and all the best for everybody else who is preparing.
23 years ago
Hi Tod
Its like this -
s points to the string object with "abcde".
When you call s.toUpperCase it returns a string object with "ABCDE" as it content.
s = s.toUpperCase reassigns s (so to speak) and s now refers (or points) to the second string object. This a new String object and its not that the old one is changed. So strings are immutable as you rightly pointed out.
Hope this makes sense. Others please correct me if I wrong.
Thanks h33 and Jane
What you said did clear a lot of things.
Vivek
Thanks Everybody, You were a great help
Vivek
Hi folks !
A question from JExam
Select the correct statement regarding the following piece of code.
File f = new File("C:\\Large.txt")
a) On execution a file called "Large.txt" will be created on the local harddisk
b)The code fails to compile on a Unix machine because the directory Seperator is not correct
C)A file is not created when the code is executed
d) an excepton is trown at runtime if the file "large.txt" already exits
e) The code fails to compile since this is not a valid constructor for the File class.
I thought the correct answers were b and c . But the answer given is only c. Isn't the file separator '\\' unique to windows ?
I do not have unix on my machine to try it out. Can any one help out ?
Regards
vivek
Hi Simon and Ameen
Thanks for the replies. I did know that primitives (int, float etc) pass by value but what about classes ? When I passed Integer to c.method() and changed the value , the changed value was not reflected in the calling program. does this mean that Classes also pass by value ?
Hi
I came across this question on Jquest exam (I think):

what is printed out when the following code is executed?
code:
java Mystery Mighty Mouse
1. class Mystery {
2. public static void main(String args[]) {
3. Changer c = new Changer();
4. c.method(args);
5. System.out.println(args[0] + " " + args[1]);
6. }
7. static class Changer
{
8. void method(String s[])
{
9. String temp = s[0];
10. s[0] = s[1];
11. s[1] = temp;
12. }
13. }
14. }
end of code.
a) Mighty Mouse
B) Mouse Mighty
C) code fails o compile
d) code compiles but runtime exception is thrown
I thought the answer was a) but it actually is B) . (I ran the code too). But I didn't understand why. I thought the array s in 'method' is local and so no changes will get reflected in the calling program. I tried passing different types to the method - primitives,wrapper classes like integer etc and in none of the cases did the value change in the calling program.It changes only in the case of an array being passed.
Can anyone provide an explanation ?
Vivek