Welcome Guest | Sign in | Register
Language Fundamentals - Discussion Page For Q.3013 | 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 static void main(String[] args){
double d = 10 / 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:Runtime exception

Explanation:
  Division by zero on integer literals will throw
a runtime error.

Comment on this Question

Name:

Loading...




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