ayush raj

Ranch Hand
+ Follow
since Jan 15, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
6
Received in last 30 days
0
Total given
5
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by ayush raj

Chandramouli Rajagopalan wrote:Wouldn't khalid mughal help?



It would do but maintain your pace accordingly ..

Chandramouli Rajagopalan wrote:I attended the core java course offered by niit technologies a few months back,i want to start preparing for ocjp now,my voucher expires on 30th november,can you advise my on the no.of hours per day i need to spend ,the methodologies to adopt and the resources needed to clear the exam successfully.



Depends upon the grasping power your brain . Follow the OCPJP syllabus strictly and get a reference book . I think Kathy Sierra and Bert Bates book would be the best one to refer . It has the relevant topics in a very organised way once you do have the idea of core java . Follow the book strictly and remain intouch with the book upto the exam . Practise as much as you can , code as much as you can .

Thanks

Rahul Choudhary wrote:If explanation is given for such concept in K&B please could you provide me with page number.



Its given in page 618 describing briefly with what operation can be performed on which of the generics code and what cannot be performed . Read it thoroughly . That would make sense .

You need to be very clear with this . By saying <? extends Object> , we are saying "I can be assigned a collection that is a subtype of LinkedList and typed for <Object>" and its like we swear that we wont be adding anything to the collection . <? extends> doesn't allow you to add either in the same method or in the different method . In the first case , its self explanatory that LinkedList<Object> will accept any of its sub-types also as Integer is-a Object , String is-a Object .... and so on . However , in the second case , even if you really want that the " LinkedList<? extends Object> l " should contain all that you have added , you need to change your code as the following :



Check it and tell me if its clear or not . And nothing to thank me .. thanks to Kathy Sierra and Bert Bates for the magnificent book provided by them
K&B book is just sufficient for the exam basics . The practise questions given at the back are a bit tougher than the real questions on the exam but are built basically to improve our command over the language . Go through the two minutes drill at regular intervals as well as the practise questions to get the concepts clearer . You can also refer the online docs provided by oracle . Additionally Khalil Mudgal book also comes for the same , but i would suggest go either through K&B or Khalil Mudgal . In case of any doubt , post it in the forum , we are here for your help ..
" Always try to learn from your mistakes and work upon it .. !! "
@Rahul Choudhary : In main method , the set doesn't have any generic code , so whatever you add gets added (with warning that its not a type a safe operation, Remember compiler warnings are not the same as compiler error) without any error . However , when you are passing it to the method , you are specifying that the set now will contain only numbers in it . It does not check for the existing contents , but rather gets alert to whatever is added in future . Hence , if you now try to add a string in the set , you would surely be prompted with an error !!
Seems to be installation problem .. re-check it ..
Please use code tags. Telling you this once again . The code snippet you provided runs just fine in my JVM . Try re-compiling your code .
Always use code tags when posting codes in the forum . The Corrected code is given below. Check out the changes made yourself . If unable to find do tell it , would help ..


I was about to post this question from K&B . I have a clear concept regarding HashCode and equals method but i am not able to understand the hashMap , how does the mapping of key-value pair takes place , how is the 'bucket' chosen and what is the content of the 'bucket' and on what criteria the object/value is retrieved . Thanks in advance ..

Mansi Agarwal:
"what about " addListener" is it valid? "



Even I am of the opinion that addListener as well as removeListener should not be a valid JavaBean name . So , addMouseListener is the only valid name according to me in the entire list of names as provided
by you. But still , if anybody is sure about it , please do reply and let us know the accurate answer .


Paul Clapham
" For one thing a Java Bean's name should follow the original Sun guidelines and start with an uppercase character. "



I think not every name is a valid Java Bean method name as long as the parameters of the methods matches with the method's names.

Eg :- If addMouseListener() will take a parameter , it can only be a MouseListener reference i.e addMouseListener(MouseListener m){ }

However , to delete a Listener , "remove" and to register a Listener ,"add" must be preceded with the function name.

So i think deleteMouseListener and registerMouseListener are not valid .

Patrick Kasarski :
if you call a method as a parameter, the parameter method will execute first, before the method call of which it is a parameter?




Thats absolutely true . In your example also , the same thing happens .