Java | Answer them all 1. Any Java interface must contain certain number of meth
ID: 3701111 • Letter: J
Question
Java | Answer them all
1. 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
2. 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
3. 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.
4. 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
5. 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.
6. 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!")}
7. 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
Explanation / Answer
If you post more than 1 question, as per chegg guidelines I have to solve only first question.
Ques 1. Answer : (b) False
We can still define data attributes in the interface which can be implemented by a class and we can use the attributes in the class to predefine some value.
Ques 2. Answer : (A) converting compile errors to runtime errors
In generic methods, we define a generic attributes. So, it removes the compile time error where the data types are incompatible. So, at compile time, these errors are not there, but they appear in case of run time.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.