Create a free account on Computer Sir Ki Class and unlock access to valuable learning resources.
Exam Paper Downloads: After registering and logging in, you can download exam question papers in PDF format to practice and prepare for your exams.
Student Support: Get assistance with your doubts, queries, and questions related to your studies. Our support is here to help you understand topics and resolve your learning difficulties.
Register today and make your exam preparation easier and more effective!
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;
Answer:
(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 erroras the variables b and c do not have their data types declared.
Notes:
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.
C. Sir| Created: 30-Mar-2018 | Updated: 16-Apr-2019|ICSE2016