谁知道这3个程序的输出结果?

来源:百度知道 编辑:UC知道 时间:2024/09/25 12:12:53
1.
<%@ page contentType="text/html;charset=gb2312"%>
<html>
<body>
<%!double sum=0,i=1,j=1;
synchronized void aaa()
{
number++;
sum=sum+i/j;
j=j+2;
i=-i;
}
%>
<%aaa();%>
<%=sum*4%>
</body>
</html>

2.
<html>
<head>
<title>Scriptlet test page</title>
</head>
<body>
<h1>Scriptlet test page</h1>
<%
for(int i=0;i< 3;i++) {
out.println("<b>Hello World. This is a scriptlet test " + i + "</b><br>");
System.out.println("This goes to the System.out stream " + i);
}
%>
</body>
</html>

3.
<%@ page contentType="text/html;charset=GB2312" %>
<HTML>
<BODY&g

第一题有错误,number没声明,不知道这个是干什么的,好几行都没用,结果是:4.0
第二题:前台:Scriptlet test page
Hello World. This is a scriptlet test 0
Hello World. This is a scriptlet test 1
Hello World. This is a scriptlet test 2
后台:This goes to the System.out stream 0
This goes to the System.out stream 1
This goes to the System.out stream 2
第三题:i是随机的,转到哪一个都有可能

第一个写错了吧 不过结果值应该是4.0;
第二个 <b>Hello World. This is a scriptlet test 0</b><br>
This goes to the System.out stream 0
<b>Hello World. This is a scriptlet test 1</b><br>
This goes to the System.out stream 1
<b>Hello World. This is a scriptlet test 2</b><br>
This goes to the System.out stream 2
第三个 是随机的 也就是说有可能是 跳转到test1.jsp 也有可能跳转到 test2.jsp