• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help me..help me..

 
Sungjin
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which is correct?....
if you know exactly,answer......please..ㅠ,ㅠ
question 1...
<%! x=0; %>
<% x=1; %>
<%! y=2; %>
<% y=3; %>
<body>
numbers are : <%=x> and <%=y>
</body>
</html>
what is the result of such jsp (one choice):
A) translation but compilation error
B) numbers are : 0 and 1
C) numbers are : 1 and 3
D) numbers are : 0 and 2
E) numbers are : 1 and 2
question 2...
Consider the following code below in the test.jsp :
...
<% x=1; %>
<%! x=0; %>
<%! y=2; %>
<% y=3; %>
<%! y=2; %>
...
<body>
numbers are : <%=x> and <%=y>
</body>
</html>
what is the result of such jsp (one choice):
A) translation but compilation error
B) numbers are : 0 and 1
C) numbers are : 1 and 3
D) numbers are : 0 and 2
E) numbers are : 1 and 2
 
Chintan Rajyaguru
Ranch Hand
Posts: 341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In both cases answer is a because variable type is not declared in any case. I mean it should be int x, int y and so on. If we are to assume that the declaration has been done, the answer in the first case is C because scriptlet code is put inside )jspService() method and declaration code creates instance variables. Variables local to the method get precedence over the instance variable and hence answer is C. In second case answer is A compilation error because y has already been defined and cannot be defined again. It's like
int y=2;
int y=2;
Remember type of y (int or whatever is missing and that is the first error).
Hope this helps
Chintan
[ February 02, 2002: Message edited by: Chintan Rajyaguru ]
 
Sungjin
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oops~~~~
my question is not right..^^
I doesn't intend it....
my question2 is correct...
=============================================
question 2...
Consider the following code below in the test.jsp :
...
<% x=1; %>
<%! x=0; %>
<% y=3; %>
<%! y=2; %>
...
<body>
numbers are : <%=x> and <%=y>
</body>
</html>
what is the result of such jsp (one choice):
A) translation but compilation error
B) numbers are : 0 and 1
C) numbers are : 1 and 3
D) numbers are : 0 and 2
E) numbers are : 1 and 2
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Sungjin"
Your name doesn't agree with the javaranch guidelines. Please atake a moment and re-register after reviewing the guidelines at http://www.javaranch.com/name.jsp
thanks for your cooperation.
- satya
 
Chintan Rajyaguru
Ranch Hand
Posts: 341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Before posting replies let us wait until Sungjin can reregister with proper name.
C
 
Sungjin
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not good at English,because I live in Korea=non-english-nation=...
I try to register,but I don't understand how to register...ㅠ.ㅠ
Here i introduce...ㅠ.ㅠ
If you are embrassed by me,sorry...ㅠ.ㅠ
============================================
I live in South-Korea..
I go to University.....
My magor is Computer-Secience...
My age is 22...
I have a few certificate..-SCJP,CCNA,OCP-
=============================================
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am not good at English,because I live in Korea=non-english-nation=...

I thought you are fine. Why do you think we shuold be embarassed?

I try to register,but I don't understand how to register

Okay, first logout. Then read the guidelines from the link above. Then goto register and register.
The point is that its a javaranch policy and we try to enforce it on everyone...doesn't matter who you are or where you are from.
Thanks for your cooperation.
- satya
 
Ram Dhan Yadav K
Ranch Hand
Posts: 321
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Madhav,
I have south korean friends and some of them are poor at interpreting english. I think you should give Sungjin a little bit more assistance in getting registered.
 
Chintan Rajyaguru
Ranch Hand
Posts: 341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay. It seems that you will soon register with correct name. I understand your concern about English because I am from India and not a native English speaker.
Here is the answer. You know that JSP is compiled into a Servlet.
<% x=1; %>
This line goes into _jspService () method. Like this,
_jspService ()
{
x=1;
}
<%! x=0; %>
This line makes x an instance variable. For example,
public class myClass
{
int x=0;
}
Notice that x is NOT inside a method it is inside class.
Now when you try to print x, inside a method, the one local to the method gets printed and not the class variable. So, (x=)1 is printed not (x=)0.
<% y=3; %>
<%! y=2; %>
Same thing happens for y. y=3 is local to the method _jspService(). So, 3 gets printed.
Your answer is C. This assumes that x and y has been declared. In normal cases you would say
<%! int x=0 %>
If the assumption that x and y have been declared is wrong then answer is A (compilation error).
Hope this helps
Chintan
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi Madhav,
I have south korean friends and some of them are poor at interpreting english. I think you should give Sungjin a little bit more assistance in getting registered

Ram:
Would love to. You send me to South Korea with all the expenses (whatsoever) paid and I will personally help Sungjin.
I don't understand why you should pick on me. I said his (her) english is fine. I gave instructions on how to re-register. Not sure what more you want me to do.
How difficult is it to follow instructions when you are registering. Javaranch specifically says use a firstname, a space then a lastname.
Sungjin, please don't take this wrongly. Lot of people do this mistake and it is customary for moderators to request the users to change the name. Thats okay with me.
What I don't understand is why Ram should pick on me..... :roll: . I thought I was pretty decent in the instructions that I gave.
Wonder what others think?
- satya
 
Axel Janssen
Ranch Hand
Posts: 2166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For me you are a very polite, very helpful, very exact bartender, especially after that weekends with some really confused downs. .
Think you answer 80% of the questions.
Would like to see more people trying to answer, although they are wrong. Would be more vivid discussion. Nobody has answered to Ersins "more tease" questions and its just not more than take an editor, take a compiler and then the start-tomcat-stop-tomcat-start-tomcat... game.
Say "would like". Everybody should do what he likes.
Don't know what Ram (which I like as contributor) means.
Axel
 
Ram Dhan Yadav K
Ranch Hand
Posts: 321
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok guys, peace!
Well, i guess i went into shoes of Sungjin for a while and i though Madhav would do a good may be better job in guiding Sungjin , probably some thing like
Step 1: Go to URL
Step 2: Do this
Step 3: Do that

No offence Mahdav , you do a great job man over here!
 
Axel Janssen
Ranch Hand
Posts: 2166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peace, too.
But you may do it too. As u allready have started...
Originally posted by Ram Dhan Yadav K:

Step 1: Go to URL
Step 2: Do this
Step 3: Do that


[ February 04, 2002: Message edited by: Axel Janssen ]
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok peace.
Oh! Com'on Ram, that's too much to ask.
Would like to see more people trying to answer,
Okay, I can take a hint. I will shutup.....
regds.
- satya......now drifted to the Meaningless Drivel forum.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic