Welcome Guest | Sign in | Register
Language Fundamentals - Discussion Page For Q.3005 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Language Fundamentals > Questions and Answers

Q:   What is the result of trying to compile and run the following code.
public final static void main(String[] args){
double d = 10.0 / -0;
if(d == Double.POSITIVE_INFINITY)
System.out.println("Positive infinity");
else
System.out.println("Negative infinity");
}
A. output Positive infinity B. output Negative infinity
C. Will fail to compile D. Runtime exception

Answer and Explanation

Answer:output Positive infinity

Explanation:
There is no such thing as a positive or negative zero.
Hence the result is always positive infinity.

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.