InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
Do The Javamail Apis Work In Web Browsers? |
|
Answer» JavaMail will work in any BROWSER that SUPPORTS the required JDK VERSION. The Java Plug-in may be required to PROVIDE such support. JavaMail will work in any browser that supports the required JDK version. The Java Plug-in may be required to provide such support. |
|
| 2. |
How Do We Store Mail Messages On My Local Disk? |
|
Answer» A "local store provider" can be used to store mail messages on a local disk. The JavaMail API download does not include such a provider but a provider that SUPPORTS the Unix mbox FORMAT is available in the JavaMail source repository that you can build yourself. See this page for details. In addition, SEVERAL local store providers are available from third parties for different local store FORMATS such as MH and Mbox. See our Third Party Products page for the latest list of such providers. A "local store provider" can be used to store mail messages on a local disk. The JavaMail API download does not include such a provider but a provider that supports the Unix mbox format is available in the JavaMail source repository that you can build yourself. See this page for details. In addition, several local store providers are available from third parties for different local store formats such as MH and Mbox. See our Third Party Products page for the latest list of such providers. |
|
| 3. |
What Jdk Does The Javamail Api Need? |
|
Answer» The JavaMail API requires JDK/JRE 1.4 or higher. The JavaMail API is a Java optional PACKAGE, it is not part of the core Java SE but is INCLUDED in Java EE. The JavaMail API requires JDK/JRE 1.4 or higher. The JavaMail API is a Java optional package, it is not part of the core Java SE but is included in Java EE. |
|
| 4. |
What Is Mime? |
|
Answer» MIME and RFC822 are the standards for describing email messages that are sent ACROSS the Internet. The javax.mail.internet subpackage (which is part of the JavaMail APIs) PROVIDES a complete implementation of these two PACKAGES. MIME is specified by the following RFCs: RFC2045, RFC2046, RFC2047. MIME and RFC822 are the standards for describing email messages that are sent across the Internet. The javax.mail.internet subpackage (which is part of the JavaMail APIs) provides a complete implementation of these two packages. MIME is specified by the following RFCs: RFC2045, RFC2046, RFC2047. |
|
| 5. |
Explain Imap? |
|
Answer» IMAP: Short for Internet Message Access Protocol. This is another most prevalent protocol of internet standard for email usage apart from POP. Usually all the MODERN email server and CLIENT supports these two protocols for transmitting the email messages. For Example Gmail server uses to transmit the message to a client such as Mozilla Thunderbird and Microsoft Outlook. IMAP is an application LAYER protocol over internet that is operating from port no. 143 that allows the accessibility of email on a REMOTE server by a client. IMAP supports the online and offline (disconnected) modes of operations. Usually the email clients using IMAP utilizes the facility of leaving the message on the server. The message lasts until the user explicitly deletes them. IMAP also allows multiple clients to have the accessibility of the same mailbox. IMAP: Short for Internet Message Access Protocol. This is another most prevalent protocol of internet standard for email usage apart from POP. Usually all the modern email server and client supports these two protocols for transmitting the email messages. For Example Gmail server uses to transmit the message to a client such as Mozilla Thunderbird and Microsoft Outlook. IMAP is an application layer protocol over internet that is operating from port no. 143 that allows the accessibility of email on a remote server by a client. IMAP supports the online and offline (disconnected) modes of operations. Usually the email clients using IMAP utilizes the facility of leaving the message on the server. The message lasts until the user explicitly deletes them. IMAP also allows multiple clients to have the accessibility of the same mailbox. |
|
| 6. |
Explain Smtp? |
|
Answer» SMTP: Simple Mail Transfer Protocol, for sending email between ‘servers’. Most of the emailing systems implement the messages over internet USE SMTP. The MESSAGE sent from one SERVER to another server, and then the message can be retrieved by an email client. The client USES either POP or IMAP. In addition to this process, SMTP is ALSO generally used for message sending and retrieval from a mail client to a mail server. This is the reason why the need of POP or IMAP server and the SMTP servers at the time of configuring the email application. SMTP: Simple Mail Transfer Protocol, for sending email between ‘servers’. Most of the emailing systems implement the messages over internet use SMTP. The message sent from one server to another server, and then the message can be retrieved by an email client. The client uses either POP or IMAP. In addition to this process, SMTP is also generally used for message sending and retrieval from a mail client to a mail server. This is the reason why the need of POP or IMAP server and the SMTP servers at the time of configuring the email application. |
|
| 7. |
What Are The Advantages Of Javamail? |
|
Answer» Potential advantages include - Java mail is used to create personal mail filter, simple mailing lists and personal mail applications. Java mail ALSO includes the capabilities to add the EMAILING process to an enterprise application or even to create a full-fledged e-mail CLIENT. Many companies in the INDUSTRY have written new e-mail clients using Java Mail. Potential advantages include - Java mail is used to create personal mail filter, simple mailing lists and personal mail applications. Java mail also includes the capabilities to add the emailing process to an enterprise application or even to create a full-fledged e-mail client. Many companies in the industry have written new e-mail clients using Java Mail. |
|
| 8. |
What Is Message In Javamail Api? |
|
Answer» After creating session object, create MESSAGE to send by using Message CLASS. Because of message class is abstract class so we will use subclass javax.mail.internet.MimeMessage. MimeMessage message = NEW MimeMessage(session) After creating session object, create message to send by using Message class. Because of message class is abstract class so we will use subclass javax.mail.internet.MimeMessage. MimeMessage message = new MimeMessage(session) |
|
| 9. |
What Is Address In Javamail Api? |
|
Answer» Address class is ALSO an abstract class so we will use here class javax.mail.internet.InternetAddress. After creating address CONNECT with message by two ways: 1: By setFrom()method: message.setFrom(address); Address types are of three types:
Address class is also an abstract class so we will use here class javax.mail.internet.InternetAddress. After creating address connect with message by two ways: 1: By setFrom()method: message.setFrom(address); Address types are of three types: |
|
| 10. |
Sample Code For Replying To Messages Using Javamail? |
|
Answer» The Message CLASS have a reply() method to configure a new Message with the proper recipient and subject, adding "Re: " if not already there. This does not add any content to the message, reply() method have a boolean parameter indicating whether to reply to only the sender (false) or reply to all (true). MimeMessage reply = (MimeMessage)message.reply(false);reply.setFrom(new InternetAddress("president@whitehouse.gov"));reply.setText("Thanks");Transport.send(reply); To configure the reply-to address when sending a message, use the setReplyTo() method. package com.withoutbook.common; import java.io.*; The Message class have a reply() method to configure a new Message with the proper recipient and subject, adding "Re: " if not already there. This does not add any content to the message, reply() method have a boolean parameter indicating whether to reply to only the sender (false) or reply to all (true). MimeMessage reply = (MimeMessage)message.reply(false);reply.setFrom(new InternetAddress("president@whitehouse.gov"));reply.setText("Thanks");Transport.send(reply); To configure the reply-to address when sending a message, use the setReplyTo() method. package com.withoutbook.common; import java.io.*; |
|
| 11. |
Sample Code For Reading Attachment Message Using Javamail? |
|
Answer» JAVA Mail API provides classes to send multiple Mime BODY part with one Mime Message. MulipltMimeBody parts can be text, file or image. All message are stored in Folder objects. folders can contain folders or messages. The Folder class declares methods that fetch, append, copy and delete messages, and message contain Attachment. package com.withoutbook.common; import java.io.*;<BR>import java.util.*; Java Mail API provides classes to send multiple Mime body part with one Mime Message. MulipltMimeBody parts can be text, file or image. All message are stored in Folder objects. folders can contain folders or messages. The Folder class declares methods that fetch, append, copy and delete messages, and message contain Attachment. package com.withoutbook.common; import java.io.*; |
|
| 12. |
Sample Code For Reading Multipart Mail Using Javamail? |
|
Answer» These days Multipart mail is used to compose emails with attachment. In the email you can attach images, zip FILES, xls, doc etc.. It allows you to create nicely DESIGN emails. Java Mail API also provides classes to create, send and read the Multipart message. If you have given a task to create emails with attachment in Java technologies, then you can use the Java Mail api to accomplish your task. Using the Multipart Class Following code snippet shows how you can use the Multipart class. You have to create the object of Multipart class and then you can GET the body part and compose or read your email. Multipart multipart = (Multipart) msg[i].getContent();After that create BodyPart object BodyPart bodyPart = multipart.getBodyPart(x); And then read bodyPart content using getContent() method.
package com.withoutbook.common; System.out.println("Subject: " + subject); These days Multipart mail is used to compose emails with attachment. In the email you can attach images, zip files, xls, doc etc.. It allows you to create nicely design emails. Java Mail API also provides classes to create, send and read the Multipart message. If you have given a task to create emails with attachment in Java technologies, then you can use the Java Mail api to accomplish your task. Using the Multipart Class Following code snippet shows how you can use the Multipart class. You have to create the object of Multipart class and then you can get the body part and compose or read your email. Multipart multipart = (Multipart) msg[i].getContent();After that create BodyPart object BodyPart bodyPart = multipart.getBodyPart(x); And then read bodyPart content using getContent() method.
package com.withoutbook.common; System.out.println("Subject: " + subject); |
|
| 13. |
What Is Store And Folder In Javamail Api? |
|
Answer» After getting the session you connect to javax.mail.Store class with Authenticator or host, PORT, user and PASSWORD information. Store object that implements the SPECIFIED protocol can be created by by passing the protocol information to the getStore() method of the session object. Store store = session.getStore("pop3"); store.connect(host, username, password); After connecting to store you need to get a folder that HOLDS messages. For POP3, the only folder AVAILABLE is the INBOX but with IMAP, you can have other folders available. For this you can use javax.mail.Folder class. Folder folder = store.getFolder("INBOX"); folder.open(Folder.READ_ONLY); Message message[] = folder.getMessages(); Once you have read messages, you need to close Store and Folder. folder.close(booleanValue); store.close(); After getting the session you connect to javax.mail.Store class with Authenticator or host, port, user and password information. Store object that implements the specified protocol can be created by by passing the protocol information to the getStore() method of the session object. Store store = session.getStore("pop3"); store.connect(host, username, password); After connecting to store you need to get a folder that holds messages. For POP3, the only folder available is the INBOX but with IMAP, you can have other folders available. For this you can use javax.mail.Folder class. Folder folder = store.getFolder("INBOX"); folder.open(Folder.READ_ONLY); Message message[] = folder.getMessages(); Once you have read messages, you need to close Store and Folder. folder.close(booleanValue); store.close(); |
|
| 14. |
What Is Transport In Javamail Api? |
|
Answer» This is final PART of SENDING Email, it is an abstract CLASS. Default version of this class can be used by calling static send() method. Transport.send(message); Or can create a specific INSTANCE from the session for defined protocol. message.saveChanges(); Transport transport = session.getTransport("smtp"); transport.connect(host, username, PASSWORD); transport.sendMessage(message, message.getAllRecipients()); transport.close(); This is final part of sending Email, it is an abstract class. Default version of this class can be used by calling static send() method. Transport.send(message); Or can create a specific instance from the session for defined protocol. message.saveChanges(); Transport transport = session.getTransport("smtp"); transport.connect(host, username, password); transport.sendMessage(message, message.getAllRecipients()); transport.close(); |
|
| 15. |
What Is Authenticator In Javamail Api? |
|
Answer» The JavaMail Authenticator is found in the javax.mail package, and used as an authenticator to access PROTECTED resources by PROMPTING the USER for username and PASSWORD.
The JavaMail Authenticator is found in the javax.mail package, and used as an authenticator to access protected resources by prompting the user for username and password. |
|
| 16. |
Sample Code To Send Html Mail With Images Using Javamail? |
|
Answer» A client create NEW message by using Message subclass. It sets attributes like recipient address and the SUBJECT, and inserts the content into the Message object, and inserts the content into the Message object. Finally, it sends the Message by invoking the Transport.send() method. The Transport class models the transport AGENT that routes a message to its destination addresses. This class provides methods that send a message to a list of recipients. Invoking the Transport.send() method with a Message object identifies the appropriate transport BASED on its destination addresses. package com.withoutbook.common; import java.util.*; A client create new message by using Message subclass. It sets attributes like recipient address and the subject, and inserts the content into the Message object, and inserts the content into the Message object. Finally, it sends the Message by invoking the Transport.send() method. The Transport class models the transport agent that routes a message to its destination addresses. This class provides methods that send a message to a list of recipients. Invoking the Transport.send() method with a Message object identifies the appropriate transport based on its destination addresses. package com.withoutbook.common; import java.util.*; |
|
| 17. |
What Is Session In Javamail Api? |
|
Answer» Session is the top-level entry CLASS representing mail session. It USES java.util.Properties object to get information about mail server, username, password etc. This class has a private constructor and you can get session OBJECTS through getInstance() and getDefaultInstance() METHODS. getDefaultInstance() method PROVIDES default Session object which takes Properties and Authenticator objects as arguments. Properties props = new Properties(); Properties props = new Properties(); Session is the top-level entry class representing mail session. It uses java.util.Properties object to get information about mail server, username, password etc. This class has a private constructor and you can get session objects through getInstance() and getDefaultInstance() methods. getDefaultInstance() method provides default Session object which takes Properties and Authenticator objects as arguments. Properties props = new Properties(); Properties props = new Properties(); |
|
| 18. |
Explain The Structure Of Javamail Api? |
|
Answer» The JavaMail API has classes such as Message, Store and Transport. The API can be used to subclass for providing new protocols and some additional functionality when needed. The concrete subclasses of this API are MimeMessage and MimeBodyPart which are implemented widely by the internet mail protocols. The supporting protocols for Javamail API are IMAP4, POP3 and SMTP. The Java mail architectural components include the following: Abstract Layer: This layer declares the classes, INTERFACES and abstract methods that are intended for supporting the mail functions which all mailing systems supports. INTRANET Implementation Layer: The implementation of MIME internet standards and part of the abstract layer comprises this layer. Java Bean Activation Framework: The encapsulation of message data and handling the data INTERACTING commands is used by the JAVABEAN The JavaMail API has classes such as Message, Store and Transport. The API can be used to subclass for providing new protocols and some additional functionality when needed. The concrete subclasses of this API are MimeMessage and MimeBodyPart which are implemented widely by the internet mail protocols. The supporting protocols for Javamail API are IMAP4, POP3 and SMTP. The Java mail architectural components include the following: Abstract Layer: This layer declares the classes, interfaces and abstract methods that are intended for supporting the mail functions which all mailing systems supports. Intranet Implementation Layer: The implementation of MIME internet standards and part of the abstract layer comprises this layer. Java Bean Activation Framework: The encapsulation of message data and handling the data interacting commands is used by the Javabean |
|
| 19. |
Discuss About Javamail? |
Answer»
|
|
| 20. |
Explain The Use Of Mime Within Message Makeup? |
|
Answer» MIME message includes the picture STORED as file in GIF format and the GIF format uses 8-bit format. The RFC 822 uses ASCII text format. The messages in the form of ASCII text format is to be encoded. To display the image in the recipient system, the information ABUT the encoding mechanism is used. The message is to be made up in the recipient’s application. The following snippet is used to identify the content is a GIF file which is to be encoded using the standard “base64Algorithm. This is to be treated as an attachment by the client who uses the email. Content-Type: image/gif; The ACCOMPLISHMENT of this is DONE by simplifying and rebuilding of complex files. These files are encoded and transported as a body of the message or a SERIES of messages which are the parts of the file.A message format is defined by the MIME that allows the following: Non ASCII character textual message bodies. MIME message includes the picture stored as file in GIF format and the GIF format uses 8-bit format. The RFC 822 uses ASCII text format. The messages in the form of ASCII text format is to be encoded. To display the image in the recipient system, the information abut the encoding mechanism is used. The message is to be made up in the recipient’s application. The following snippet is used to identify the content is a GIF file which is to be encoded using the standard “base64Algorithm. This is to be treated as an attachment by the client who uses the email. Content-Type: image/gif; The accomplishment of this is done by simplifying and rebuilding of complex files. These files are encoded and transported as a body of the message or a series of messages which are the parts of the file.A message format is defined by the MIME that allows the following: Non ASCII character textual message bodies. |
|
| 21. |
Explain Pop? |
|
Answer» POP: The Post Office Protocol is an application-level protocol WITHIN an intranet which are used by the local e-mail clients to SEND and retrieve e-mails from a remote server those are connected using TCP/IP. POP is one of the most prevalent protocol FRO the usage of e-mail. The POP and its procedures SUPPORT the end-users with dial-up NETWORK connections. POP allows the users to retrieve e-mail when connected and later allows viewing and altering the retrieved messages. This is done with a promising feature – without staying connected. The process of using emails over POP is to connect, retrieve the messages, and store them on the user’s PC as a new message. Later these messages can be ‘deleted from the server’ and disconnecting the server – makes POP a distinguished protocol.
POP: The Post Office Protocol is an application-level protocol within an intranet which are used by the local e-mail clients to send and retrieve e-mails from a remote server those are connected using TCP/IP. POP is one of the most prevalent protocol fro the usage of e-mail. The POP and its procedures support the end-users with dial-up network connections. POP allows the users to retrieve e-mail when connected and later allows viewing and altering the retrieved messages. This is done with a promising feature – without staying connected. The process of using emails over POP is to connect, retrieve the messages, and store them on the user’s PC as a new message. Later these messages can be ‘deleted from the server’ and disconnecting the server – makes POP a distinguished protocol.
|
|
| 22. |
What Are The Javamail Api Core Classes? |
|
Answer» There are TWO packages that are used in Java MAIL API: javax.mail and javax.mail.internet PACKAGE. These packages contains many classes for Java Mail API. They are:
There are two packages that are used in Java Mail API: javax.mail and javax.mail.internet package. These packages contains many classes for Java Mail API. They are:
|
|
| 23. |
Explain Javamail Architecture? |
|
Answer» The java application USES JavaMail API to compose, SEND and receive emails. The JavaMail API uses SPI (SERVICE Provider INTERFACES) that PROVIDES the intermediatory services to the java application to deal with the different protocols. The java application uses JavaMail API to compose, send and receive emails. The JavaMail API uses SPI (Service Provider Interfaces) that provides the intermediatory services to the java application to deal with the different protocols. |
|
| 24. |
Which Protocols Are Used In Javamail Api? |
|
Answer» There are some protocols that are used in JavaMail API.
SMTP : SMTP is an acronym for Simple Mail Transfer PROTOCOL. It provides a mechanism to deliver the EMAIL. We can use Apache James server, Postcast server, cmail server etc. as an SMTP server. But if we purchase the host SPACE, an SMTP server is bydefault provided by the host provider. For example, my smtp server is mail.javatpoint.com. If we use the SMTP server provided by the host provider, AUTHENTICATION is required for sending and receiving emails. POP : POP is an acronym for Post Office Protocol, also known as POP3. It provides a mechanism to receive the email. It provides support for single mail box for each user. We can use Apache James server, cmail server etc. as an POP server. But if we purchase the host space, an POP server is bydefault provided by the host provider. For example, the pop server provided by the host provider for my site is mail.javatpoint.com. This protocol is defined in RFC 1939. IMAP : IMAP is an acronym for Internet Message Access Protocol. IMAP is an advanced protocol for receiving messages. It provides support for multiple mail box for each user ,in addition to, mailbox can be shared by multiple users. It is defined in RFC 2060. MIME : Multiple Internet Mail Extension (MIME) tells the browser what is being sent e.g. attachment, format of the messages etc. It is not known as mail transfer protocol but it is used by your mail program. NNTP and Others : There are many protocols that are provided by third-party providers. Some of them are Network News Transfer Protocol (NNTP), Secure Multipurpose Internet Mail EXTENSIONS (S/MIME) etc. There are some protocols that are used in JavaMail API. SMTP : SMTP is an acronym for Simple Mail Transfer Protocol. It provides a mechanism to deliver the email. We can use Apache James server, Postcast server, cmail server etc. as an SMTP server. But if we purchase the host space, an SMTP server is bydefault provided by the host provider. For example, my smtp server is mail.javatpoint.com. If we use the SMTP server provided by the host provider, authentication is required for sending and receiving emails. POP : POP is an acronym for Post Office Protocol, also known as POP3. It provides a mechanism to receive the email. It provides support for single mail box for each user. We can use Apache James server, cmail server etc. as an POP server. But if we purchase the host space, an POP server is bydefault provided by the host provider. For example, the pop server provided by the host provider for my site is mail.javatpoint.com. This protocol is defined in RFC 1939. IMAP : IMAP is an acronym for Internet Message Access Protocol. IMAP is an advanced protocol for receiving messages. It provides support for multiple mail box for each user ,in addition to, mailbox can be shared by multiple users. It is defined in RFC 2060. MIME : Multiple Internet Mail Extension (MIME) tells the browser what is being sent e.g. attachment, format of the messages etc. It is not known as mail transfer protocol but it is used by your mail program. NNTP and Others : There are many protocols that are provided by third-party providers. Some of them are Network News Transfer Protocol (NNTP), Secure Multipurpose Internet Mail Extensions (S/MIME) etc. |
|