Java Interview Questions and Answers Set 9

81.What does the JDBC Connection interface?

The Connection interface maintains a session with the database. It can be used for transaction management. It provides factory methods that returns the instance of Statement, PreparedStatement, CallableStatement and DatabaseMetaData.

82.Is it necessary that each try block must be followed by a catch block?

It is not necessary that each try block must be followed by a catch block. It should be followed by either a catch block OR a finally block. And whatever exceptions are likely to be thrown should be declared in the throws clause of the method.

83.How does execution phase work in JSF (JavaServer Faces) lifecyle?

In execute phase, when first request is made, application view is built or restored. For other subsequent requests other actions are performed like request parameter values are applied, conversions and validations are performed for component values, managed beans are updated with component values and application logic is invoked.

84.What is h:inpuText tag in JSF (JavaServer Faces)?

The JSF <h: inputText> tag is used to render an input field on the web page.

It is used within a <h: form> tag to declare input field that allows user to input data.

85.What is f:convertNumber tag in JSF (JavaServer Faces)?

It is used to convert component (user input) data into a Java Number type. You can convert a component’s data to a java.lang.Number by nesting the convertNumber tag inside the component tag. The convertNumber tag has several attributes that allow you to specify the format and type of the data.

86.How to create a Fecelet view?

Facelets views are XHTML pages. You can create a web page or view, by adding components to the page, wire the components to backing bean values and properties, and register converters, validators, or listeners on the components.

87.What are Facelets Templates?

It is a tool which provides the facility to implement the user interface. Templating is a useful Facelets feature that allows you to create a page that will act as the base for the other pages in an application. By using templates, you can reuse code and avoid recreating similarly pages again and again.

88.What does the JDBC DatabaseMetaData interface?

The DatabaseMetaData interface returns the information of the database such as username, driver name, driver version, number of tables, number of views etc.

89.What are the features of JUnit?

  • Opensource
  • Annotation support for test cases
  • Assertion support for checking the expected result
  • Test runner support to execute the test case

90.What is the default size of load factor in hashing based collection?

The default size of load factor is 0.75. The default capacity is computed as initial capacity * load factor. For example, 16 * 0.75 = 12. So, 12 is the default capacity of Map.