Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question Bank ID : 41

 
Sar Lolla
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which of the following statements are TRUE (Choose 2).

1) <%! int i; %> is a variable declaration that has object scope within
the servlet.


2) <% int i; %> is a variable declaration that is class scope to the service method.


3) <%! int i; > a variable declaration that has local scope within the
service method of the servlet

4) <% int i = 0; %> is a variable declaration that has local scope within the service method of the servlet.

The mock test is giving the answers as 1 and 4. Why? what is the meaning of object scope?

Can some one please help me? I marked 2 and 4 as answers.
 
Mikalai Zaikin
Ranch Hand
Posts: 3369
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy

1)



will be converted at JSP translation time to:



which is object scope (global scope)


4)



will be converted at JSP translation time to:



which is local scope (method scope)

NOTE, you can have both :


and


in the same JSP - one variable will shadow another

regards,
MZ
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic