What is legal about JSP scriplets

  1. A loop can begin in one Scriptlet and end in another

  2. Statements in Scriptlets should follow Java Syntax

  3. Semicolon is needed at the end of each statement in a Scriptlet

  4. All the above


Correct Option: D

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) A loop can begin in one Scriptlet and end in another - This option is incorrect. In JSP, scriptlets are used to embed Java code within the HTML markup. Each scriptlet is treated as a separate block of code and cannot span across multiple scriptlet tags. Therefore, a loop cannot begin in one scriptlet and end in another.

Option B) Statements in Scriptlets should follow Java Syntax - This option is correct. In JSP, scriptlets are used to write Java code. Therefore, any statements written within a scriptlet should follow the syntax rules of the Java programming language.

Option C) Semicolon is needed at the end of each statement in a Scriptlet - This option is correct. In Java, semicolons are used to mark the end of a statement. Similarly, in JSP scriptlets, semicolons are required at the end of each statement to indicate the end of the line of code.

Option D) All the above - This option is correct. Both options B and C are true. Statements in scriptlets should follow Java syntax, and semicolons are needed at the end of each statement in a scriptlet.

Therefore, the correct answer is D) All the above.

Find more quizzes: