error types – Computer Sir Ki Class


Lost your password?

Don't have an account ?
Register (It's FREE) ×


Exam Questions-ICSE2016-01D #JAVA#4216    siteicon   siteicon  

Problem Statement - error types

Name the type of error (syntax, runtime or logical error) in each case given below:
(i) Math.sqrt (36-45)
(ii) int a;b;c;


TC++ #4216

(i) Math.sqrt (36-45)
This will return NaN (Not a Number) to indicate that proper result is not possible. One may consider it a runtime error as it comes at runtime.  But technically speaking it is a Logical Error as no exception occurs but result is undesirable. It is just a case where the result is not possible to due to limitation of the method used.
(ii) int a;b;c;
This would be a Syntax Error found at compile time error as the variables b and c do not have their data types declared.


  • Math.sqrt(-9) and square root of a negative number are not real values. There are alternative ways to handle complex and imaginary numbers in java but sqrt() method will return NaN.


sunmitra| Created: 30-Mar-2018 | Updated: 16-Apr-2019|ICSE2016