Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!

hari harann

Ranch Hand
+ Follow
since Aug 07, 2008
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 hari harann

Thanks kurt..
By the way i just want to know how many questions will be asked as
1)drag and drop
2)fill up the text box

Please let me know.
Thanks in advance.
Can someone please compare the difficulty level of scjp1.5 exam with the chapter wise questions given in kathy book?? i am going to take exam this monday..
Given a properly prepared String array containing five elements, which range of results could a
proper invocation of Arrays.binarySearch() produce?
A. 0 through 4
B. 0 through 5
C. -1 through 4
D. -1 through 5
E. -5 through 4
F. -5 through 5
G. -6 through 4
H. -6 through 5
3 G is correct. If a match is found, binarySearch()will return the index of the element that was matched. If no match is found, binarySearch() will return a negative number that,
if inverted and then decremented, gives you the insertion point (array index) at which the value searched on should be inserted into the array to maintain a proper sort.
but i feel option G is incorrect, the answer is option E. am i right??
Hmmm..after a very long search, the below link gave me the solution for my queries,

Anyway hereby i want to THANK HENRY you were very kind replying me. after i went through the above link i found that my issue was really a basic thing in generics.
hi kanishka, i think our issues are similar. please check this link
but am not still clear with wat was explained there..
class a
public void adda(List<? super c> l)
l.add(new b()); // even i could not add b obj to my list..
yes henry, you are perfectly right in your explanation.
but am in desparate need of guidance.
the following is what i learned from kathy book.

public void addAnimal(List<? super Dog> animals)
is essentially, "Hey compiler, please accept any List with a generic type that is of type Dog, or a supertype of Dog.
<? super ...> syntax, you are telling
the compiler that you can accept the type on the right-hand side of super or any of its supertypes.

my case, looks similar to this. but...
can someone explain this please..
Thans Henry.. i will surely try my own coding..
sorry Henry, i really do not understand what do you meant by this,

"Hence, it will only allow you to add something that is of class 'c', or a subtype of class 'c', because those objects are also IS-A super type of all objects of class 'c'."

where does this subtype comes into picture??

Also, do you mean that adding an object of class 'a' is not legal??so it gives a compiler err??or exception???
hi vyas, i think the list is actually 'typed' for class b. so how ll it work for class 'a', which is a super class of class b???
List<b> l=new ArrayList<b>();

am i right??
Thanks campbell, i have understood that. but my issue is the following sentence,

"the class must provide a static method or variable that allows access to an instance created from within the class"

please explain about the static method which they have mentioned here..
12 years ago
Constructors can use any access modifier, including private. (A private
constructor means only code within the class itself can instantiate an object
of that type, so if the private constructor class wants to allow an instance
of the class to be used, the class must provide a static method or variable that allows access to an instance created from within the class.)

can someone please explain the stuff given inside ( ). i really dont understand what they meant...
12 years ago
hi sumit, of course we can case it this way,
ani.add((c)new Object());
but, my question is, my program is purely GENERIC, then we dont need a cast. in this case will the compiler complain??if so, the GENERIC property is not satisfied.. am i right???

hi badal,
what you have told is nice, but that is not my question is..

Thanks for both of you guys.. please let me know if you have any more details..