Loading...

Interview Questions


What is the use of garbage collection in Java?


The use of garbage collection in Java is to recognize and remove objects that are no more required by a program and are unnecessary consuming the program resources that could be freed and reused by other objects. An object in Java is subject to garbage collection when it turns inaccessible to the Java program in which it is initiated.

What do you understand by thread in Java?


A thread is a single sequential flow of control within a process where each process can contain two or more "threads". In Java, a thread is created and coordinated by the java.lang.Thread class.

Every process (or application) in Java language contains at least one thread (also known as the main thread). Depending on the programmers need, the process can contain multiple threads as well to handle different tasks such as memory management and 1/0.

When and how a deadlock occurs in any program?


A deadlock occurs when two or more threads are blocked on locks and every thread that's blocked is holding a lock that another block thread wants. For example: thread 1 is holding lock 1 and waiting to acquire lock 2 but thread 2 is holding lock 2 and waiting to acquire lock 1. It creates a situation where all the threads holding the locks are blocked therefore it will never release the locks they're holding and so none of the waiting threads will actually ever run.

Why developers use BufferedReader to read any file in Java?


A BufferedReader reads text from the input stream and buffers the characters into a character array. Reading chunks of data from a stream (unlike a file) is more efficient than reading just a few characters at a time.

Therefore we can conclude that BufferReader is more streamlined and faster. Also, we can specify the size of the buffer, but the default is 8k, and that is also sufficient for most purposes.

Mention the advantages and disadvantages of using Java Sockets.


Advantages of Java Sockets: Sockets are used in Java programming because of their flexibility and easy communication protocols. They also cause low network traffic such as HTML forms and CGI scripts that create and transfer the complete web pages for each new data request.

Disadvantages of Java Sockets: The communications that occurs through Socket only enables to send packets of raw data between applications.

What do you understand by JavaMail?


The JavaMail is an API widely used in Java programming to facilitate mailing operations such as compose, read, send, and receive electronic mails on the Internet.

It is a protocol-independent and platform-independent framework available as an optional package with the Java SE platform and incorporated in the Java EE platform as well.

The JavaMail API can be used for many conducting other events. It can be used to register the user (sending notifications unlike thank you for visiting my website or subscribing to our newsletter), forgot the password (set and update a new password through mail), sending update notifications, etc,

Name the two core packages used in JavaMail API


The two packages that contain the core classes of JavaMail API are given below:

  1. mail
  2. mail.activation

Name the JSTL tags


JSTL includes five types of tags:

  • Core Tags
  • Function Tags
  • Formatting Tags
  • XML Tags
  • SQL Tags

Does JSP allow the use of exception implicit object in any page?


The exception implicit object was created only for the JSP error page and is defined using the isErrorPage attribute. Therefore, we cannot use the exception implicit object in any JSP page.

Can we forward the request from a JSP page to a servlet page?


Yes, we can forward a request from the JSP page to Servlet by using the JSP "forward action" tag and by mentioning the URL pattern of the Servlet.


Categories ( 117 )