Win a copy of Head First Android this week in the Android forum!

Rajeswari Kumar

Greenhorn
+ Follow
since Mar 23, 2007
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 Rajeswari Kumar

Yes Yes. Thanku. It didn't strike for me.
This is a question from whizlabs.

class AutoBox2 {
public static void main(String []ar) {
Float F=new Float(9.0);
float f=(float)9.0;
System.out.println(f.equals(F));
}
}
When I am trying to compile the program, following error has come
AutoBox2.java:6: float cannot be dereferenced
System.out.println(f.equals(F));
^
1 error
What is called dereferencing. But if it is given as
System.out.println(F.equals(f));
code compiles fine. Please explain me.
Sorry Barry. I don't know whether it is a brain dump or not. My friend forwarded me a set of questions. I got this question from there. Iam really sorry.
regards
Rajeswari
Congrats Megha. Excellent score.
14 years ago
Thanku. Sometimes iam really get confused
One question from javabeat.net

public static <T> void addandDisp(Collection<T> cs, T t)
{
for (T o : cs)
{
s.add(o);
}
for (T o : cs)
{
System.out.println(o);
}
}

//call 1
List<? super Object> ls1 = new LinkedList<Object>();
addandDisp(ls1,new String());

//call 2
List<? extends Object> ls2 = new LinkedList<Object>();
addandDisp(ls2,new Object());

//call 3
List<Object> ls3 = new LinkedList<Object>();
addandDisp(ls3,new String());

//call 4
List<? super Object> ls4 = new LinkedList<Object>();
addandDisp(ls4,new Object());

Which call(s) to above method(addandDisp) are error free?

a)only 3

b)only 1 and 3

c)only 1 and 4

d)only 1,2 and 3

e)only 1,3 and 4

Answer e)

(call 2)Method call 2 cannot work,because the compiler cannot gurantee
the type to substitute.But in all other calls it is guranteed.

My doubt is how we can add String in call1.
Congrats Damodar
14 years ago
Congrats Sampath. Can you narrate your experience

thnaks
Rajeswari
14 years ago
Thanks Anil. Now i got it
What is the difference between adding type in reference and object creation

ArrayList sampleList = new ArrayList<Integer>();// type information is added in object creation
ArrayList<Integer> sampleList = new ArrayList(); // type information is added in reference

In upper bound(using super) we can add elements I think
But in lower bound(using extends)it is not so.

Please clarify this

thanks
Rajeswari
ArrayList sampleList = new ArrayList<Integer>();
ArrayList<Integer> sampleList = new ArrayList();

What is difference between above two statements. Are they type safe.

Can anybody explain the difference between upper bound and lower bound in generics in terms of adding elements and passing/returning values.

thanks
Rajeswari
Congrats. Thanks for the advice
14 years ago
hi suleman
First of all congratulations for your score.
Did you buy only enthuware. Is it worth buying.
Can you suggest scjp1.5 mock exam links. Iam able to find only scjp1.4

regards
Rajeswari
14 years ago