Spring Questions and Answers – Java Send Email API

This set of Java Spring Puzzles focuses on “Java Send Email API”.

1. To send an email using your Java Application:-
a) JavaMail API
b) Java Activation Framework (JAF)
c) All of the mentioned
d) None of the mentioned
View Answer

Answer: c
Explanation: You can download latest version of JavaMail (Version 1.2) from Java’s standard website. You can download latest version of JAF (Version 1.1.1) from Java’s standard website.

2. If you want to send an email to multiple recipients:-
a) void addRecipients(Message.RecipientType type, Address[] addresses)
b) void addRecipients(Message.RecipientType type)
c) all of the mentioned
d) none of the mentioned
View Answer

Answer: a
Explanation: If you want to send an email to multiple recipients then the following methods would be used to specify multiple email IDs:
void addRecipients(Message.RecipientType type, Address[] addresses) throws MessagingException.

3. void addRecipients(Message.RecipientType type, Address[] addresses)
Parameter:-
type: This would be set to:-
a) TO
b) CC
c) BCC
d) All of the mentioned
View Answer

Answer: d
Explanation: This would be set to TO, CC or BCC. Here CC represents Carbon Copy and BCC represents Black Carbon Copy. Example Message.RecipientType.TO.
advertisement
advertisement

4. void addRecipients(Message.RecipientType type, Address[] addresses)
Parameter:-
addresses: This is the array of email ID, the method used while specifying email IDs
a) Internet
b) InternetAddress
c) BCC
d) All of the mentioned
View Answer

Answer: b
Explanation: Addresses: This is the array of email ID. You would need to use the InternetAddress() method while specifying email IDs.

5. To set content whose second argument is “text/html” to specify that the HTML content is included in the message.
a) setContent
b) content
c) setMail
d) none of the mentioned
View Answer

Answer: a
Explanation: setContent() method to set content whose second argument is “text/html” to specify that the HTML content is included in the message.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

6. If it is required to provide user ID and Password to the email server for authentication purpose then you can set properties:
a) props.setProperty(“mail.user”, “myuser”)
b) props.setProperty(“mail.password”, “mypwd”)
c) all of the mentioned
d) none of the mentioned
View Answer

Answer: c
Explanation: If it is required to provide user ID and Password to the email server for authentication purpose then you can set these properties as follows:

props.setProperty(“mail.user”, “myuser”);
props.setProperty(“mail.password”, “mypwd”);

advertisement

7. It is assumed that your localhost is connected to the internet and capable enough to send an email.
a) True
b) False
View Answer

Answer: a
Explanation: To send an HTML email from your machine.

8. The JavaMailSender interface is a subinterface of MailSender that includes specialized JavaMail features:-
a) Multipurpose Internet Mail Extensions
b) Multipurpose Internet Mail
c) Multipurpose Internet Extensions
d) None of the mentioned
View Answer

Answer: a
Explanation: The JavaMailSender interface is a subinterface of MailSender that includes specialized JavaMail features such as Multipurpose Internet Mail Extensions (MIME) message support. To send an email message with HTML content, inline images, or attachments, you have to send it as a MIME message.
advertisement

9. You can implement the interface to send email notifications in case of errors.
a) Notify
b) Error
c) ErrorNotifier
d) None of the mentioned
View Answer

Answer: c
Explanation: You can implement the ErrorNotifier interface to send email notifications in case of errors.

10. You send the email by making a call to:-
a) Transport.send()
b) Transport.sendTo()
c) All of the mentioned
d) None of the mentioned
View Answer

Answer: a
Explanation: You send the email by making a call to Transport.send().

Sanfoundry Global Education & Learning Series – Java Spring.
To practice puzzles on all areas of Java Spring, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.