Java J2EE Interview Questions
Questions Answers Views Company eMail

10. class Nav{ 11. public enum Direction { NORTH, SOUTH, EAST, WEST } 12. } 13. public class Sprite{ 14. // insert code here 15. } Which code, inserted at line 14, allows the Sprite class to compile? a)Direction d = NORTH; b)Nav.Direction d = NORTH; c)Direction d = Direction.NORTH; d)Nav.Direction d = Nav.Direction.NORTH;

2 16070

33. try { 34. // some code here 35. } catch (NullPointerException e1) { 36. System.out.print(”a”); 37. } catch (RuntimeException e2) { 38. System.out.print(”b”); 39. } finally { 40. System.out.print(”c”); 41. } What is the result if a NullPointerException occurs on line 34? 1 c 2 a 3 ab 4 ac

5 14583

Given: 10. interface A { void x(); } 11. class B implements A { public void x() { } public voidy() { } } 12. class C extends B { public void x() {} } And: 20. java.util.List list = new java.util.ArrayList(); 21. list.add(new B()); 22. list.add(new C()); 23. for (A a:list) { 24. a.x(); 25. a.y();; 26. } What is the result? 1 Compilation fails because of an error in line 25. 2 The code runs with no output. 3 An exception is thrown at runtime. 4 Compilation fails because of an error in line 20.

3 21100

11. static class A { 12. void process() throws Exception { throw new Exception(); } 13. } 14. static class B extends A { 15. void process() { System.out.println(”B”); } 16. } 17. public static void main(String[] args) { 18. new B().process(); 19. } What is the result? 1 B 2 The code runs with no output. 3 Compilation fails because of an error in line 12. 4 Compilation fails because of an error in line 15.

6 17346

84. try { 85. ResourceConnection con = resourceFactory.getConnection(); 86. Results r = con.query(”GET INFO FROM CUSTOMER”); 87. info = r.getData(); 88. con.close(); 89. } catch (ResourceException re) { 90. errorLog.write(re.getMessage()); 91. } 92. return info; Which is true if a ResourceException is thrown on line 86? 1 Line 92 will not execute. 2 The connection will not be retrieved in line 85. 3 The resource connection will not be closed on line 88. 4 The enclosing method will throw an exception to its caller.

1 10324

Given: 1. package test; 2. 3. class Target { 4. public String name = “hello”; 5. } What can directly access and change the value of the variable name? 1 any class 2 only the Target class 3 any class in the test package 4 any class that extends Target

Infosys, WW,

7 18954

Given: 11. public static void main(String[] args) { 12. Integer i = uew Integer(1) + new Integer(2); 13. switch(i) { 14. case 3: System.out.println(”three”); break; 15. default: System.out.println(”other”); break; 16. } 17. } ‘What is the result? 1 three 2 other 3 An exception is thrown at runtime. 4 Compilation fails because of an error on line 12.

9 15722

which is advanced deep technology in java launched by the sun microsystem??? The answer is very logical If u need correct answer mail me at priya_gupta@gmail.com

IBM,

3161

I need some details about an employee. i have only the employee id in my presentation layer(JSP).I entered that ID and click "Show Details" Button. Question is how the JSP pass that id to Controller layer and DAO and what mechanism we are using to retrive data from DB and how the data passed to JSP as a Output. Please explain in detail.

TCS,

1 4537

My application URL : http://localhost:8080/Application/Login.jsp. When a user enter this url in IE then, how it get Login.JSP Page exactly? what are the processes will happen from when we submit the URL to get Login.jsp?

IBM, TCS,

3 42247

What is Three tier architecture. Can anyone explain with a Ordinary web application Project? (JSP,Servlets,JAVA,DAO) ?

TCS,

3 10869

We can write any Java Logics in our JSP. Then why we are using servlets(Controller Layer) to interact with the DAO ?

TCS,

6 9384

Hi frnds iam new to struts wen iam running helloworld application using struts iam getting the error as belwo kindly any one can solve it plzz .....thanks in advance......... Nov 18, 2009 9:27:46 PM org.apache.tomcat.util.digester.SetPropertiesRule begin WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:StrutsExample1' did not find a matching property. Nov 18, 2009 9:27:46 PM org.apache.tomcat.util.digester.SetPropertiesRule begin WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Struts1' did not find a matching property. Nov 18, 2009 9:27:46 PM org.apache.catalina.core.AprLifecycleListener init INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre6\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\sys tem32;C:\WINDOWS;C:/Program Files/Java/jre6/bin/client;C:/Program Files/Java/jre6/bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOW S\System32\Wbem;C:\Program Files\Java\jdk1.5.0_18\bin; Nov 18, 2009 9:27:46 PM org.apache.coyote.http11.Http11Protocol init INFO: Initializing Coyote HTTP/1.1 on http-8081 Nov 18, 2009 9:27:46 PM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 678 ms Nov 18, 2009 9:27:46 PM org.apache.catalina.core.StandardService start INFO: Starting service Catalina Nov 18, 2009 9:27:46 PM org.apache.catalina.core.StandardEngine start INFO: Starting Servlet Engine: Apache Tomcat/6.0.20 Nov 18, 2009 9:27:46 PM org.apache.catalina.core.ApplicationContext log INFO: Marking servlet action as unavailable Nov 18, 2009 9:27:46 PM org.apache.catalina.core.ApplicationContext log SEVERE: Error loading WebappClassLoader delegate: false repositories: /WEB-INF/classes/ ----------> Parent Classloader: org.apache.catalina.loader.StandardClassLoader@ca2dce org.apache.struts.action.ActionServlet java.lang.ClassNotFoundException: org.apache.struts.action.ActionServlet at org.apache.catalina.loader.WebappClassLoader.loadClass(Webap pClassLoader.java:1387) at org.apache.catalina.loader.WebappClassLoader.loadClass(Webap pClassLoader.java:1233) at org.apache.catalina.core.StandardWrapper.loadServlet(Standar dWrapper.java:1095) at org.apache.catalina.core.StandardWrapper.load(StandardWrappe r.java:993) at org.apache.catalina.core.StandardContext.loadOnStartup(Stand ardContext.java:4149) at org.apache.catalina.core.StandardContext.start(StandardConte xt.java:4458) at org.apache.catalina.core.ContainerBase.start(ContainerBase.j ava:1045) at org.apache.catalina.core.StandardHost.start(StandardHost.jav a:722) at org.apache.catalina.core.ContainerBase.start(ContainerBase.j ava:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine .java:443) at org.apache.catalina.core.StandardService.start(StandardServi ce.java:516) at org.apache.catalina.core.StandardServer.start(StandardServer .java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:583 ) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:2 88) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:41 3) Nov 18, 2009 9:27:46 PM org.apache.catalina.core.StandardContext loadOnStartup SEVERE: Servlet /Struts1 threw load() exception java.lang.ClassNotFoundException: org.apache.struts.action.ActionServlet at org.apache.catalina.loader.WebappClassLoader.loadClass(Webap pClassLoader.java:1387) at org.apache.catalina.loader.WebappClassLoader.loadClass(Webap pClassLoader.java:1233) at org.apache.catalina.core.StandardWrapper.loadServlet(Standar dWrapper.java:1095) at org.apache.catalina.core.StandardWrapper.load(StandardWrappe r.java:993) at org.apache.catalina.core.StandardContext.loadOnStartup(Stand ardContext.java:4149) at org.apache.catalina.core.StandardContext.start(StandardConte xt.java:4458) at org.apache.catalina.core.ContainerBase.start(ContainerBase.j ava:1045) at org.apache.catalina.core.StandardHost.start(StandardHost.jav a:722) at org.apache.catalina.core.ContainerBase.start(ContainerBase.j ava:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine .java:443) at org.apache.catalina.core.StandardService.start(StandardServi ce.java:516) at org.apache.catalina.core.StandardServer.start(StandardServer .java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:583 ) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:2 88) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:41 3) Nov 18, 2009 9:27:46 PM org.apache.coyote.http11.Http11Protocol start INFO: Starting Coyote HTTP/1.1 on http-8081 Nov 18, 2009 9:27:46 PM org.apache.jk.common.ChannelSocket init INFO: JK: ajp13 listening on /0.0.0.0:8009 Nov 18, 2009 9:27:46 PM org.apache.jk.server.JkMain start INFO: Jk running ID=0 time=0/31 config=null Nov 18, 2009 9:27:46 PM org.apache.catalina.startup.Catalina start INFO: Server startup in 616 ms

2 5888

kindly can any one post for me portlet,hibernate,spring example code and configuration,and some related tutorials plz its urgent for me....thanks in advance ............

1 4278

Hi frnd can i any one kindly can post for me portlet,hibernate and spring example application and with flow explantion configuration using Jdeveloper.and related links ar tutorials kindly please send me .its urgent for me .thanks in advance...........else can any one send to kondaiah.goddeti@gmail.com

1721


Un-Answered Questions { Java J2EE }

List the common jdbc exceptions ?

547


How does hibernate lazy loading work?

163


Explain the difference between call by refrence and call by value?

531


Difference between this() and super() in java ?

593


Why swings are used in java?

503






What does the append?

476


Why jstlenvironmentsetup.jspf is included in jsp?

457


What is jdbc odbc connection?

488


How does lazy loading work in hibernate?

149


What are the important features of Java 8 release?

557


What languages are pass by reference?

515


How many JVMs can run on a single machine and what is the meaning of Just-In-Time (JIT) compiler?

728


Explain about object oriented programming and its features?

569


Name some of the important interfaces of hibernate framework?

146


Which is better hibernate or jpa?

117