Radha Kamesh

Ranch Hand
+ Follow
since May 19, 2007
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 Radha Kamesh

Hi everyone !

I cleared SCJP 1.4 with 91 % .

To Kathy Sierra and Bert Bates , i would like to say .....

You were the very reason for kindling my interest in java, your book was absolutely fabulous! With witty examples, clear explanations and funny comments all along....it made for delightful studying... without you this title most definitely would not have been mine... Thank you so much... keep up the great work..



To all members of javaranch,
... studying becomes so much more interesting with friends like you around... thanks for always coming forward to help... it added so much value to my prep...

regards,
Radha Kamesh
16 years ago
Hi friends,

I too have just completed the certification with 91% , and downloaded the logo... i'd like to paste it on my resume.. but how will that authenticate me ... should i also provide any link for use by potential employers??if so, then can anyone tell me what that link is?i am currently on an urgent lookout for a job.

Thanks in advance,

Radha
Sorry friends, this might turn out to be a really stupid doubt, but
i'm confused..

I dont get why this piece of code throws a NullPointerException at line 5



Thanks
yes... how careless of me...

Thanks friends...
Hi friends,

i dont understand why this code compiles properly?

class A
{
public A() {} // A1
public A(String s) { this(); System.out.println("A :"+s); } // A2
}
class B extends A
{
public int B(String s) { System.out.println("B :"+s); return 0; } // B1
}
public class C extends B
{
private C(){ super(); } // C1
public C(String s){ this(); System.out.println("C :"+s); } // C2
public C(int i){} // C3

public static void main(String[] args) {
C c = new C();
}
}


Since there is no no-arg constuctor in B ( we need to type it in because we have defined ome other constructor) , wont calling the super() from line C1 cause a compiler error?? what am i missing here?
sorry friends, the diagram for the exception hierarchy i had posted came out wrongly.. i have now out it in a code block for the structure to be retained......

according to the diagram, now both BaseException and RuntimeException derive directly from Exception...

i know that Runtime exception need not be declared... but is it wrong to do
so in this case?
hi friends,

in this piece of code:



output:

(int)d : -2
absolute val of d: 2.9
(int)absolute val: 2
i*= (int)(Math.abs(d): -4
(int)(-2* Math.abs(d)) : -5

i thought the last two statements would give the same output...
but looks like in the *= statement does the cast on each element and then gives the output... while the last statement does the cast on the whole result...

is this how it is supposed to happen?... i always thought the cast is performed after the operands are evaluated.. am i wrong?

thanks in advance
hi ranchers,

Given the code below

public class ThreadDemo extends Thread[
public void run(){
System.out.println("Thread started");
try{
Thread.sleep(20000); //20 seconds sleep
System.out.println("I am Back from my sleep");
}
catch(InterruptedException e){
System.out.println("I got Interrupted");
}
}
}
Which of the following statements are true?

A.Exactly 20 seconds after the start method
is called "I am Back from my sleep" be printed.

B.We can be sure that atleast after 20 seconds elapsed,
"I am Back from sleep" will be printed.

C.The delay between output "Thread started" and "I am Back
from sleep" is less or more than 20 seconds.

D.None of the above.

Answer given: B

Yes, i do agree that B will be correct... but only if there is a main method which starts an instance of ThreadDemo by calling start() ...
here should we assume anything and proceed?

going just by the question i would say option D is the correct answer ... am i right in doing so?
Hi friends,

please check out this question...

Given that method aMethod() throws BaseException, SubException and RuntimeException of the following exception hierarchy







Which of the following are legal

A.public class MyClass {
public void myMethod(){
aMethod();
}
}
B.public class MyClass{
public void myMethod() throws BaseException,RuntimeException{
aMethod();
}
}

C.public class MyClass{
public void myMethod() throws BaseException{
aMethod();
}
}

D.public class MyClass{
public void myMethod() throws Exception{
aMethod();
}
}

E.public class MyClass{
public void myMethod() throws RuntimeException {
aMethod();
}
}

Answers: C and D

what i dont understand is why option B is incorrect?
the quesion states "method aMethod() throws BaseException, SubException and RuntimeException ", then why cant we throw both BaseException and RunTimeException together from myMethod... the way we handle these exceptions is beyond the scope of this question right?can't myMethod choose to throw these exceptions? i know i'm missing something here.. can anyone explain???

thanks in advance
[ September 04, 2007: Message edited by: Radha Kamesh ]
Henry Wong,

That was a very clear explanation..Thanks for the info.. felt really confused on seeing the questions.. now its all clear..

Radha
[ September 03, 2007: Message edited by: Radha Kamesh ]
i found this mock question in Abilash's site...

Question 6.
An Interface can never be private or protected.

True
False

Answer Provided:
1.FALSE

But when i tried running such a case on my system, i got a compiler error stating " illegal modifier: only final and abstract are permitted"
Is this an errata question..??
hi friends,

Can anyone explain why this produces an output of "not Equal" while
instead of if(" String ".trim() == "String") , we replace if(" String" == "String") we get an output of "equal"... what happens internally?





Thanks in advance
[ September 04, 2007: Message edited by: Radha Kamesh ]
Sorry i forgot to mention that...

I meant the SCJP 1.4 exam...

Thanks,
Radha Kamesh
[ August 31, 2007: Message edited by: Radha Kamesh ]
Hi friends ,

will such questions ( implementing comparator... using compare() etc come for the exam?)




choose:
Compilation succeeds, compare() throws ClassCastException
Compilation succeeds, the output is 0 1 2 3
Compilation succeeds, the output is 1 2 3
Compile time error, the compare() method does not have the correct signature
Compile Time error, compareTo method from the Comparator interface has not been implemented.


Solution provided:
Answer 3 is correct.
The compilation succeeds and the output will be in ascending order (e.g.: 1 2 3).
The class Car is a Comparator but at the same time also a business object that contains the total of wheels for the car.

At line 20 the TreeSet is created, the TreeSet of the constructor takes in the Car() Comparator, this constructor creates a new empty set sorted according to the Car criteria. All elements must be mutually comparable by the car.compare(Object o1, Object o2) method. The Car object used to create the TreeSet does not belong to the set.

The cars are sorted by the total amount of wheels. 3 new objects are created and added to a list. When the TreeSet start sorting it will call the compare method and it compares the total of wheels. It uses the Integer compareTo method.
Thank you Jesper Young...

That made things very clear for me as well!,

Radha Kamesh
[ August 30, 2007: Message edited by: Radhika ]