sumi rankan

Ranch Hand
+ Follow
since Apr 07, 2008
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by sumi rankan

Thats awesome! Congratulations!
[ November 10, 2008: Message edited by: sumi rankan ]
15 years ago
Congrats! thats a great score!
15 years ago
Whew! I cleared SCJP1.4!!!
Thank you for all the ranchers helping me in clearing my doubts.

I know this version is outdated..when I started learning java, I didnt know much about it .Having much confidence(!) in me,I wanted to take advantage of Sun's promotion of free retake and immediately bought a voucher .Later when I joined this forum,I realised I made a mistake buying 1.4 voucher.Well ...past is past...

I started of by learning Head First Java which really is an excellent book for a novice like me.This book is hilarious.Though this has been said before,honestly...I have'nt read anything like this before!

Then when I was confident enough with the fundamentals I bought the scjp book by Kathy Sierra and Bert Bates.I almost spent 4 months and the past 1 month was spent in trying out the free mock exams available given in this forum.

Two weeks back ,I bought the enthuware mock exams and completed all the 12 tests including the trial one.My average in all the tests were 70% which ranged from 55% to 80%.
In the master exam from the book,I scored 80%.

I took the test yesterday.Actually ,I thought the questions were easy compared to enthuware and I might get only 3 or 4 of them wrong.But to my surprise I got 9 questions wrong .May be I overlooked somethings due to nervousness...It took almost the first 10 questions to settle down.Time was more than enough.My least scores are from Threads and gc.I used to get all the questions right in gc in the mock exams.I am really puzzled by this one and I expected something like this in threads!

Well ...its over now...For all the people out there trying for this exam.. All the very best...

Last but not the least ,I would like to thank the authors Sierra and Bates for their wonderful book without which this might not be possible...
[ November 04, 2008: Message edited by: sumi rankan ]
15 years ago
This is from enthuware test.

public class TestOuter
public void myOuterMethod()
// 1
public class TestInner { }
public static void main(String[] args)
TestOuter to = new TestOuter();
// 2

Which of the following options correctly instantiates a TestInner object?

Select 2 correct options
a. new TestInner(); at //1

b. new TestInner(); at //2

c. new to.TestInner(); at //2

d. new TestOuter.TestInner(); at //2

e. new TestOuter().new TestInner(); at //1

The correct options given are
a. new TestInner(); at //1
e. new TestOuter().new TestInner(); at //1

I got the first one right.For the other instantiation ,I was searching for an answer TestInner() at //2.

I felt it was kinda misleading to ask for an answer to be placed at //1 and //2 and giving the answers only for //1.May be I misunderstood the question!

Anyway ,my concern is not this qustion..but in the real exam, will there be any ambiguity as to how to answer the question?!

Because you know,I dont want to lose a question just because it has been worded in such a manner.

May be I am reading too much into this ...I dont know!
I just wanted to know if others felt this way or its just me...
With the exam date fast approaching,I might just be panicking!
This sure will give you possible loss of precision error.But if you initialize final int i where you declared it, will compile fine.Because the compiler sees that 127 will surely fit in a byte and its value is not going to change since it is final.
But, if you just say int i=127 or anything <127 ,the compiler cannot be sure if that value is going to be same.So it flags an error eventhough the value fits comfortably in a byte.
Another thing,this holds true only if the value is <=127.If the value is above the range of byte,even if it is a comile time constant ,compiler flags an error.Hope this clears!
This is from enthuware:

Consider these two interfaces:

interface I1
void m1() throws IOException;
interface I2
void m1() throws FileNotFoundException;

What methods have to be implemented by a class that says it implements I1 and I2 ?

The answer given is
public void m1() throws FileNotFoundException {}

I thought the answer would be public void m1() throws IOException {} ,since the implementing method should be able to handle both the exceptions .Did I miss something here?
ok obviously I did but cannot figure it out...
Congratulations! great score!
15 years ago
Hey Marcus,
The code of yours sure did show some nuances in the initializing process.Thanks for sharing with us.Now we know why you take >15 months to
take a shot at scjp.Wish you all the best!

Originally posted by mukki pandey:
but then where does immutabilty comes in picture in KB book i saw e.g like

s.concat without assigning doesnt changes the value otherwise if you
do like s= s.concat("abc");

then value changes

The same thing here.
when you say
String s="abc";
s.concat("def"); // s is not changed by this.

System.out.println(s); //prints abc

s=s.concat("def"); // now "abc" is abandoned and s now refers to abcdef

System.out.println(s); //prints abcdef

So here basically the string reference is changed(not the object)to refer to the newly created object.
2 objects ,abc and abcdef are created.
Hope this clears your doubt.

Originally posted by mukki pandey:
public class Stngcheck {

* @param args
public static void main(String[] args) {
Stngcheck ss = new Stngcheck();
String s1="1";
String s2="2";


public void go(String s3){


Hi Javaranchers

since string is immutable object why does s2 prints 1 i know this is pretty silly but i want to know pleaseeeeee

One important thing we need to remember is String objects are immutable;String references are not.

In the above example,
s2 reference is changed to point to another object which s1 points to("1").The object which s2 used to refer to "2" is still there but not reachable(abandoned).So the String objects are as such immutable.

It will be more clear if you could just draw a picture.
This pictorial representation is very helpful for solving gc problems too.Trust me.When I started learning this concept,I just tried to solve mentally but couldnt get it.Thats when I started using diagrams.

Moreover the String immutability is also shown by pictorial representation in K&B book.Please go over this chapter once again.I am sure You can get it.

O..another thing.No question is silly.I have asked sillier questions before.Always there will be a patient someone to answer these dont worry.

hope this helps.
[ October 18, 2008: Message edited by: sumi rankan ]
Which of the following statements are true?
1 A reference to a primitive is eligible for garbage collection when it is set to zero.

false.Assuming "reference to primitive" is primitive wrapped in an object and referred by a variable,is eligible for gc only when this is the single live reference to that wrapper.

2 A reference to a primitive is eligable for garbage collection when it is set to null.

false .Again by the same assumption,the object will only be eligible if there is no other reference other than the one set to null.Setting one reference to null will not make the object eligible for gc.

3 An array object is eligible for garbage collection when it is no longer reachable.

true.Since it has been explicitly given that the object is no longer reachable.

4 Setting an object reference to null will guarantee the object is eligable for garbage collection.

false.There is no guarantee that if one reference is set to null,the object will be eligible for gc.There may be some other references.

So ,unless it has been given explicitly that there are no live references to this object or this object is no longer reachable,that particular object will not be eligible for gc.
[ October 17, 2008: Message edited by: sumi rankan ]
If you are new to java, head first java by Kathy Sierra and Bert Bates is the best book to start and Thinking in java by Bruce Eckel is a better book too.After spending some time (may be some months as per your time availability)with those books and coding alongside, you can start with scjp book by K&B.