• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Mock question

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
Given the following pairs of method declarations, which of the statments are true?
1.
void perform_work(int time){ }
int perform_work(int time, int speed){ return time*speed ;}

2.
void perform_work(int time){ }
int perform_work(int speed){return speed ;}
3.
void perform_work(int time){ }
void Perform_work(int time){ }
A- The first pair of methods will compile correctly.
B- The second pair of methods will compile correctly.
C- The third pair of methods will compile correctly.
D- The second pair of methods will not comile correctly.
E- The third pair of methods will no compile correctly.
The answer is A and D but I think that the answer is A,D,E because I believe that can not have two identical methods in the same class. And I try compile this but compile error.
Can someone help me?
Thank you in advance.
 
Ranch Hand
Posts: 375
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jordi ,
You know the answer - Just think CASE SENSITIVE .
Peace
Ashish
------------------
VoodooBytes - Bit Demo Applet
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Exactly,
you have two different methods in this case.

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This question is very similar to the Review Question 4.10 in Khalid Mughal's book. You may want to take a look at the explanation the authors have given at the back of the book if your questions are still not answered.
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
My curious is what is the problem with C? I think either C or E should be correct. As you said E is not correct, how about C?
Sorry I do not have Khalid Mughal's book, I can not check with that.Thanks for you reply!
 
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
The answers should be A,C and D.
C is correct because the third pair has two different method names, which implies method names are case-sensitive.
-- Sandeep
SCJP2, OCSD(Oracle JDeveloper), OCED(Oracle Internet Platform)
[This message has been edited by Desai Sandeep (edited September 17, 2001).]
 
Kathy Wang
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for ur quickly reply!
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you guys noticed, the original post says A & D are the correct answer choices whereas the correct answers (for the original post) are what Desai Sandeep suggested (A, C & D). This is because, I believe this quesion has been slightly modified from review question 4.10 of Khalid Mughal's book for which the answers A & D are appropriate.
For the benifit of those who don't have the book...I have posted that question below.


The correct answer choices are choices (a) & (d).
Hope this helps
Shyam
[This message has been edited by Shyamsundar Gururaj (edited September 17, 2001).]
 
Time flies like an arrow. Fruit flies like a banana. Steve flies like a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic