Java Spring Puzzles 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
Answer: c
Clarification: 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
Answer: a
Clarification: 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
Answer: d
Clarification: This would be set to TO, CC or BCC. Here CC represents Carbon Copy and BCC represents Black Carbon Copy. Example Message.RecipientType.TO.
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
Answer: b
Clarification: 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
Answer: a
Clarification: setContent() method to set content whose second argument is “text/html” to specify that the HTML content is included in the message.
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
Answer: c
Clarification: 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”);
7. It is assumed that your localhost is connected to the internet and capable enough to send an email.
a) True
b) False
Answer: a
Clarification: 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
Answer: a
Clarification: 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.
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
Answer: c
Clarification: 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
Answer: a
Clarification: You send the email by making a call to Transport.send().
To practice puzzles on all areas of Java Spring,