Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

SCJP doubt

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai,
I am planning to appear for Sun Certification and I have joined new in this forum. Let me have those advantages of clear concepts.
Thanks.
Question 1.
Which of the following statements are valid for a method which overrides the foll:
protected void method(int x) {..}
a. overiding method takes int as only parameter.
b. Overriding method must return a void.
c.overriding method can be declared as private.
d.overiding method can return any value it wishes.
Kindly clear my doubt as I have chosen a,b. Is that true?
Quetion 2:
Is -0.0 different from 0.0?
In that case what would be the right answer for ceil() and floor() of -0.5? Kindly clear my doubt.
 
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your answer for Q1) is correct.
For Q2), yes in Java -0.0 is different from +0.0 and ceil(-0.5) will give -0.0 as result.
regds
maha anna
 
Ranch Hand
Posts: 477
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maha: In ABHILASH test there is a question about:
System.out.println(Math.min(0.0,-0.0));
Where -0.0 is the result, what�s true about this?
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even 0.0 is a signed number. -0.0 is less than 0.0 .
However, -0.0 == 0.0 returns true.
I know it is weird, but that's the way it is
Ajith
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Quetion 2:
Is -0.0 different from 0.0?
In that case what would be the right answer for ceil() and floor() of -0.5?
Explanation:-
JLS says:
Positive zero and negative zero compare equal;
0.0==-0.0 is true
0.0>-0.0 is false.
But other operations can distinguish positive and negative zero;
1.0/0.0 is positive infinity,
1.0/-0.0 is negative infinity.
So Math.ceil(-0.5) gives -0.0
Math.floor(-0.5) gives -1.0
Hope this may help

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can any one give a link to the ABHILAASH test ?
Thx
 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here it is http://www.angelfire.com/or/abhilash/Main.html
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic