Owner: Java Interview Questions URL:http://www.seekjava.info/ Join Date: Sat, 04 Aug 2007 14:05:44 -0500 Rating:0 Site Description: Get complete interview questions on Java platform and learn more about here.Java interview | J2EE interview | Core Java interview | Adv Java interview| J2ME interview | Struts interview| SERVLETS interview| JSP interview| CORBA interview| RMI interview| E Site statistics:Click here
A simple EJB 3 + Servlet application 2007-07-09 13:38:00 In previous post, I wrote a simple EJB3 bean invoked from a standalone java client. Standalone java client is convenient for prototyping and testing purpose. The most common way to invoke EJB is from a web app. Here I will add such a simple web app to invoke the foo-ejb module written in previous post.
Steps 1 - 5 are the same as in previous post, except in step 2, foo/Client.java is not
A simple EJB 3 application, hand-made 2007-06-26 14:00:00 This is a simple EJB 3 app that is written, deployed and run from command line and vim, with no IDE, no ant, no maven, no admin console. The target appserver is glassfish.
1. project directory structure:
C:simple-ejb3> tree /A /F
+—classes
| —foo
—src
—foo
Client.java
FooBean.java
FooRemote.java
2. create java src files under srcfoo:
package foo;
import
Java Architect Interview Questions 2007-06-26 02:30:00 Java Architect
Interview Questions
1. What do you understand by UML. How to interpret UML diagrams?2. State the effect of encapsulation, inheritance, and use of interfaces on architectural characteristics?3. Differentiate between 2 tier, 3 tier and n-tier architectures.4. How do the following characteristics scalability,performance, high availabilty behave based on the above architecture selected.5. In what all ways (methods/concepts) can we achieve integration with legacy/n-n-legacy applications using JAVA technologies.6. List the required classes/interfaces that must be provided for an EJB technology.7. Distinguish stateful and stateless Session beans.8. Distinguish Session and Entity beans.9. Recognize appropriate uses for Entity, Stateful Session, and Stateless Session beans.10. State the transactional behavior in a given scenario for an enterprise bean method with a specified transactional deployment descriptor.11.Given a requirement specification detailing security and flexibilit
Centralize exception handling in java methods (2) 2007-06-16 11:19:00 In this post, I wrote about how to centralize java exception
handling inside one method by saving the exception to a local variable. Some of you might ask, “why not put exception logic into a separate private method?” I would avoid this approach for the following reasons:
1. When the exception-handling logic is specific to the current method, I like to scope it to the current method. Even if
Where to put persistence.xml in web app? 2007-06-15 11:01:00 In all cases, persistence.xml always resides in {root-of-persistence-unit}/META-INF/ directory. For example,
foo.war:
WEB-INF/classes/META-INF/persistence.xml //good
WEB-INF/classes/com/foo123/jpa/Project.class
WEB-INF/web.xml
index.jsp
You may also package entity classes and persistence.xml inside a library jar, which is packaged inside the war:WEB-INF/lib
foo.war:
WEB-INF/lib/my-entities.jar
Use ant NoBannerLogger and -emacs options for better output (2) 2007-06-13 11:46:00 In my previous post, I wrote about using ant options -emacs -logger org.apache.tools.ant.NoBannerLogger to strip out empty targets and task names. Here are more tips to save some typing:
1. define an shell-level alias to include these options.
In bash, add to $HOME/.bashrc:
alias ant=’ant -emacs -logger org.apache.tools.ant.NoBannerLogger’
In tcsh, add to $HOME/.tcshrc:
alias ant ‘ant -emacs
Read more:better
Centralize exception handling in java methods 2007-06-12 13:54:00 Oftentimes we need to handle a series of java exception
s in one method in a similar manner. So it’s desirable to centralize the exception logic to avoid duplication. For example, the following method looks up UserTransaction and then performs the transaction. You will need to handle at least 6 exceptions. I find it handy to first save the exception to handle it at the end.
public void
How to set prompt in tcsh and bash 2007-06-11 17:27:00 Wherever I go, I like to set prompt to display the current directory. I mean the complete path of current directory, not just the last element, and they all must be in one single line.
This is good:/usr/bin/X11 >
Avoid this:
bash-3.2$ cd /usr/bin/X11
bash-3.2$
For tcsh, I have this in my $HOME/.tcshrc:
set prompt=”%/ > ”
For bash, include this in $HOME/.bashrc:
PS1=”w > ”
, Or you can also
Use ant NoBannerLogger and -emacs options for better output 2007-06-06 11:57:00 It can be hard to get useful data from a huge ant output file. So I like to use two options when running ant:
1. -logger org.apache.tools.ant.NoBannerLogger to strip out any empty targets.
2. -emacs to strip out [taskname]
Here is a comparison of running a simple build.xml target:
Read more:better
Start java web start app from command line 2007-06-01 09:59:00 When I need to start a Java webstart app, I usually do it from command
line, instead of opening a browser. There are 2 slightly different ways to do that:
1. Run javaws with the url to jnlp file:
%JAVA_HOME%injavaws http://www.foo123.com/bar/buz.jnlp2. Save the jnlp file locally and run javaws with the local copy. If you enter this jnlp url in the browser’s address bar, it will run the app
Java class extends clause comes before implements clause 2007-08-11 03:26:00 The following class
failed to compile with either JDK 5 or 6:import java.io.Serializable;
public class ImplementsExtendsOrder implements Serializable extends
Object {
}
—————
jdk6injavac ImplementsExtendsOrder.java
ImplementsExtendsOrder.java:7: ‘{’ expected
public class ImplementsExtendsOrder implements Serializable extends Object {
Read more:comes
260 Frequently Asked Questions in java 2007-08-10 10:10:30
Can a main() method of class be invoked in another class?
What is the difference between java command line arguments and C command line arguments?
What is the difference between == & .equals
What is the difference between abstract class & Interface.
What is singleton class & it’s implementation.
Use of static,final variable
Examples of final class
Difference between Event propagation & Event delegation
Difference between Unicast & Multicast model
What is a java bean
What is synchronized keyword used for.
What are the restrictions of an applet & how to make the applet access the local machines resources.
What is reflect package used for & the methods of it.
What is serialization used for
Can methods be overloaded based on the return types ?
Why do we need a finalze() method when Garbage Collection is there ?
Difference between AWT and Swing compenents ?
Is there any heavy weight component in Swings ?
Can the Swing application if you upload in net, be Read more:Frequently Asked Questions
Frequently Asked Questions on Servlets Concepts 2007-08-16 12:39:02 1. How do u deal property files in servlet?
2. What methods do u use in Servlet - Applet communication ?
3. What are the types of Servlet ?
4. Difference between HttpServlet and Generic Servlets ?
5. Difference between doGet and doPost ?
6. What are the methods in HttpServlet?
7. What are the types of SessionTracking?
8. What is Cookie ? Why is Cookie used ?
9. If my browser does not support Cookie,and my server sends a cookie instance What will happen ?
10. Why do u use Session Tracking in HttpServlet ?
11. Can u use javaScript in Servlets ?
12. What is the capacity the doGet can send to the server ?
13. What are the type of protocols used in HttpServlet ?
14. What is meant by a servlet ?
15. What are the types of servlets ? Explain
16. What is the different between a Servlet and a CGI?
17. What is the difference between 2 types of Servlets ?
18. What is the type of method for sending request from HTTP server ?
19. What are the exceptions thrown by Servlets ? Why ?
20. What is the lif Read more:Concepts
, Frequently Asked Questions
Line tools NetBeans plugin 2007-09-19 15:22:00 I don’t like overloading my IDE with a bunch of plugins, but this is a must-have for my NetBeans
. I use it everyday to copy and paste lines of text without using CTRL-C CTRL-V. This is its official description:
Line Tools Support following operations in text editors: 1. Move Line (or lines spanned by selection) Up 2. Move Line (or lines spanned by selection) Down 3. Copy Line (or lines spanned
Latest Java interview questions 2007-09-17 15:00:34 1. When we declare a Private Constructor?
Ans. If we dont want the constructor to be visible to the extend classes then we can declare a constructor to be private and also if we want a class to made as a singleton class then we have to declare it has private
2. What is the difference between redirect and forward in the sense.
we want to go forward from one page then come backward then what is the difference between send redirect and forward ?
Ans: If you want to redirect your page which is residing on a different application then you’ll be using response.sendRedirect(), here the request will be forwarded to another application i,e your request will be redirected to another resoure on different application/server
response.sendRedirect(”http://www.somesite.com”);
If you want to forward your request to another page on the same application then you’ll be using the requestdispatcher.
RequestDispatcher rd = ct.getRequestDispatcher(”/servlet/AccountServlet” Read more:interview
, questions
JAVA overloaded 2007-09-15 13:22:00 JAVA is now the stock symbol for Sun, replacing SUNW. This word JAVA has become more overloaded, and can mean at least 3 things: (1) the Java programming language; (2) the Java Island in Indonesia; and (3) the stock symbol for Sun Microsystems.
So every time you google “java”, you will have more mixed results to filter out. Unfortunately, the first match by google and msn is the stock chart of
Frequently Asked Questions on Servlets Concepts 2007-08-16 12:39:02 1. How do u deal property files in servlet?
2. What methods do u use in Servlet - Applet communication ?
3. What are the types of Servlet ?
4. Difference between HttpServlet and Generic Servlets ?
5. Difference between doGet and doPost ?
6. What are the methods in HttpServlet?
7. What are the types of SessionTracking?
8. What is Cookie ? Why is Cookie used ?
9. If my browser does not support Cookie,and my server sends a cookie instance What will happen ?
10. Why do u use Session Tracking in HttpServlet ?
11. Can u use javaScript in Servlets ?
12. What is the capacity the doGet can send to the server ?
13. What are the type of protocols used in HttpServlet ?
14. What is meant by a servlet ?
15. What are the types of servlets ? Explain
16. What is the different between a Servlet and a CGI?
17. What is the difference between 2 types of Servlets ?
18. What is the type of method for sending request from HTTP server ?
19. What are the exceptions thrown by Servlets ? Why ?
20. What is the lif Read more:Concepts
, Frequently Asked Questions
Java class extends clause comes before implements clause 2007-08-11 03:26:00 The following class
failed to compile with either JDK 5 or 6:import java.io.Serializable;
public class ImplementsExtendsOrder implements Serializable extends
Object {
}
—————
jdk6injavac ImplementsExtendsOrder.java
ImplementsExtendsOrder.java:7: ‘{’ expected
public class ImplementsExtendsOrder implements Serializable extends Object {
Read more:comes
260 Frequently Asked Questions in java 2007-08-10 10:10:30
Can a main() method of class be invoked in another class?
What is the difference between java command line arguments and C command line arguments?
What is the difference between == & .equals
What is the difference between abstract class & Interface.
What is singleton class & it’s implementation.
Use of static,final variable
Examples of final class
Difference between Event propagation & Event delegation
Difference between Unicast & Multicast model
What is a java bean
What is synchronized keyword used for.
What are the restrictions of an applet & how to make the applet access the local machines resources.
What is reflect package used for & the methods of it.
What is serialization used for
Can methods be overloaded based on the return types ?
Why do we need a finalze() method when Garbage Collection is there ?
Difference between AWT and Swing compenents ?
Is there any heavy weight component in Swings ?
Can the Swing application if you upload in net, be Read more:Frequently Asked Questions
A simple EJB 3 + Servlet application 2007-07-09 13:38:00 In previous post, I wrote a simple EJB3 bean invoked from a standalone java client. Standalone java client is convenient for prototyping and testing purpose. The most common way to invoke EJB is from a web app. Here I will add such a simple web app to invoke the foo-ejb module written in previous post.
Steps 1 - 5 are the same as in previous post, except in step 2, foo/Client.java is not
A simple EJB 3 application, hand-made 2007-06-26 14:00:00 This is a simple EJB 3 app that is written, deployed and run from command line and vim, with no IDE, no ant, no maven, no admin console. The target appserver is glassfish.
1. project directory structure:
C:simple-ejb3> tree /A /F
+—classes
| —foo
—src
—foo
Client.java
FooBean.java
FooRemote.java
2. create java src files under srcfoo:
package foo;
import
Java Architect Interview Questions 2007-06-26 02:30:00 Java Architect
Interview Questions
1. What do you understand by UML. How to interpret UML diagrams?2. State the effect of encapsulation, inheritance, and use of interfaces on architectural characteristics?3. Differentiate between 2 tier, 3 tier and n-tier architectures.4. How do the following characteristics scalability,performance, high availabilty behave based on the above architecture selected.5. In what all ways (methods/concepts) can we achieve integration with legacy/n-n-legacy applications using JAVA technologies.6. List the required classes/interfaces that must be provided for an EJB technology.7. Distinguish stateful and stateless Session beans.8. Distinguish Session and Entity beans.9. Recognize appropriate uses for Entity, Stateful Session, and Stateless Session beans.10. State the transactional behavior in a given scenario for an enterprise bean method with a specified transactional deployment descriptor.11.Given a requirement specification detailing security and flexibilit
Centralize exception handling in java methods (2) 2007-06-16 11:19:00 In this post, I wrote about how to centralize java exception
handling inside one method by saving the exception to a local variable. Some of you might ask, “why not put exception logic into a separate private method?” I would avoid this approach for the following reasons:
1. When the exception-handling logic is specific to the current method, I like to scope it to the current method. Even if
Struts Interview questions 2007-10-02 11:33:14 Is Struts threadsafe?
Yes
1. Response is handled by light-weight Action object; rather than individual servlet.
2. Servlet instantiates Action class once and allows other requests to be threaded through the original object.
3. This conserves resources and provides best throughput.
What are the various Struts Tag libraries?
Struts provide many tag libraries to ease the development of web applications. These tag libraries are:
* Bean tag library - Tags for accessing JavaBeans and their properties.
* HTML tag library - Tags to output standard HTML, including forms, text boxes, checkboxes, radio buttons etc..
* Logic tag library - Tags for generating conditional output, iteration capabilities and flow management
* Tiles or Template tag library - For the application using tiles
* Nested tag library - For using the nested beans in the application
What is ActionMapping?
1. Associates an action name with an action.
2. It can contain reference to a form bean t Read more:questions
Websphere Interview Questions 2007-10-02 11:28:09 How to choose websphere over other application servers?
Selecting application server is part of architechtural process when infrastructure is defined. It depends on several facots:
1. External systems your application will be interacting
2. Type of application you have
3. Target availability of system.
4. Corporate standards
5. Budget.
What are deployment descriptors? How many types of Deployment descriptors are available? What are they?
Deployment descriptor is an XML file that describes how to deploy a module or application by specifying configuration and container options. For example, an EJB deployment descriptor passes information to an EJB container about how to manage and control an enterprise bean. There are two types of deployment descriptor in websphere: Web application deployment descriptor and portlet deployemnt descriptor
Portlets are packaged as WAR files with a web application deployment descriptor (web.xml). This defines each portlet as a servlet within t
JSP Interview Questions 2007-10-02 11:27:05 JSP Action:
* JSP actions are XML tags that direct the server to use existing components or control the behavior of the JSP engine.
* Consist of typical (XML-base) prefix of ‘jsp’ followed by a colon, followed by the action name followed by one or more attribute parameters. For example: There are six JSP Actions: , , , , ,
What is the difference between and
?
Both the tag includes the information from one page in another. The differences are as follows: : This is like a function call from one jsp to another jsp. It is executed ( the included page is executed and the generated html content is included in the content of calling jsp) each time the client page is accessed by the client. This approach is useful to for modularizing the web application. If the included file changed then the new content will be included in the output.
: In this case the content of the included file is textually embedded in the page that have directive. In this case in the included file changes,
UML interview questions 2007-10-02 11:24:23 What is UML?
Graphical language for visualizing, specifying, constructing and documenting the artifacts of the system. allows to create blueprints of all the aspects of the system, before physically implementing the system.
What is modeling? What are the advantages of creating a model?
Well-accepted engineering technique which helps build a model. Model is the simplification of reality; blueprint of the system that needs to be built. Model helps you visualize the system. helps to specify the structural and behaviour of the sytem. helps make templates for constructing the system. helps document the sytem.
What are the different views considered when building an object-oriented software system? there aer 5 veiws:
1. Use case view: exposes requirements of a system.
2. Design view: capturing the vocabulary
3. process view: modeling the distribution of the sytems processes and threads.
4. implementation veiw: addressing the physical implementation of the system.
5. deployem Read more:questions
, interview
Servlet Interview Questions 2007-10-02 11:21:58 The java.servlet.Servlet interface defines 3 methos known as life-cycle method.
1. public void init(ServletConfig config) throws ServletException: servlet is constructe, then initialized with the init() method.
2. public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException: any request from client are handled initially by the service() method before delegating to the doXxx() methods in the case of HttpServlet.
3. public void destroy(): Servlet is removed from service, destroyed with the destroy() method, then garbage collected and finalized.
What is the difference between doGet() and doPost()?
doGet() mthod is limited with 2k of data to be sent, and doPost() mehtod doesn’t have this limitation. A request string for doGet() looks like the following: http://www.google.com/svt1?p1=v1&p2=v2&…&pN=vN. doPost() method call doesntneed a long texttail after a servlet name in a request. All parameters are stored in a request itself,
Sample Java Interview Questions 2007-10-02 11:18:56 Inheritance:
Process by which one object acquires the properties of another object. Inheritance allows well-tested procedures to be reused and enables changes to make once and have effect in all relevant places.
Implicit Casting:
Process of simply assigning one entity to another without any transformation guidance to the compiler.
Native method: method that is not implemented in java.
Polymorphism: one name many forms. enables one entity to be used as general category for different types of actions.
Encapsulation: process of binding or wrapping the data and the codes that operates on the data into single entity. This keeps data safe from outside interface and misuse. objects allow procedures to be encapsulated with their data to reduce potential interference. one way to think about encapsulation is as a protective wrapper that prevents code and data from being arbitrarily accessed by other code defined outside the wrapper.
Procedural programs: programming logic follows certain proced Read more:Sample
Jakarta struts interview questions 2007-10-01 14:28:41 1. What is Jakarta
Struts Framework?
Jakarta Struts is open source implementation of MVC (Model-View-Controller) pattern for the development of web based applications. Jakarta Struts is robust architecture and can be used for the development of application of any size. Struts framework makes it much easier to design scalable, reliable Web applications with Java.
2. What is ActionServlet?
The class org.apache.struts.action.ActionServlet is the called the ActionServlet. In the the Jakarta Struts Framework this class plays the role of controller. All the requests to the server goes through the controller. Controller is responsible for handling all the requests.
3. How you will make available any Message Resources Definitions file to the Struts Framework Environment?
Message Resources Definitions file are simple .properties files and these files contains the messages that can be used in the struts project. Message Resources Definitions files can be added to the struts-config.xml file t Read more:questions
, interview