Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Any body can help ? Thank you

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Consider the following jsp code:



<html>
<body>
<% String a = "aaa"; %>
<%! String a = "AAA"; %>
<% String b = "bbb"; %>
<%! String b = "BBB"; %>
<% out.println(a+b); %>
</body>
</html>



What will be the output?



Options

Select 1 correct option.

A. aaabbb

B. aaaBBB

C. AAAbbb

D. AAABBB

E. Compilation error!
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
option 1 is the correct one.
 
muthu moorthy
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If there are two variables in the same name (local and instance), will take always local variable, is it so ?

Kindly explain. thank you
 
Kamesh Rao
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when you declare a variable in a declarative tag these are created as class level variables (available to all the methods of the class). If you declare variables in a scriplet it is created in the service method of the generated servlet class.
 
Ranch Hand
Posts: 292
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

If there are two variables in the same name (local and instance), will take always local variable, is it so ?


It's just basic java....I don't find any reason for any confusion here unless you're getting confused with plain old java concepts itself.
[ January 10, 2007: Message edited by: Sayak Banerjee ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic