Question

Java | answer all the questions 17. Any Java interface must contain certain number of methods....

Java | answer all the questions

17. Any Java interface must contain certain number of methods. If an interface does not have any method declared, then it is useless.

(a)true

(b)false

18. Suppose that the name of a parameter is user, which is passed to a JSP. How to use an EL expression to access the value of this parameter in this JSP?

Answer:

19. The Java generics are used to reduce errors in Java programs using collection-type objects. Which of the following gives what the Java generics do?

(a) converting compile errors to runtime errors

(b) converting runtime errors to compile errors

20. In which of the following situations, the EL engine would complain?

(a) When an EL expression accesses a session attribute by the name, but the attribute object does not exist.

(b) When an EL expression access a JavaBean property through its bean reference, but the property does not exist.

21. If you use the data binding feature that copies data from an HTML form to the properties of a JavaBean, you need to make sure that the input field names of the HTML form exactly match their corresponding JavaBean property names. Other-wise you can never make the data copy successful.

(a) true

(b) false

22. Suppose the value of a parameter called chap is not available. If we use the EL expression ${param.chap} to access the parameter, which of the following would happen?

(a)an empty string

(b)null

(c)An error message is displayed.

23. Which of the following ways of using an EL expression is legal?

(a)${paramValue.names[0]}

(b)${cookies.user}

(c)${headerValues["Accept-Language"][0]}

(d)${headerValues.Accept-Language[0]}

(e)${out.println("Done!")}

24. Suppose that we use the following two lines in a servlet to set values for the book attribute, request.setAttribute("book", "java1"); session.setAttribute("book", "java2"); Then when we display the value of the book attribute in the JSP forwarded by this servlet using the EL expression ${book}, what is its result?

(a)java1

(b)java2

(c)empty string

(d)java1, java2

(e)error

25. Suppose that we use the following two lines in a servlet to set values for the myval attribute, request.setAttribute("myvar", "value1"); session.setAttribute("myvar", "value2"); Then in the JSP forwarded by this servlet, how do we display the value of the at-tribute myvar in the session scope?

Ans:

0 0
Add a comment Improve this question Transcribed image text
Answer #1

17) (a)True
Interfaces are used to store incomplete or abstract methods. If there are no methods then interface is simple useless.

18) ${param.user}
This expression fetches the value stored in parameter user and prints it.

19) (a)converting complie error to runtime errors
Generics can accept values of heterogeneous data types. If in-appropriate values are tried to access then it might lead to runtime error.
For example: String value is stored and we want to perform certain operation on that value which is assumed to be of type INT.

20)(a)When an EL expression accesses a session attribute by name, but the attribute object does not exist.
It gives error if object does not exist.

21) (a)True
The names must be same as form feild names.

22) (c)Error message is displayed
If we try to access the parameter that is not available then it leads to error

23)(a)${paramValue.names[0]}
All other options have syntax error.

24) (b)java2
Session will set the book value to book2 and hence JSP will access this and display using EL expression


25) The value of attribute mayvar is value2 because it is in the session scope.

Add a comment
Know the answer?
Add Answer to:
Java | answer all the questions 17. Any Java interface must contain certain number of methods....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT