• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

output

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
class Q81{
public static void main(
String args[]){
System.out.print(
Double.isNaN(3.0%0));
System.out.print(" ");
System.out.println(
Double.isNaN(3.0/0));
}//end main()
}//end class definition
what is the output of above program and y ?
thanks
rahul
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The output of the above code is :
true false.
because 3.0%0 gives NaN and 3.0/0 gives infinity.
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rahul Pawar:
class Q81{
public static void main(
String args[]){
System.out.print(
Double.isNaN(3.0%0));
System.out.print(" ");
System.out.println(
Double.isNaN(3.0/0));
}//end main()
}//end class definition
what is the output of above program and y ?
thanks
rahul


The output of the above program is true false.
Dividing a double by zero produces the result of Infinity.The value 'Infinity' indicates an effectively infinite result,in that it is greater than the largest number that can be represented as type double.
The operation 3.0%0 produces an indeterminate result.Hence the value of the output will be NaN.The value is referred to as Not-a-Number,indicating an indeterminate value.
 
I RELEASE YOU! (for now .... ) Feel free to peruse this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic