Advanced Java Interview Questions – Set 03

What is caller ?

Same as caller principal.

What is comment ?

In an XML document, text that is ignored unless the parser is specifically told to recognize it.

What is “application configuration resource file” ?

An XML file used to configure resources for a JavaServer Faces application, to define navigation rules for the application, and to register converters, validators, listeners, renderers, and components with the application.

how convert java file to jar files

cmd/designated folder/ jar cf name.jar *.*

Create a file: META-INF/MANIFEST.MF Add a line: Main-Class: com.myco.calc.CalculatorDemo Include META-INF/MANIFEST.MF in calculator.jar Run with java -jar calculator.jar

.What’s the difference between load() and get()

load() get()
Only use the load() method if you are sure that the object exists. If you are not sure that the object exists, then use one of the get() methods
load() method will throw an exception if the unique id is not found in the database. get() method will return null if the  unique id is not found in the database.
load() just returns a proxy by default and database won’t be hit until the proxy is first invoked. get() will hit the database immediately.

What is Cookies and what is the use of Cookies

A “cookie” is a small piece of information sent by a web server to store on a web browser so it can later be read back from that browser. This is useful for having the browser remember some specific information.

  • to create a temporary session where the site in some way “remembers in the short term” what the user was doing or had chosen between web page requests, e.g. remembering who the user is logged in as at the moment, or what they’ve ordered from an on-line “shopping cart”;
  • to remember low-security information more permanently: for example, to remember a user’s search results preferences or who they are logged in as on their social bookmarking site;
  • to compile user statistics, e.g. for advertising purposes or for improving the functionality of a site.

Getting the Value of a Cookie with a Specified Name :

for(int i=0; i<cookies.length; i++)

{

Cookie cookie = cookies[i];

if (cookieName.equals(cookie.getName()))

return(cookie.getValue());

}

return(defaultValue);

What is the difference in usingrequest.getRequestDispatcher() and context.getRequestDispatcher()

request.getRequestDispatcher(path): In order to create it we need to give the relative path of the resource context.getRequestDispatcher(path): In order to create it we need to give the absolute path of the resource.

How many messaging models do JMS provide for and what are they

JMS provide for two messaging models, publish-and-subscribe and point-to-point queuing.

Why we are used setMaxAge() and getMaxAge() in Cookies

Gets/sets how much time (in seconds) should elapse before the cookie expires. If you don’t set this, the cookie will last only for the current session (i.e. until the user quits the browser), and will not be stored on disk.

What is the use of setSecure() and getSecure() in Cookies

setSecure method indicates to the web browser that the cookie should only be sent using a secure protocol (https). getSecure method returns the value of the ‘secure’ flag.