Given the code fragment:
Which method should be used on line 3 to enable default validation mechanism?
Given the code fragment:
Which method should be used on line 3 to enable default validation mechanism?
To enable the default validation mechanism in JAXB, you should use the setSchema method. The setValidating method is deprecated, and using setEventHandler is for handling validation events but does not enable the default validation mechanism. Therefore, the correct method to use is setSchema(Schema).
There is no correct answer! Correct is setValidating(true) or setSchema(javax.xml.validation.Schema) because method setValidating(true) is deprecated. https://docs.oracle.com/javaee/7/api/javax/xml/bind/Unmarshaller.html#:~:text=By%20default%2C%20the%20Unmarshaller%20does,one%20of%20the%20unmarshal%20methods.
Correct is B
Answer C
It seems that C is the correct answer. https://docs.oracle.com/javase/8/docs/api/javax/xml/bind/helpers/AbstractMarshallerImpl.html#setEventHandler-javax.xml.bind.ValidationEventHandler-
Correct is C