Java
1. Give a scenario where hotspot will optimize your code?
If we have defined a variable as static and then initialized this variable in a static block then the Hotspot will merge the variable and the initialization in a single statement and hence reduce the code.
2. What will happen if an exception is thrown from the finally block?
The program will exit if the exception is not catched in the finally block.
3. If I give you an assignment to design Shopping cart web application, how will you define the architecture of this application? You are free to choose any framework, tool or server?
Usually I will choose a MVC framework which will make me use other design patterns like Front Controller, Business Delegate, Service Locater, DAO, DTO, Loose Coupling etc. Struts 2 is very easy to configure and comes with other plugins like Tiles, Velocity and Validator etc. The architecture of Struts becomes the architecture of my application with various actions and corresponding JSP pages in place.
Why is it better to use hibernate than JDBC for database interaction in various Java applications?
Hibernate provides an OO view of the database by mapping the various classes to the database tables. This helps in thinking in terms of the OO language then in RDBMS terms and hence increases productivity.
What is the purpose of intern () method in the String class?
It helps in moving the normal string objects to move to the String literal pool
How will you make your web application to use the https protocol?
1. Download JSSE 1.0.2 (or later) from http://java.sun.com/products/jsse/ and either make it an installed extension on the system, or else set an environment variable JSSE_HOME that points at the directory into which you installed JSSE.
2. Create a certificate keystore by executing the following command:
%JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA
3.Uncomment the "SSL HTTP/1.1 Connector" entry in $CATALINA_HOME/conf/server.xml and tweak as necessary.
If we have defined a variable as static and then initialized this variable in a static block then the Hotspot will merge the variable and the initialization in a single statement and hence reduce the code.
2. What will happen if an exception is thrown from the finally block?
The program will exit if the exception is not catched in the finally block.
3. If I give you an assignment to design Shopping cart web application, how will you define the architecture of this application? You are free to choose any framework, tool or server?
Usually I will choose a MVC framework which will make me use other design patterns like Front Controller, Business Delegate, Service Locater, DAO, DTO, Loose Coupling etc. Struts 2 is very easy to configure and comes with other plugins like Tiles, Velocity and Validator etc. The architecture of Struts becomes the architecture of my application with various actions and corresponding JSP pages in place.
Why is it better to use hibernate than JDBC for database interaction in various Java applications?
Hibernate provides an OO view of the database by mapping the various classes to the database tables. This helps in thinking in terms of the OO language then in RDBMS terms and hence increases productivity.
What is the purpose of intern () method in the String class?
It helps in moving the normal string objects to move to the String literal pool
How will you make your web application to use the https protocol?
1. Download JSSE 1.0.2 (or later) from http://java.sun.com/products/jsse/ and either make it an installed extension on the system, or else set an environment variable JSSE_HOME that points at the directory into which you installed JSSE.
2. Create a certificate keystore by executing the following command:
%JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA
3.Uncomment the "SSL HTTP/1.1 Connector" entry in $CATALINA_HOME/conf/server.xml and tweak as necessary.