Question: Java | answer all the questions 17. Any Java interface must contain certain number of methods. If an interface does not have any method declared,

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:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!