Padma priya,
when the JSP file gets translated to
servlet the variables in declaration element <%! ... %> becomes instance variables to the class.
<%! String a = "AAA"; %>
<%! String b = "BBB"; %>
and
the variables in Scriptlet element <% ... %> becomes local variables to the in built service method.
<% String a = "aaa"; %>
<% String b = "bbb"; %>
and
the scriptlet element <% out.println(a+b); %> will be in service method.
Since the local and instance variable names are the same, the local variables overrides instance variables.
Hence, aaabbb is the output.
Thanks,
Vidhya