Identify which of the following lead to: a compile-time error, run-time error,or
ID: 3670474 • Letter: I
Question
Identify which of the following lead to: a compile-time error, run-time error,or logical error and which are valid java identifiers from (g - I)?. Writing print1n when you should have written println Forgetting a} at the end of a method body Calculating product of numbers instead of sum of numbers Typing b, instead of b.in System.out.println Forgetting to put an end of line character Subtracting a variable by itself in the denominator Remainder 9_multiple addTwolntegers PI_VALUE highestof4 diff_&_divExplanation / Answer
Please find the solutions
2)
a) Writing print1n instead of println leads to 'compile time error'
Reason:Upon compilation JVM validates the existance of the methods
(here checks for print1n and gives compilation error)
b)Forgettig the { at the end of method body leads to 'compile time error'
Reason:Upon compilation JVM checks for balanced parathesis
c)Calculating the product of numbers instead of sum of numbers
leads to Logical error(will not have compile or run time errors that stops execution)
d)Typing b, instead of b. leads to compile time error(because .is operator where as , is not)
e)forgetting to put an end of line character (does not cause any error)
f)substracting the variable by itself causes (runtime error)
Because it is syntactically correct but result in infinite value whene divided by zero,
g)Remainder--- valid
h)9_multiple-- Invalid (Identifier should not start with number)
i)addTwoIntegers--valid
j)PI_VALUE--valid
k)highestof4--valid
l)diff_&_div--Invalid (Identifier should not have special characters other than _(underscore))
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.