Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews Application Program Interviews:AutoCADBEA WeblogicBioinformaticsBizTalk ServerBug Tracking ToolsBugzillaClarify CRMCoding StandardsComputer Aided Design (CAD) DesignerCVSGIMPJMXLINQLoadRunnerMagentoMATLABMicrosoft AccessMicrosoft ExcelMicrosoft OfficeMicrosoft OutlookMicrosoft WordModel View Controller (MVC)OLAPOOADQuickbookRational RobotRDFSchemaSiebelSilkTestSVGTest PlanTesting ToolsUnity 3D DeveloperVRMLWCF SDKWPFXML DOMXPointer
Copyright © 2018. All Rights Reserved
BEA Weblogic Interview Question:
Considering the code below, which of the lines of code (given in the choices) should be placed at line 4 to make this JSP prints My score is : 100? Please ignore the line numbers for the purpose of validity of the JSP code.?
Submitted by: Administrator1:
2:
3:
My Progress Report
4:
5: <% score++; %>
6: <%= "My score is : " + score %>
7:
8:
a. <%! int score = 99; %>
` b. <% int score; %> `
c. <%@ int score = 99; %>
` d. < int score = 99; />
A is the correct choice. The above JSP will work on declaring and initializing the variable score. The syntax for declaring and initializing a variable in JSP is as follows:
<%! variable=variable_value ; %>
Thus A is the correct choice. The <%@ ... %> tag is used to declare directives like include directive. Thus choice C is incorrect. The <% ... %> code is used to insert scriptlets (lines of code in java) like the one at line 5. The code written inside the scriptlet becomes part of the service() method of the generated servlet. Thus 'score' becomes the local variable of the service method. And for this JSP to compile properly, the variable 'score' should have been initialized. If "<% int score; %>" is replaced by "<% int score=99; %>" , the choice B would also be correct. In the present scenario, the choice B will give compilation error saying "Variable score may not have been initialized". Choice D is incorrect as it's not a valid tag.
Submitted by: Administrator
2:
3:
My Progress Report
4:
5: <% score++; %>
6: <%= "My score is : " + score %>
7:
8:
a. <%! int score = 99; %>
` b. <% int score; %> `
c. <%@ int score = 99; %>
` d. < int score = 99; />
A is the correct choice. The above JSP will work on declaring and initializing the variable score. The syntax for declaring and initializing a variable in JSP is as follows:
<%! variable=variable_value ; %>
Thus A is the correct choice. The <%@ ... %> tag is used to declare directives like include directive. Thus choice C is incorrect. The <% ... %> code is used to insert scriptlets (lines of code in java) like the one at line 5. The code written inside the scriptlet becomes part of the service() method of the generated servlet. Thus 'score' becomes the local variable of the service method. And for this JSP to compile properly, the variable 'score' should have been initialized. If "<% int score; %>" is replaced by "<% int score=99; %>" , the choice B would also be correct. In the present scenario, the choice B will give compilation error saying "Variable score may not have been initialized". Choice D is incorrect as it's not a valid tag.
Submitted by: Administrator
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.