Java Interview Questions -44

Java Interview Questions -44

1.Why should we go for interservlet communication?

Servlets running together in the same server communicate with each other in several ways. The three major reasons to use interservlet communication are: a) Direct servlet manipulation – allows to gain access to the other currently loaded servlets and perform certain tasks (through the ServletContext object) b) Servlet reuse – allows the servlet to reuse the public methods of another servlet. c) Servlet collaboration – requires to communicate with each other by sharing specific information (through method invocation)

2.Is it possible to call servlet with parameters in the URL?

Yes. You can call a servlet with parameters in the syntax as (?Param1 = xxx || m2 = yyy).

3.What is Servlet chaining?

Servlet chaining is a technique in which two or more servlets can cooperate in servicing a single request. In servlet chaining, one servlet’s output is piped to the next servlet’s input. This process continues until the last servlet is reached. Its output is then sent back to the client.

4.What is JSP?

JSP is a dynamic scripting capability for web pages that allows Java as well as a few special tags to be embedded into a web file (HTML/XML, etc). The suffix traditionally ends with .jsp to indicate to the web server that the file is a JSP files. JSP is a server side technology – you can’t do any client side validation with it. The advantages are: a) The JSP assists in making the HTML more functional. Servlets on the other hand allow outputting of HTML but it is a tedious process. b) It is easy to make a change and then let the JSP capability of the web server you are using deal with compiling it into a servlet and running it.

5.What are Predefined variables or implicit objects?

To simplify code in JSP expressions and scriptlets, we can use eight automatically defined variables, sometimes called implicit objects. They are request, response, out, session, application, config, pageContext, and page.

6.What are JSP ACTIONS?

JSP actions use constructs in XML syntax to control the behavior of the servlet engine. You can dynamically insert a file, reuse JavaBeans components, forward the user to another page, or generate HTML for the Java plugin. Available actions include: jsp:include – Include a file at the time the page is requested. jsp:useBean – Find or instantiate a JavaBean. jsp:setProperty – Set the property of a JavaBean. jsp:getProperty – Insert the property of a JavaBean into the output. jsp:forward – Forward the requester to a newpage. Jsp: plugin – Generate browser-specific code that makes an OBJECT or EMBED

7.What is RMI and steps involved in developing an RMI object?

Remote Method Invocation (RMI) allows java object that executes on one machine and to invoke the method of a Java object to execute on another machine. The steps involved in developing an RMI object are: a) Define the interfaces b) Implementing these interfaces c) Compile the interfaces and their implementations with the java compiler d) Compile the server implementation with RMI compiler e) Run the RMI registry f) Run the application

8.How do servlets handle multiple simultaneous requests?

The server has multiple threads that are available to handle requests. When a request comes in, it is assigned to a thread, which calls a service method (for example: doGet(), doPost() and service()) of the servlet. For this reason, a single servlet object can have its service methods called by many threads at once.

9.What is the difference between TCP/IP and UDP?

TCP/IP is a two-way communication between the client and the server and it is a reliable and there is a confirmation regarding reaching the message to the destination. It is like a phone call. UDP is a one-way communication only between the client and the server and it is not a reliable and there is no confirmation regarding reaching the message to the destination. It is like a postal mail.

10.What is Inet address?

Every computer connected to a network has an IP address. An IP address is a number that uniquely identifies each computer on the Net. An IP address is a 32-bit number.

11.What is Domain Naming Service(DNS)?

It is very difficult to remember a set of numbers(IP address) to connect to the Internet. The Domain Naming Service(DNS) is used to overcome this problem. It maps one particular IP address to a string of characters. For example, www. mascom. com implies com is the domain name reserved for US commercial sites, moscom is the name of the company and www is the name of the specific computer, which is mascom’s server.

12. What is difference between custom JSP tags and beans?

Custom JSP tag is a tag you defined. You define how a tag, its attributes and its body are interpreted, and then group your tags into collections called tag libraries that can be used in any number of JSP files. To use custom JSP tags, you need to define three separate components: the tag handler class that defines the tag’s behavior ,the tag library descriptor file that maps the XML element names to the tag implementations and the JSP file that uses the tag library
JavaBeans are Java utility classes you defined. Beans have a standard format for Java classes. You use tags
Custom tags and beans accomplish the same goals — encapsulating complex behavior into simple and accessible forms. There are several differences:
Custom tags can manipulate JSP content; beans cannot. Complex operations can be reduced to a significantly simpler form with custom tags than with beans. Custom tags require quite a bit more work to set up than do beans. Custom tags usually define relatively self-contained behavior, whereas beans are often defined in one servlet and used in a different servlet or JSP page. Custom tags are available only in JSP 1.1 and later, but beans can be used in all JSP 1.x versions.

13.Can we use the constructor, instead of init(), to initialize servlet?

Yes. But you will not get the servlet specific things from constructor. The original reason for init() was that ancient versions of Java couldn’t dynamically invoke constructors with arguments, so there was no way to give the constructor a ServletConfig. That no longer applies, but servlet containers still will only call your no-arg constructor. So you won’t have access to a ServletConfig or ServletContext.

14. What is servlet mapping?

The servlet mapping defines an association between a URL pattern and a servlet. The mapping is used to map requests to Servlets.

15. What is servlet context ?

The servlet context is an object that contains a information about the Web application and container. Using the context, a servlet can log events, obtain URL references to resources, and set and store attributes that other servlets in the context can use.

16.What is the difference in using request.getRequestDispatcher() and context.getRequestDispatcher()?

In request.getRequestDispatcher(path) in order to create it we need to give the relative path of the resource. But in resourcecontext.getRequestDispatcher(path) in order to create it we need to give the absolute path of the resource.

17.What is RMI architecture?

RMI architecture consists of four layers and each layer performs specific functions: a) Application layer – contains the actual object definition. b) Proxy layer – consists of stub and skeleton. c) Remote Reference layer – gets the stream of bytes from the transport layer and sends it to the proxy layer. d) Transportation layer – responsible for handling the actual machine-to-machine communication.

18.what is UnicastRemoteObject?

All remote objects must extend UnicastRemoteObject, which provides functionality that is needed to make objects available from remote machines.

19.What are JSP scripting elements?

JSP scripting elements lets to insert Java code into the servlet that will be generated from the current JSP page. There are three forms: a) Expressions of the form <%= expression %> that are evaluated and inserted into the output, b) Scriptlets of the form<% code %>that are inserted into the servlet’s service method, and c) Declarations of the form <%! Code %>that are inserted into the body of the servlet class, outside of any existing methods.

20. How many JSP scripting elements are there and what are they?

There are three scripting language elements: declarations, scriptlets, expressions.

21. What is a Expression?

Expressions are act as place holders for language expression, expression is evaluated each time the page is accessed. This will be included in the service method of the generated servlet.

22. What is a Declaration?

It declares one or more variables or methods for use later in the JSP source file. A declaration must contain at least one complete declarative statement. You can declare any number of variables or methods within one declaration tag, as long as semicolons separate them. The declaration must be valid in the scripting language used in the JSP file. This will be included in the declaration section of the generated servlet.

23.Explain the methods, rebind() and lookup() in Naming class?

rebind() of the Naming class(found in java. rmi) is used to update the RMI registry on the server machine. Naming. rebind(”AddSever”, AddServerImpl); lookup() of the Naming class accepts one argument, the rmi URL and returns a reference to an object of type AddServerImpl.

24.What is a Java Bean?

A Java Bean is a software component that has been designed to be reusable in a variety of different environments.

25.What is a Jar file?

Jar file allows to efficiently deploying a set of classes and their associated resources. The elements in a jar file are compressed, which makes downloading a Jar file much faster than separately downloading several uncompressed files. The package java. util. zip contains classes that read and write jar files.

26.What is BDK?

BDK, Bean Development Kit is a tool that enables to create, configure and connect a set of set of Beans and it can be used to test Beans without writing a code.

27. How do I include static files within a JSP page?

Static resources should always be included using the JSP include directive. This way, the inclusion is performed just once during the translation phase.

28. What are the lifecycle of JSP?

When presented with JSP page the JSP engine does the following 7 phases.
Page translation: -page is parsed, and a java file which is a servlet is created.
Page compilation: page is compiled into a class file
Page loading : This class file is loaded.
Create an instance :- Instance of servlet is created
jspInit() method is called
_jspService is called to handle service calls
_jspDestroy is called to destroy it when the servlet is not required.

29. What are context initialization parameters?

Context initialization parameters are specified by the in the web.xml file, these are initialization parameter for the whole application.

30. How can I implement a thread-safe JSP page?

You can make your JSPs thread-safe adding the directive <%@ page isThreadSafe=”false” % > within your JSP page.

31. What is a Scriptlet?

A scriptlet can contain any number of language statements, variable or expressions that are valid in the page scripting language. Within scriptlet tags, you can declare variables to use later in the file, write expressions valid in the page scripting language, use any of the JSP implicit objects or any object declared with a . Generally a scriptlet can contain any java code that are valid inside a normal java method. This will become the part of generated servlet’s service method.

32. What are the Collection types in Hibernate ?

Set, List, Array, Map, Bag

33. Differentiate between .ear,  .jar and .war files.

.jar files: These files are with the .jar extenstion. The .jar files contains the libraries, resources and accessories files like property files.
.war files: These files are with the .war extension. The .war file contains jsp, html, javascript and other files for necessary for the development of web applications.
.ear files: The .ear file contains the EJB modules of the application.

34. What are JSP Directives? Directives <%@page language=”java” %>
2. include Directives: <%@ include file=”/header.jsp” %>
3. taglib Directives <%@ taglib uri=”tlds/taglib.tld” prefix=”html” %>

35.What is ActionErrors?

ActionErrors object that encapsulates any validation errors that have been found. If no errors are found, return null or an ActionErrors object with no recorded error messages.The default implementation attempts to forward to the HTTP version of this method. Holding request parameters  mapping and request  and returns set of validation errors, if validation failed; an empty set or null

36.What is the EAR file?

An EAR file is a JAR file with an .ear extension. A J2EE application with all of its modules is delivered in EAR file.

37.How do you pass data (including JavaBeans) to a JSP from a servlet?- (1) Request Lifetime: Using this technique to pass beans, a request dispatcher (using either “include” or forward”) can be called. This bean will disappear after processing this request has been completed. Servlet: request. setAttribute(”theBean”, myBean); RequestDispatcher rd = getServletContext(). getRequestDispatcher(”thepage. jsp”); rd. forward(request, response); JSP PAGE:<jsp: useBean id=”theBean” scope=”request” class=”. . . . . ” />(2) Session Lifetime: Using this technique to pass beans that are relevant to a particular session (such as in individual user login) over a number of requests. This bean will disappear when the session is invalidated or it times out, or when you remove it. Servlet: HttpSession session = request. getSession(true); session. putValue(”theBean”, myBean); /* You can do a request dispatcher here, or just let the bean be visible on the next request */ JSP Page:<jsp:useBean id=”theBean” scope=”session” class=”

. . ” /> 3) Application Lifetime: Using this technique to pass beans that are relevant to all servlets and JSP pages in a particular app, for all users. For example, I use this to make a JDBC connection pool object available to the various servlets and JSP pages in my apps. This bean will disappear when the servlet engine is shut down, or when you remove it. Servlet: GetServletContext(). setAttribute(”theBean”, myBean); JSP PAGE:<jsp:useBean id=”theBean” scope=”application” class=”. . . ” />

38.How can I set a cookie in JSP?

response. setHeader(”Set-Cookie”, “cookie string”); To give the response-object to a bean, write a method setResponse (HttpServletResponse response) – to the bean, and in jsp-file:<% bean. setResponse (response); %>

39.What is URL?

URL stands for Uniform Resource Locator and it points to resource files on the Internet. URL has four components: http://www. address. com:80/index.html, where http – protocol name, address – IP address or host name, 80 – port number and index.html – file path.

40.What is action mapping??

In action mapping we specify action class for particular url ie path and diffrent target view ie forwards on to which request response will be forwarded.The ActionMapping represents the information that the ActionServlet knows about the mapping of a particular request to an instance of a particular Action class.The mapping is passed to the execute() method of the Action class, enabling access to this information directly.

41.How many Cookies is supported to the host ?

User agents excepted to support twenty per host.And its take four Kilobytes each.

42.What is the use of setComment and getComment methods in Cookies ?

setComment:If a user agent (web browser) presents this cookie to a user, the cookie’s purpose will be described using this comment. This is not supported by version zero cookies.

public void setComment(String use)
Returns the comment describing the purpose of this cookie, or null if no such comment has been defined.

43.Why do you need both GET and POST method implementations in Servlet?

A single servlet can be called from differenr HTML pages,so Different method calls can be possible.

44.If you want to modify the servlet,will the Webserver need to be ShutDown.


45.What is the uses Sessions ?

Its a part of the SessionTracking and it is for mainting the client state at server side.

46.What are the advantage of using Sessions over Cookies and URLReWriting?

Sessions are more secure and fast becasue they are stored at serverside. But Sessions has to be used combindly with Cookies or URLReWriting for mainting the client id that is sessionid at client side.
Cookies are stored at client side so some clients may disable cookies so we may not sure that thecookies which we are mainting may work or not but in sessions cookies are disable we can maintain our sessionid using URLReWriting .
In URLReWriting we can’t maintain large data because it leads to network traffic and access may be become slow.Where as in seesions will not maintain the data which we have to maintain instead
we will maintain only the session id.

47.What is session tracking and how do you track a user session in servlets?

Session tracking is a mechanism that servlets use to maintain state about a series requests
from the same user across some period of time. The methods used for session tracking are:

a) User Authentication – occurs when a web server restricts access to some of its resources to only those clients that log in using a recognized username and password
b) Hidden form fields – fields are added to an HTML form that are not displayed in the client’s browser. When the form containing the fields is submitted, the fields are sent back to the server
c) URL rewriting – every URL that the user clicks on is dynamically modified or rewritten to include extra information. The extra information can be in the form of extra path information, added parameters or some custom, server-specific URL change.
d) Cookies – a bit of information that is sent by a web server to a browser and which can later be read back from that browser.
e) HttpSession- places a limit on the number of sessions that can exist in memory. This limit is set in the session.maxresidents property

48.What is Cookies and what is the use of Cookies ?

Cookies are used to get user agents (web browsers etc) to hold small amounts of state associated with a user’s web browsing.Later that infromation read by server

49.What is the advantage of Servlets over other serverside technologies.

PlatForm independent, so once compiled can be used in any webserver.For different processes different threads will execute inbuilt mutithreaded.

50. What are the various Struts tag libraries?

The various Struts tag libraries are:
a. Bean tag library – to access JavaBeans and their properties.
b. HTML tag library – to give standard HTML output, like forms, text boxes, etc.
c. Logic tag library – in order to generate conditional output, iteration capabilities and flow management.
d. Tiles or Template tag library – for those application using tiles.
e. Nested tag library – in order to use the nested beans in the application.

51. How the exceptions are handled in struts?

Exceptions in Struts are handled in two ways:

a. Programmatic exception handling: It is the explicit try/catch blocks in the code that can throw exception. It works well when any error occurs in the custom value
b. Declarative exception handling: In this we either define <global-exceptions> handling tags in the struts-config.xml or exception handling tags within <action></action> tag. It works well when error occurs in custom page and applies only to exceptions thrown by Actions.

52. What is the Map interface?

The Map interface replaces the JDK 1.1 Dictionary class and is used associate keys with values.

53.Does a class inherit the constructors of its superclass?

A class does not inherit constructors from any of its superclasses.

54. Which class should you use to obtain design information about an object?

The Class class is used to obtain information about an object’s design.

55. What are the contents of web.xml and struts-config.xml? Explain the difference between them.

The web.xml file contains the information used by servlets and JSPs, having the description of the application, mapping information about servlets and URL, JSP configuration information, error page information without the exceptions.
The struts-config.xml file contains information about struts framework at the time of deploying the web application. It includes information about form bean, action mappings, controller information containing the buffer size, content type, etc.

56. Is &&= a valid Java operator?

No. It is not a valid java operator.

57 . Name the eight primitive Java types.

The eight primitive types are byte, char, short, int, long, float, double, and boolean.

58. What is SwitchAction & ForwardAction in struts?

A SwitchAction switches between modules and forwards the control to the URL specified in the new module. There are two parameters namely page, to which control is forwarded after switching and prefix that specifies the module to which the control is switched.
A ForwardAction is used to forward a request to the specified URL, represented as a destination to the controller to which it is sent after the action is completed.

59. What is Struts?

Struts is an open source software that helps developers to easily build web application. It is a web page development framework which comprises of Java Servlets, Java Server Pages, custom tags, and message resources into a single framework. It is also a cooperative platform for development teams as well as independent developers.

60. Explain the components of Struts?

Struts is based on the MVC design pattern and its components can be categorized into:
Model: Components like business logic / business processes and data are parts of this.
View: It contains JSP, HTML etc.
Controller: Action Servlet of Struts is part of Controller components which works as front controller to handle all the requests.

61.What are JSP directives?

JSP directives are messages for the JSP engine. i.e., JSP directives serve as a message from a JSP page to the JSP container and control the processing of the entire page
They are used to set global values such as a class declaration, method implementation, output content type, etc.
They do not produce any output to the client.
Directives are always enclosed within <%@ ….. %> tag.
Ex: page directive, include directive, etc.

62.What are implicit objects in JSP?

Implicit objects in JSP are the Java objects that the JSP Container makes available to developers in each page. These objects need not be declared or instantiated by the JSP author. They are automatically instantiated by the container and are accessed using standard variables; hence, they are called implicit objects.The implicit objects available in JSP are as follows:
The implicit objects are parsed by the container and inserted into the generated servlet code. They are available only within the jspService method and not in any declaration.

63. What is Action Class?

The Action Class is a part of the Model. Its purpose is to translate the HttpServletRequest to the business logic and use the Action, we need to have a Subclass and overwrite the execute() method, In which all the database/ business processing are done. The ActionServlet (command) passes the parameterized class to Action Form using the execute() method and its return type is used by the Struts Framework to forward the request to the file according the value of the returned ActionForward object.

64.What is the _jspService() method?

SThe _jspService() method of the javax.servlet.jsp.HttpJspPage interface is invoked every time a new request comes to a JSP page. This method takes the HttpServletRequest and HttpServletResponse objects as its arguments. A page author cannot override this method, as its implementation is provided by the container.

65.What is the jspDestroy() method?

The jspDestroy() method of the javax.servlet.jsp.JspPage interface is invoked by the container when a JSP page is about to be destroyed. This method is similar to the destroy() method of servlets. It can be overridden by a page author to perform any cleanup operation such as closing a database connection.

66.What JSP lifecycle methods can I override?

You cannot override the _jspService() method within a JSP page. You can however, override the jspInit() and jspDestroy() methods within a JSP page. jspInit() can be useful for allocating resources like database connections, network connections, and so forth for the JSP page. It is good programming practice to free any allocated resources within jspDestroy().

67.How can I override the jspInit() and jspDestroy() methods within a JSP page?

The jspInit() and jspDestroy() methods are each executed just once during the lifecycle of a JSP page and are typically declared as JSP declarations:

68.What are the advantages of JSP over Servlet?

JSP is a serverside technology to make content generation a simple appear.The advantage of JSP is that they are document-centric. Servlets, on the other hand, look and act like programs. A Java Server Page can contain Java program fragments that instantiate and execute Java classes, but these occur inside an HTML template file and are primarily used to generate dynamic content. Some of the JSP functionality can be achieved on the client, using JavaScript. The power of JSP is that it is server-based and provides a framework for Web application development.

69.What is the life-cycle of JSP?

When a request is mapped to a JSP page for the first time, it translates the JSP page into a servlet class and compiles the class. It is this servlet that services the client requests.
A JSP page has seven phases in its lifecycle, as listed below in the sequence of occurrence:
Loading the class
Instantiating the class
jspInit() invocation
_jspService() invocation
jspDestroy() invocation

70.What is JCA in java?

Java Cryptography Architecture term from Sun for implementing security functions for the Java platform. It provides a platform and gives architecture and APIs for encryption and decryption. JCA is used by the developer to combine the application with the security measure. A programmer uses the JCA to meet the security measure. It helps in performing the third partly security rules. It uses the hash table, encryption message digest, etc to implement the security.

71.What is JPA in java?

The Java Persistence API is enabling us to create the persistence layer for desktop and web applications. Java Persistence deals in following:
Java Persistence API
Query language
Java Persistence Criteria API
Object mapping metadata

72.What is difference between eager and lazy loading?

The difference between eager and loading are:
Eager loading means to load the data before the requirement whereas lazy loading mean that load the data only when required.
Eager loading fetch the data in one query whereas lazy loading fetch the data when needed by triggering the sub query.

73.What is JMS in Java?

Java Message Service (JMS) is used for creating the communication interface between two clients by using the message passing services. This helps the application to interact with other components irrespective of components location whether they rely on same system or connect to the main system through LAN or internet.

74. Which Java operator is right associative?

The = operator is right associative.

75.When can an object reference be cast to an interface reference?

An object reference be cast to an interface reference when the object implements the referenced interface.

76.What is the difference between a Window and a Frame?

The Frame class extends Window to define a main application window that can have a menu bar.

77. Which class is extended by all other classes?

The Object class is extended by all other classes.

78.What is shallow cloning and deep cloning?

Shallow copy: in this object is copied without its contained objects. Shallow clone only copies the top level structure of the object not the lower levels. It is an exact bit copy of all the attributes.
Deep copy: In this object is copied along with the objects it refers to. Deep clone copies all the levels of the object from top to the bottom recursively.

79.What are Class loaders?

Class loader enables the program to load the class at run time. This is located in the java.lang package.
Using Class Loader we can also load the customize classes which is required for the application execution. The class loaders in Java are organized in a tree. When JVM is started three class loaders are used:
Bootstrap class loader: the core java libraries. It is written in native code.
Extensions class loader: loads the code in the extension directories. It is implemented by ExtClassLoader class.
System class loader: code found on the java.class.path which map to the system class path variables. It is implemented by AppClassLoader class. All user classes by default are load by the system class loader.

80.What is the Comparable interface?

The Comparable interface is used to sort collections and arrays of objects using the collections.sort() and java.utils. The objects of the class implementing the Comparable interface can be ordered. All classes implementing the Comparable interface must implement the compareTo() method that has the return type as an integer. The signature of the compareTo() method is as follows:
int i = object1.compareTo(object2)
If object1 < object2: The value of i returned will be negative.
If object1 > object2: The value of i returned will be positive.
If object1 = object2: The value of i returned will be zero.
What is Single Threaded Model in Servlets?
Single Thread Model is a marker interface which contains no methods and variable in it.
When using Single thread model with Servlet, it make sure that that only one thread can be executed at a time. It avoids running of two or more thead simultaneously.
If we wants to make single threaded we can implement this interface in the following fashion.
public class SingleThreadedTest implements SingleThreadModel
//some code

81. Why are the methods of the Math class static?

So they can be invoked as if they are a mathematical code library.

82. How are commas used in the intialization and iteration parts of a for statement?

Commas are used to separate multiple statements within the initialization and iteration parts of a forstatement.

83. What is the purpose of the wait(), notify(), and notifyAll() methods?

The wait(), notify(), and notifyAll() methods are used to provide an efficient way for threads to wait for a shared resource. When a thread executes an object’s wait() method, it enters the waiting state. It only enters the ready state after another thread invokes the object’s notify() or notifyAll() methods.

84. Name three subclasses of the Component class.

Box.Filler, Button, Canvas, Checkbox, Choice, Container, Label, List, Scrollbar, or TextComponent.

85. What is the relationship between clipping and repainting?

When a window is repainted by the AWT painting thread, it sets the clipping regions to the area of the window that requires repainting.

86. For which statements does it make sense to use a label?

The only statements for which it makes sense to use a label are those statements that can enclose a break orcontinue statement.

87.why we always put the word new while creating object?

Here we are creating an object, instance of class so everytime it is mendatory to allocate memory space to that instance.
So by new key word we are allocating memory to that object

88.why printstream class static object inside System class

There is always one static object (out) inside System class because to connect console with the system class we need the out as well as println(), is a method of Printstream class, So to call that method from system class we need one  object of Printstream class inside System class and to instantiate that object at the starting of the program we make that object as static.

89.Why internationalization often named as i18n?

The term internationalization is abbreviated as i18n, because there are 18 letters between the first “i” and the last “n.”

90.Why does the InputStreamReader class has a read()

When end of stream is reached we always get the value -1. It is not possible with char. How do we know when stream is empty? We can not use EOF, EOL and so on.

91.What is Unicode characters?

Characters defined in Java are called Unicode characters.

92.what is the meaning of abstract?

The meaning of abstract is without body or you can say concept or idea without any instance.In java terminology abstract is a keyword and we can define abstract method and classes.

93.What is the main difference between Java platform and other platforms?

The Java platform differs from most other platforms in that it’s a software-only platform that runs on top of other hardware-based platforms. The Java platform has two components: 1. The Java Virtual Machine (Java VM) 2. The Java Application Programming Interface (Java API)

94.What is the Java Virtual Machine (JVM) ?

The Java Virtual Machine is a software that can be ported onto various hardware-based platforms.

95.What is the Java API?

The Java API is a large collection of ready-made software components that provide many useful capabilities, such as graphical user interface (GUI) widgets.

96.what is new in JSP?

JSP is a dynamic web page and it runs on server side .Jsp stands for “Java server page”.JSP are built by SUN Microsystem.JSP enable the developers to directly insert java code into jsp file,
this makes the development process very simple and its maintenance also becomes very easy.JSP simply place JAVA inside the HTML pages means it’s an embedded of html tag and jsp’s own tag.

97.What is difference between Hashmap and Hashtable?

There is almost no difference, since hashmap is Hash table based implementation of the Map interface (citation from API). The difference is that Hashtable is synchronized.

98. When a thread blocks on I/O, what state does it enter?

A thread enters the waiting state when it blocks on I/O.

99. What is clipping?

Clipping is the process of confining paint operations to a limited area or shape.

100. What is a native method?

A native method is a method that is implemented in a language other than Java.

101. To what value is a variable of the String type automatically initialized?

The default value of an String type is null.

102. What is a task’s priority and how is it used in scheduling?

A task’s priority is an integer value that identifies the relative order in which it should be executed with respect to other tasks. The scheduler attempts to schedule higher priority tasks before lower priority tasks.




This site uses Akismet to reduce spam. Learn how your comment data is processed.