Monday, October 8, 2012

Java Swing Question and Answer



Question Set 1 :

1) What is Event-Driven-Thread (EDT) in Swing?
Event-Driven-Thread or EDT is a special thread in Swing and AWT. Event-Driven Thread is used to draw graphics and listen for events in Swing. You will get a bonus point if you able to highlight that time consuming operations like connecting to database, opening a file or connecting to network should not be done on EDT thread because it could lead to freezing GUI because of blocking and time consuming nature of these operations instead they should be done on separate thread and EDT can just be used to spawn those thread on a button click or mouse click.

2) Does Swing is thread safe? What do you mean by swing is not thread-safe?
This swing interview questions is getting very popular now days. Though it’s pretty basic many developer doesn't understand thread-safety issue in Swing. Since Swing components are not thread-safe it means you can not update these components in any thread other than Event-Driven-Thread. If you do so you will get unexpected behavior. Some time interviewer will also ask what are thread-safe methods in swing which can be safely called from any thread only few like repaint() and revalidate().

3) What are differences between Swing and AWT?
One of the classic java swing interview questions and mostly asked on phone interviews. There is couple of differences between swing and AWT:

1) AWT component are considered to be heavyweight while Swing component are lightweights
2) Swing has plug-gable look and feel.
3) AWT is platform depended same GUI will look different on different platform while Swing is developed in Java and is platform dependent.

4) Why Swing components are called lightweight component?
Another popular java swing interview question, I guess the oldest that is generally comes as follow-up of earlier question based on your answer provided. AWT components are associated with  native screen resource and called heavyweight component while Swing components is uses the screen resource of an ancestor instead of having there own and that's why called lightweight or lighter component.

5) What is difference between invokeAndWait and invokeLater?
This swing interview question is asked differently at different point. some time interviewer ask how do you update swing component from a thread other than EDT, for such kind of scenario we use SwingUtilities.invokeAndWait(Runnable r) and SwingUtilities.invokeLetter(Runnable r) though there are quite a few differences between these two, major one is invokeAndWait is a blocking call and wait until GUI updates while invokeLater is a non blocking asynchronous call. In my opinion these question has its own value and every swing developer should be familiar with these questions or concept not just for interview point of view but on application perspective.

6) Write code for JTable with custom cell editor and custom cell renderer?
Now comes harder part of swing interviews, questions asked in this part of Swing interview is mostly about writing code and checking developer’s capability of API familiarity, key concept of swing code etc.

JTable is one of favorite topic of all Swing interviews and most popular questions on swing interviews are from JTable why? Because here interviewer will directly asked you to write code another reason is JTable heavily used in all Electronic trading GUI. GUI used for online stock trading uses JTable to show data in tabular format so an in depth knowledge of JTable is required to work on online trading GUI developed in Swing. While this question is just an example questions around JTable are mostly centered around updating table, how do you handle large volume of data in table, using customize cell renderer and editor, sorting table data based on any column etc. so just make sure you have done quite a few handsone exercise on JTable before appearing for any java swing interview in IB.

7) Write code to print following layout (mainly focused on GridBag layout)?
After JTable second favorite topic of swing interviewer is GridBagLayout. GridBagLayout in swing is most powerful but at same time most complex layout and a clear cut experience and expertise around GridBagLayout is desired for developing Swing GUI for trading systems. No matter whether you are developing GUI for equities trading, futures or options trading or forex trading you always required GridBagLayout. Swing interview question on GridBagLayout will be mostly on writing code for a particular layout just like an example shown here. In which six buttons A, B, C, D, E and F are organized in certain fashion.


8) How do you handle opening of database, file or network connection on a click of button?
This one is one of the easy java swing interview question. Interviewer is interested on whether you know the basic principle of Java GUI development or not. answer is you should not do this operation in EDT thread instead  spawn a new thread from actionListener or button and disable the button until operation gets completed to avoid resubmitting request. Only condition is that your GUI should always be responsive no matter what happens on network connection or database connection because these operations usually take time.

9) Prediction of output of code?
This is another category of Swing interview questions asked in IB whether they will give you code and asked what would be the output , how will the GUI look like. This type of question is based upon how well you understand and visualize the code. Whether you are familiar with default layout manager of various component classes or not e.g. default layout of JFrame is BorderLayout. So do some practice of these kinds of java Swing interview questions as well?

10) Question around JList like Creating a Jlist component such which should contain all the asset classes like stocks, futures, options and derivatives etc in form of String. But constraint is JList should always be sorted in Ascending order except that all assets which begins with "Electronic trading” appears on top?
This is an excellent java swing interview questions which is based on real world task and focus on JList component, Sorting and customizing JList model. For sorting you can use comparable in Java and by customizing the JList model you can display content as requested. Once you successfully answer this question there may be some followup on customizing the color of cell etc which can be done by customizing renderer.

11) Can a class be it’s own event handler? Explain how to implement this.
A: Sure. an example could be a class that extends Jbutton and implements ActionListener. In the actionPerformed method, put the code to perform when the button is pressed.

12) Why does JComponent have add() and remove() methods but Component does not?
A: because JComponent is a subclass of Container, and can contain other components and jcomponents.

13) How would you create a button with rounded edges?
A: there’s 2 ways. The first thing is to know that a JButton’s edges are drawn by a Border. so you can override the Button’s paintComponent(Graphics) method and draw a circle or rounded rectangle (whatever), and turn off the border. Or you can create a custom border that draws a circle or rounded rectangle around any component and set the button’s border to it.

14) If I wanted to use a SolarisUI for just a JTabbedPane, and the Metal UI for everything else, how would I do that?
A: in the UIDefaults table, override the entry for tabbed pane and put in the SolarisUI delegate. (I don’t know it offhand, but I think it’s "com.sun.ui.motiflookandfeel.MotifTabbedPaneUI" - anything simiar is a good answer.)

15) What is the difference between the ‘Font’ and ‘FontMetrics’ class?
A: The Font Class is used to render ‘glyphs’ - the characters you see on the screen. FontMetrics encapsulates information about a specific font on a specific Graphics object. (width of the characters, ascent, descent)

16) What class is at the top of the AWT event hierarchy?
A: java.awt.AWTEvent. if they say java.awt.Event, they haven’t dealt with swing or AWT in a while.

17) Explain how to render an HTML page using only Swing.
A: Use a JEditorPane or JTextPane and set it with an HTMLEditorKit, then load the text into the pane.

18) How would you detect a keypress in a JComboBox?
A: This is a trick. most people would say ‘add a KeyListener to the JComboBox’ - but the right answer is ‘add a KeyListener to the JComboBox’s editor component.’

19) Why should the implementation of any Swing callback (like a listener) execute quickly?   A: Because callbacks are invoked by the event dispatch thread which will be blocked processing other events for as long as your method takes to execute.

20) In what context should the value of Swing components be updated directly?  
A: Swing components should be updated directly only in the context of callback methods invoked from the event dispatch thread. Any other context is not thread safe?

21) Why would you use SwingUtilities.invokeAndWait or SwingUtilities.invokeLater?              A: I want to update a Swing component but I’m not in a callback. If I want the update to happen immediately (perhaps for a progress bar component) then I’d use invokeAndWait. If I don’t care when the update occurs, I’d use invokeLater.

22) If your UI seems to freeze periodically, what might be a likely reason?              
A: A callback implementation like ActionListener.actionPerformed or MouseListener.mouseClicked is taking a long time to execute thereby blocking the event dispatch thread from processing other UI events.

23) Which Swing methods are thread-safe?                                                              
A: The only thread-safe methods are repaint(), revalidate(), and invalidate()

24) Why won’t the JVM terminate when I close all the application windows?            
A: The AWT event dispatcher thread is not a daemon thread. You must explicitly call System.exit to terminate the JVM.

25 What is the difference between a Choice and a List?
A: A Choice is displayed in a compact form that requires you to pull it down to see the list of available choices. Only one item may be selected from a Choice. A List may be displayed in such a way that several List items are visible. A List supports the selection of one or more List items.

26 what interface is extended by AWT event listeners?
A: All AWT event listeners extend the java.util.EventListener interface.

27 what is a layout manager?
A: A layout manager is an object that is used to organize components in a container.

28 Which Component subclass is used for drawing and painting?
A: Canvas

29 what is the difference between a Scrollbar and a Scroll Pane?
A: A Scrollbar is a Component, but not a Container. A Scroll Pane is a Container. A Scroll Pane handles its own events and performs its own scrolling.

30 Which Swing methods are thread-safe?
A: The only thread-safe methods are repaint (), revalidate (), and invalidate ()

31 which containers use a border Layout as their default layout?
A: The Window, Frame and Dialog classes use a border layout as their default layout

32 what is the preferred size of a component?
A: The preferred size of a component is the minimum component size that will allow the component to display normally

33 which containers use a Flow Layout as their default layout?
A: The Panel and Applet classes use the Flow Layout as their default layout

34 what is the immediate super class of the Applet class?
A: Panel

35 Name three Component subclasses that support painting?
A: The Canvas, Frame, Panel, and Applet classes support painting

36 what is the immediate super class of the Dialog class?
A: Window

37 what is clipping?
A: Clipping is the process of confining paint operations to a limited area or shape.

38 what is the difference between a Menu Item and a Check box MenuItem?
A: The Checkbox Menu Item class extends the MenuItem class to support a menu item that may be checked or unchecked.

39 what class is the top of the AWT event hierarchy?
A: The java.awt.AWTEvent class is the highest-level class in the AWT event-class hierarchy

40 In which package are most of the AWT events that support the event-delegation model defined?
A: Most of the AWT-related events of the event-delegation model are defined in the java.awt.event package. The AWTEvent class is defined in the java.awt package.

41 which class is the immediate super class of the Menu Component class?
A: Object

42 which containers may have a Menu Bar?
A: Frame

43 what is the relationship between the Canvas class and the Graphics class?
A: A Canvas object provides access to a Graphics object via its paint () method.

44 How are the elements of a Border Layout organized?
A: The elements of a Border Layout are organized at the borders (North, South, East, and West) and the center of a container.

Question Set 2 :

1. What is JFC?
A: JFC stands for Java Foundation Classes. The Java Foundation Classes (JFC) are a set of Java class libraries provided as part of Java 2 Platform, Standard Edition (J2SE) to support building graphics user interface (GUI) and graphics functionality for client applications that will run on popular platforms such as Microsoft Windows, Linux, and Mac OSX.

2. What is AWT?
A: AWT stands for Abstract Window Toolkit. AWT enables programmers to develop Java applications with GUI components, such as windows, and buttons. The Java Virtual Machine (JVM) is responsible for translating the AWT calls into the appropriate calls to the host operating system.

3. What are the differences between Swing and AWT?
A: AWT is heavy-weight components, but Swing is light-weight components. AWT is OS dependent because it uses native components, But Swing components are OS independent. We can change the look and feel in Swing which is not possible in AWT. Swing takes less memory compared to AWT. For drawing AWT uses screen rendering where Swing uses double buffering.

4. What are heavyweight components?
A: A heavyweight component is one that is associated with its own native screen resource (commonly known as a peer).

5. What is lightweight component?
A: A lightweight component is one that “borrows” the screen resource of an ancestor (which means it has no native resource of its own — so it’s “lighter”).

6. What is double buffering?
A: Double buffering is the process of use of two buffers rather than one to temporarily hold data being moved to and from an I/O device. Double buffering increases data transfer speed because one buffer can be filled while the other is being emptied.

7. What is an event?
A: Changing the state of an object is called an event.

8. What is an event handler ?
A: An event handler is a part of a computer program created to tell the program how to act in response to a specific event.

9. What is a layout manager?
A: A layout manager is an object that is used to organize components in a container.

10. What is clipping?
A: Clipping is the process of confining paint operations to a limited area or shape.

11. Which containers use a border Layout as their default layout?
A: The window, Frame and Dialog classes use a border layout as their default layout.

12. What is the preferred size of a component?
A: The preferred size of a component is the minimum component size that will allow the component to display normally.

13. What method is used to specify a container’s layout?
A: The setLayout() method is used to specify a container’s layout.

14. Which containers use a FlowLayout as their default layout?
A: The Panel and Applet classes use the FlowLayout as their default layout.

15. Which method of the Component class is used to set the position and size of a component?
A: setBounds

16. What is the difference between invokeAndWait() and invokeLater()?
invokeAndWait is synchronous. It blocks until Runnable task is complete. InvokeLater is asynchronous. It posts an action event to the event queue and returns immediately. It will not wait for the task to complete

17. Why should any swing call back implementation execute quickly?
Callbacks are invoked by the event dispatch thread. Event dispatch thread blocks processing of other events as long as call back method executes.

18. What is an applet?
Applet is a java program that runs inside a web browser.

19. What is the difference between applications and applets?
Application must be run explicitly within Java Virtual Machine whereas applet loads and runs itself automatically in a java-enabled browser. Application starts execution with its main method whereas applet starts execution with its init method. Application can run with or without graphical user interface whereas applet must run within a graphical user interface. In order to run an applet we need a java enabled web browser or an appletviewer.
20. Which method is used by the applet to recognize the height and width?
getParameters().

21. When we should go for codebase in applet?
If the applet class is not in the same directory, codebase is used.

22. What is the lifecycle of an applet?
init( ) method – called when an applet is first loaded
start( ) method – called each time an applet is started
paint( ) method – called when the applet is minimized or maximized
stop( ) method – called when the browser moves off the applet’s page
destroy( ) method – called when the browser is finished with the applet

23. Which method is used for setting security in applets?
setSecurityManager

24. What is an event and what are the models available for event handling?
Changing the state of an object is called an event. An event is an event object that describes a state of change. In other words, event occurs when an action is generated, like pressing a key on keyboard, clicking mouse, etc. There different types of models for handling events are event-inheritance model and event-delegation model

25. What are the advantages of the event-delegation model over the event-inheritance model?
Event-delegation model has two advantages over event-inheritance model. a)Event delegation model enables event handling by objects other than the ones that generate the events. This allows a clean separation between a component’s design and its use. b)It performs much better in applications where many events are generated. This performance improvement is due to event-delegation model does not have to be repeatedly process unhandled events as is the case of the event-inheritance.

26. What is source and listener?
A source is an object that generates an event. This occurs when the internal state of that object changes in some way. A listener is an object that is notified when an event occurs. It has two major requirements. First, it must have been registered with a source to receive notifications about specific event. Second, it must implement necessary methods to receive and process these notifications.

27. What are controls and what are different types of controls in AWT?
Controls are components that allow a user to interact with your application. AWT supports the following types of controls: Labels, Push Buttons, Check Boxes, Choice Lists, Lists, Scrollbars, and Text Components. These controls are subclasses of Component.

28. What is the difference between choice and list?
A Choice is displayed in a compact form that requires you to pull it down to see the list of available choices and only one item may be selected from a choice. A List may be displayed in such a way that several list items are visible and it supports the selection of one or more list items.

29. What is the difference between scrollbar and scrollpane?
A Scrollbar is a Component, but not a Container whereas Scrollpane is a Container and handles its own events and perform its own scrolling.

30. What is a layout manager and what are different types of layout managers available?
A layout manager is an object that is used to organize components in a container. The different layouts are available are FlowLayout, BorderLayout, CardLayout, GridLayout , GridBagLayout, Boxlayout and SpringLayout

31. How are the elements of different layouts organized?
The elements of a FlowLayout are organized in a top to bottom, left to right fashion. The elements of a BorderLayout are organized at the borders (North, South, East and West) and the center of a container. The elements of a CardLayout are stacked, on top of the other, like a deck of cards. The elements of a GridLayout are of equal size and are laid out using the square of a grid. The elements of a GridBagLayout are organized according to a grid. However, the elements are of different size and may occupy more than one row or column of the grid. In addition, the rows and columns may have different sizes. It is the most flexible layout.

32. What are types of applets?
There are two different types of applets. Trusted Applets and Untrusted applets. Trusted Applets are applets with predefined security and Untrusted Applets are applets without any security.

33. What are the restrictions imposed by a Security Manager on Applets?
Applets cannot read or write files on the client machine that’s executing it. They cannot load libraries or access native libraries. They cannot make network connections except to the host that it came from. They cannot start any program on the client machine. They cannot read certain system properties. Windows that an applet brings up look different than windows that an application brings up.

34. What is the difference between the Font and FontMetrics classes?
The FontMetrics class is used to define implementation-specific properties, such as ascent and descent, of a Font object.

35. What is the relationship between an event-listener interface and an event-adapter class?
An event-listener interface defines the methods that must be implemented by an event handler for a particular kind of event. An event adapter provides a default implementation of an event-listener interface.

36. How can a GUI component handle its own events?
A component can handle its own events by implementing the required event-listener interface and adding itself as its own event listener.

37. What is the difference between the paint() and repaint() methods?
The paint() method supports painting via a Graphics object. The repaint() method is used to cause paint() to be invoked by the AWT painting thread.

38. What interface is extended by AWT event listeners?
All AWT event listeners extend the java.util.EventListener interface.

39. What is Canvas ?
Canvas is a Component subclass which is used for drawing and painting. Canvas is a rectangular area where the application can draw or trap input events.

40. What is default Look-and-Feel of a Swing Component?
Java Look-and-Feel.

41. What are the features of JFC?
Pluggable Look-and-Feel, Accessibility API, Java 2D API, Drag and Drop Support.

42. What does x mean in javax.swing?
Extension of java.

43. What are invisible components?
They are light weight components that perform no painting, but can take space in the GUI. This is mainly used for layout management.

44. What is the default layout for a ContentPane in JFC?
BorderLayout.

45. What does Realized mean?
Realized mean that the component has been painted on screen or that is ready to be painted. Realization can take place by invoking any of these methods. setVisible(true), show() or pack().

46. What is difference between Swing and JSF?
The key difference is that JSF runs on server. It needs a server like Tomcat or WebLogic or WebSphere. It displays HTML to the client. But Swing program is a stand alone application.

47. Why does JComponent class have add() and remove() methods but Component class does not?
JComponent is a subclass of Container and can contain other components and JComponents.

48. What method is used to specify a container’s layout?
The setLayout() method is used to specify a container’s layout.

49. What is the difference between AWT and SWT?
SWT (Standard Widget Toolkit) is a completely independent Graphical User Interface (GUI) toolkit from IBM. They created it for the creation of Eclipse Integrated Development Environment (IDE). AWT is from Sun Microsystems.

50. What is the difference between JFC & WFC?
JFC supports robust and portable user interfaces. The Swing classes are robust, compatible with AWT, and provide you with a great deal of control over a user interface. Since source code is available, it is relatively easy to extend the JFC to do exactly what you need it to do. But the number of third-party controls written for Swing is still relatively small.
WFC runs only on the Windows (32-bit) user interface, and uses Microsoft extensions to Java for event handling and ActiveX integration. Because ActiveX components are available to WFC programs, there are theoretically more controls available for WFC than for JFC. In practice, however, most ActiveX vendors do not actively support WFC, so the number of controls available for WFC is probably smaller than for JFC. The WFC programming model is closely aligned with the Windows platform.

51. What is a convertor?
Converter is an application that converts distance measurements between metric and U.S units.

52. What is the difference between a Canvas and a Scroll Pane?
Canvas is a component. ScrollPane is a container. Canvas is a rectangular area where the application can draw or trap input events. ScrollPane implements horizontal and vertical scrolling.

53. What is the purpose of the enableEvents() method?
The enableEvents() method is used to enable an event for a particular object. Normally, an event is enabled when a listener is added to an object for a particular event. The enableEvents() method is used by objects that handle events by overriding their event-dispatch methods.

54. What is the difference between a MenuItem and a CheckboxMenuItem?
The CheckboxMenuItem class extends the MenuItem class to support a menu item that may be checked or unchecked.

55. Which is the super class of all event classes?
The java.awt.AWTEvent class is the highest-level class in the AWT event-class hierarchy.

56. How the Canvas class and the Graphics class are related?
A Canvas object provides access to a Graphics object via its paint() method.

57. 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. A window can be modal.

58. 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.

59. What advantage do Java’s layout managers provide over traditional windowing systems?
Java uses layout managers to lay out components in a consistent manner across all windowing platforms. Since Java’s layout managers aren’t tied to absolute sizing and positioning, they are able to accommodate platform-specific differences among windowing systems.

60. When should the method invokeLater() be used?
This method is used to ensure that Swing components are updated through the event-dispatching thread.


Tuesday, September 25, 2012

List of Java Question to be prepared before Interview


OOPS and CORE JAVA

What is JVM (Java Virtual Machine)?
What is JIT (Just-in-Time) Compilation?
What is Object Oriented Programming?
Whats a Class?
Whats an Object?
Whats the relation between Classes and Objects?
What are different properties provided by Object-oriented systems?
How do you implement inheritance in Java?
How can we implement polymorphism in Java?
Whats an interface and how will you go about implementing an interface?
What is an Abstract class?
What are Abstract methods?
Whats the difference between Abstract classes and Interfaces?
Whats difference between Static and Non-Static fields of a class?
What are inner classes and whats the practical implementation of inner classes?
What are packages?
What is a constructor in class?
Can constructors be parameterized?
Can you explain transient and volatile modifiers?
What is the use if instanceof  keyword?
What are Native methods in Java?
Explain in depth Garbage collector?
How does the garbage collector determine that the object has to be marked for deletion?
Can you explain finalize() method?
How can we force the garbage collector to run?
Whats the main difference between Switch and If  comparison?
Whats the use of JAVAP tool?
What are applets?
In which package is the applet class located?
What are native interfaces in Java?
what are Class loaders?
what is Bootstrap, Extension and System Class loader?
Can you explain the flow between bootstrap, extension and system class loader?
Can you explain how can you practically do dynamic loading?
How can you copy one array in to a different array?
Can you explain the core collection interfaces?
Can you explain in brief the collection classes which implement the collection interfaces?
Whats the difference between standard JAVA array and ArrayList class?
Whats the use of ensureCapacity in ArrayList class?
How can we obtain an array from an ArrayList class?
What is LinkedList class for?
Can you explain HashSet class in collections?
what is LinkedHashSet class?
what is a TreeSet class?
whats the use of Comparator Interface?
How can we access elements of a collection?
What is Map and SortedMap Interface?
Have you used any collection algorithm?
Why do we use collections when we had traditional ways for collection?
Can you name the legacy classes and interface for collections?
What is Enumeration Interface?
whats the main difference between ArrayList / HashMap and Vector / Hashtable?
Are String object Immutable, Can you explain the concept?
what is a StringBuffer class and how does it differs from String class?
what is the difference between StringBuilder and StringBuffer class?
What is Pass by Value and Pass by reference? How does JAVA handle the same?
What are access modifiers?
what is Assertion?
Can you explain the fundamentals of deep and shallow Cloning?
How do we implement Shallow cloning?
How do we implement deep cloning?
Whats the impact of private constructor?
What are the situations you will need a constructor to be private?
Can you explain final modifier?
What are static Initializers?
If we have multiple static initializer blocks how is the sequence handled?
Define casting? What are the different types of Casting?
Can you explain Widening conversion and Narrowing conversion?
Can we assign parent object to child objects?
Define exceptions?
Can you explain in short how JAVA exception handling works?
Can you explain different exception types?
Can you explain checked and unchecked exceptions?
Can we create our own exception class?
What are chained exceptions?
What is serialization?
How do we implement serialization actually?
Whats the use of Externalizable Interface?

Threading

Whats difference between thread and process?
What is thread safety and synchronization?
What is semaphore?
What are monitors?
Whats the importance of synchronized blocks?
How do we create threads?
whats the difference in using runnable and extends in threads?
Can you explain Thread.sleep?
How to stop a thread?
What is wait() and notify() ?
Can you explain how Scheduling and Priority works in threads?
Can you explain Yielding in threading?
what are daemon threads?


JDBC

How does JAVA interact with databases?
Can we interact with non-relational sources using JDBC?
Can you explain in depth the different sections in JDBC?
Can you explain in short how you go about using JDBC API in code?
How do you handle SQL exceptions?
If there is more than one exception in SQLException class how to go about displaying
it?
Explain Type1, Type2, Type3 and Type4 drivers in JDBC?
What are the advantages and disadvantages of using JDBC-ODBC bridge driver?
What are the advantages and disadvantages of using Native-API/ Partially Java Driver?
What are the advantages and disadvantages of using Net-Protocol/ All-Java driver?
What are the advantages and disadvantages of using Native-protocol/ All-Java driver?
Define meta-data?
What is DatabaseMetaData?
Can you explain ConnectionFactory class?
I want to display tables of a database how do I do it?
Define ResultSetMetaData?
What is the difference between ResultSet and RowSet?
Can ResultSet objects be serialized?
Can you explain ResultSet, RowSet, CachedRowset, JdbcRowset and
WebRowSet relation ship?
what are the different types of resultset?
Explain the concept of PreparedStatement statement interface?
Whats the difference between Statement and PreparedStatement?
How can we call stored procedure using JDBC?
Can you explain CallableStatement interface in detail?
How do you get a resultset object from stored procedure?
How can we do batch updates using CallableStatement Interface?
Define transactions?
what is ACID in transaction?
what are the four essential properties of a transaction?
Explain concurrency and locking?
What are different types of locks?
What are the different types of levels of resource on which locks can be placed?
Define lock escalation?
What is Table level and Row level locking?
What are the problems that can occur if you do not implement locking properly?
What are different transaction levels?
Twist: - what are different types of locks?
What is difference between optimistic and pessimistic locking?
What are deadlocks?
How can we set transaction level through JDBC API?
Can you explain transaction control in JDBC?
What are Savepoints in a transaction?
Servlets and JSP
What are Servlets?
What are advantages of servlets over CGI?
Can you explain Servlet life cycle?
What are the two important APIs in for Servlets?
Can you explain in detail javax.servlet package?
Whats the use of ServletContext?
How do we define an application level scope for servlet?
What's the difference between GenericServlet and HttpServlet?
Can you explain in detail javax.servlet.http package?
Whats the architecture of a Servlet package?
Why is HTTP protocol called as a stateless protocol?
What are the different ways we can maintain state between requests?
What is URL rewriting?
What are cookies?
What are sessions in Servlets?
Whats the difference between getSession(true) and getSession(false) ?
Whats the difference between doPost and doGet methods?
Which are the different ways you can communicate between servlets?
What is functionality of RequestDispatcher object?
How do we share data using getServletContext ()?
Explain the concept of SSI?
What are filters in JAVA?
Can you explain in short how do you go about implementing filters using Apache Tomcat?
Twist: - Explain step by step of how to implement filters?
whats the difference between Authentication and authorization?
Explain in brief the directory structure of a web application?
Can you explain JSP page life cycle?
What is EL?
how does EL search for an attribute?
What are the implicit EL objects in JSP?
How can we disable EL?
what is JSTL?
Can you explain in short what the different types of JSTL tags are?
How can we use beans in JSP?
What is tag for ?
What are JSP directives?
what are Page directives?
what are include directives?
Can you explain taglib directives?
How does JSP engines instantiate tag handler classes instances?
whats the difference between JavaBeans and taglib directives?
what are the different scopes an object can have in a JSP page?
what are different implicit objects of JSP?
what are different Authentication Options available in servlets?
Can you explain how do we practically implement security on a resource?
How do we practically implement form based authentication?
How do we authenticate using JDBC?
Can you explain JDBCRealm?
Can you explain how do you configure JNDIRealm?
How did you implement caching in JSP?


EJB

What is EJB?
what are the different kind of EJBs?
you are designing architecture for a project how do you decide whether you should use
session, entity or message driven bean?
Can you explain EJBHome and EJBObject in EJB?
Can client directly create object of session or entity beans?
Can you explain the concept of local interfaces?
What are the limitations of using Local object?
Which application server have you used for EJB ?
Can you explain step by step practically developing and deploying EJB component?
what is Passivation and Activation in EJB?
Can beans who are involved in transaction have Passivation process?
How does the server decide which beans to passivate and activate?
In what format is the conversational data written to the disk?
Can you explain in brief Life cycle for Stateless and Stateful beans?


Struts

Whats MVC pattern?
Define struts?
Can you explain the directory structure for a struts folder in brief ?
Can you give an overview of how a struts application flows?
Twist: - What are action and action form classes in Struts?

XML and Web Services

What is XML?
What is the version information in XML?
What is ROOT element in XML?
If XML does not have closing tag will it work?
Is XML case sensitive?
What is the difference between XML and HTML?
Is XML meant to replace HTML?
Can you explain why your project needed XML?
What is DTD (Document Type definition)?
What is well formed XML?
What is a valid XML?
What is CDATA section in XML?
What is CSS?
What is XSL?
What is element and attributes in XML?
What are the standard ways of parsing XML document?
In What scenarios will you use a DOM parser and SAX parser?
What is XSLT?
Define XPATH?
What is the concept of XPOINTER?
What is a Web Service ?
What is DISCO ?
What is SOAP ?
What is WSDL ?
Can you explain UDDI ?
Can you explain JAXP ?
What is a XML registry?
What is JAXR?
What is JAXM?
Can you explain how JAXM messaging model works?
Can you explain JAX-RPC?
Internationalization
Can you explain i18n and l10n?
Can you explain internationalization and localization?
What is Locale?
How do we display numbers, currency and Dates according to proper Locale format?
what are resource bundles?
How do we load a resource bundle file?
How can we do inheritance in resource bundles?


JNI

What is Native Interface in JAVA?
Can you say in brief steps required to implement Native interfaces in Java?
Can JNI be used for VB6, C# or VB.NET directly?
What are JNI functions and pointers?
How does the garbage collector know JNI objects are no more used?
Twist: - What are the different types of references JNI supports?
Twist: - How to do you delete global objects?
how does the native language C or C++ understand data types in JAVA?
Can you explain exception handling in JNI?
What are limitations for JNIEnv pointer in multi-threading scenarios?
What are the advantages and disadvantages of using JNI?
Architecture
What are design patterns ?
What is the difference between Factory and Abstract Factory Patterns?
What is MVC pattern?
Twist: - How can you implement MVC pattern in Servlets and JSP?
How can we implement singleton pattern in JAVA?
How do you implement prototype pattern in JAVA?
Twist: - How to implement cloning in JAVA? What is shallow copy and deep copy ?
Can you give a practical implementation of FAƇADE patterns?
How can we implement observer pattern in JAVA?
What is three tier architecture?
What is Service Oriented architecture?
What is aspect oriented programming?


Project Management

What is project management?
Is spending in IT projects constant through out the project?
Who is a stakeholder ?
Can you explain project life cycle ?
Twist :- How many phases are there in software project ?
Are risk constant through out the project ?
Can you explain different software development life cycles ?
What is triple constraint triangle in project management ?
What is a project baselines ?
What is effort variance?
How is normally a project management plan document organized ?
How do you estimate a project?
What is CAR (Causal Analysis and Resolution)?
What is DAR (Decision Analysis and Resolution) ?
What is a fish bone diagram ?
Twist:- What is Ishikawa diagram ?
What is pareto principle ?
Twist :- What is 80/20 principle ?
How do you handle change request?
What is internal change request?
What is difference between SITP and UTP in testing ?
What is the software you have used for project management?
What are the metrics followed in project management?
Twist: - What metrics will you look at in order to see the project is moving successfully?
You have people in your team who do not meet there deadlines or do not perform what
are the actions you will take ?
Twist :- Two of your resources have conflicts between them how would you sort it out ?
What is black box testing and White box testing?
Whats the difference between Unit testing, Assembly testing and Regression testing?
What is V model in testing?
How do you start a project?
How did you do resource allocations?
How will you do code reviews ?
What is CMMI?
What are the five levels in CMMI?
What is continuous and staged representation?
Can you explain the process areas?
What is SIX sigma?
What is DMAIC and DMADV ?
What are the various roles in Six Sigma implementation?
What are function points?
Twist: - Define Elementary process in FPA?
What are the different types of elementary process in FPA?
What are the different elements in Functions points?
Can you explain in GSC and VAF in function points?
What are unadjusted function points and how is it calculated?
Can you explain steps in function points?
What is the FP per day in your current company?
Twist :- What is your companys productivity factor ?
Do you know Use Case points?
What is COCOMO I, COCOMOII and COCOMOIII?
What is SMC approach of estimation?
How do you estimate maintenance project and change requests?


UML

What is UML?
How many types of diagrams are there in UML ?
Twist :- Explain in short all types of diagrams in UML ?
What are advantages of using UML?
Twist: - What is Modeling and why UML ?
What is the sequence of UML diagrams in project?
Twist: - How did you implement UML in your project?
Just a small Twist: - Do I need all UML diagrams in a project?
Give a small brief explanation of all Elements in activity diagrams?
Explain Different elements of a collaboration diagram ?
Explain Component diagrams ?
Explain all parts of a deployment diagram?
Describe the various components in sequence diagrams?
What are the element in State Chart diagrams ?
Describe different elements in Static Chart diagrams ?
Explain the different elements of a Use Case ?
Twist: - What is the difference between Activity and sequence diagrams?(I leave this to
the readers)

Java Web Services Questions

1. What are the features of web services?
A. Web services(WS)
· Web services can convert your applications into web applications
· Web services can be used by other applications
· Web services are published, found and used through the web
· Web services platform is XML + Http
· WS are application components
· WS communicate using open protocols
· WS are self contained and self describing
· WS can be discovered using UDDI (Universal Discovery, Description and Integration)
· XML is the basis for web services
2. How does the web services work?
A. The basic platform for web services is XML and HTTP. The HTTP protocol is the most widely used internet protocol. XML can be used between different platforms and programming languages. XML expresses the complex messages and functions. Following are the basic components of web services platform.
· SOAP(Simple Object Access Protocol)
· UDDI (Universal Description, Discovery and Integration)
· WSDL (Web Services Description Language)
3. Why web services?
· Interoperability is the most important factor
· Reusability of application components
· WS makes your application to publish its function or message to the rest of the world
· using the WS applications can exchange data between different applications and different platforms
· WS used XML to code and decode the data (which is understandable by all applications written in any language)
· WS uses SOAP to transport the data using open protocols
4. What are the three basic elements of web services platform?
· SOAP(Simple Object Access Protocol)
· UDDI (Universal Description, Discovery and Integration)
· WSDL (Web Services Description Language)
5. What is SOAP?
A. SOAP is a XML based protocol that is used by applications to exchange information over HTTP. Or simply we can define it as a protocol for accessing a web service.
The basic Web services platform is XML plus HTTP.
· SOAP is a communication protocol used for communication between applications
· SOAP is a format for sending messages
· SOAP is based on XML (eXtensible Markup Language)
· SOAP is designed to communicate via Internet
· SOAP is platform and language independent
· SOAP is based on XML
· SOAP is simple and extensible
· SOAP allows you to get around firewalls
· SOAP will be developed as a W3C standard
6. What is WSDL?
A. WSDL is an XML based language for describing web services. It also tell you how to access the services that it is providing.
· WSDL is an XML document
· WSDL is used to describe web services, along with the message format and protocol details for the web service
· WSDL is also used to locate Web Services
· WSDL is not yet a W3C standard
7. What is UDDI?
A. UDDI stands for Universal Description, Discovery and Integration. It is a Directory Service where businesses can register and search for web services.
· UDDI is a directory for storing information about web services
· UDDI is a directory of web service interfaces described by WSDL
· UDDI communicates via SOAP
8. What exactly WSDL document contains?
A. It is a document written in XML and used to describe web services. It specifies the location of the service and the operations (or methods) the service exposes.
9. Describe the major elements of a WSDL document?
A. There are four major elements in a WSDL document.
1. - defines the operations performed by the web service
2. - The message used by the web service
3. - defines the data types used by the application
4. - The communication protocols used by the web service
The above four components are generally used in a WSDL document. In addition to above components there are few more elements that can be used in WSDL, like extension elements and a service element that makes it possible to group together the definitions of several web services in one single WSDL document.
10. Explain WSDL ports?
1. is a most important element in the WSDL document.
2. The port defines the connection point to the web service
3. it describes a service, the operations that can be performed and the messages that are involved
4. it can be compared to a function library or a module or a class in general programming languages
11. Explain WSDL message?
1. defines the data elements of an operation
2. each message can consists of one or more parts
3. defines the data types of its parts
4. these parts can be compared to the parameters of a function in general programming languages
12. Explain WSDL types?
1. element defines the data types used by the web service
2. WSDL uses XML Schema syntax to define the data types (for maximum platform neutrality)
13. Explain WSDL binding?
A. WSDL binding element defines 1) message format and 2) protocol details for each port
14. What are different operation types in WSDL?
A. WSDL generally uses request-response type operation. But WSDL has actually four operation types.
1. One-way -> The operation can receive a message but it will not return a message.
2. request-response -> The operation can receive a request and will return a response
3. solicit-response -> The operation can send a request and waill wait for a response
4. Notification -> The operation can send a message but will not wait for a response
15. Explain breifly about WSDL binding to SOAP?
A. The element has two attributes.
1. name attribute - defines the name of the binding
2. type attribute - poitnts to the port for the binding
element has two attributes.
1. style attribute - It can be an "rpc" or a document
2. transport attribute - defines the SOAP protocol to use. HTTP(S) and SMTP are the valid application layer protocols used as Transport for SOAP.
Operation element defines the operation that the port exposes. For each operation, we need to specify the corresponding saopAction. You also need to specify how the input and output are encoded. The different types are literal, encoding types.
16. What is UDDI based on?
A. UDDI is based on XML, SOAP and DNS.
17. What are the Benefits of UDDI?
A.
· Making it possible to discover the right business from the millions currently online
· Defining how to enable commerce once the preferred business is discovered
· Reaching new customers and increasing access to current customers
· Expanding offerings and extending market reach
· Solving customer-driven need to remove barriers to allow for rapid participation in the global Internet economy
· Describing services and business processes programmatically in a single, open, and secure environment
18.  What are the two approaches to create a webservice?
Top Down: From WSDL one generates the Java Classes
Bottom Up: From Java classes one generates the WSDL
19.  Few tools used in your project if you used webservices.
 SOAP UI: Test the web service
 Some times some of the back end services might not available , so you can create a mock response and run the webservice service from the soap ui. Then your program should hit the mock response and you can check the functionality.
 Stylus Studio: Create the XML Schema and generate the binding classes.
 Axis2: Create the web service
20. Explain the use of Castor?
Castor is used to create the binding classes from the schema XML over HTTP

Reference for to learn Web Services:
http://www.j2eebrain.com/java-J2ee-developing-web-services-part-1.html
http://www.j2eebrain.com/java-J2ee-developing-web-services-part-2.html
http://www.j2eebrain.com/java-J2ee-developing-web-services-part-3.html

Advance Java Blogging

Java New Articles

Javas Latest News

Java Web Services and XML

Ajax Latest News

Mac OS Java Features

Advance Spotlights

Patterns Features