Core Java Interview Questions
Questions Answers Views Company eMail

IS method overriding is Duplication of Methods?

CybAge,

5 8702

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 16124

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 14646

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 21211

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 17435

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 10372

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 19017

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 15798

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,

3174

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 4553

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 42347

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

TCS,

3 10903

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

TCS,

6 9426

Accenture NJ mostly ask question on Collection like 1)How to sort Objcts and how treeset sort them 2)Explain mechanism of Hashcode finding in Java 3)Name some of the Sorted collection.

Accenture,

2 7227

could you run the java program without main method?

6 13883


Post New Core Java Questions

Un-Answered Questions { Core Java }

What’s the difference between unit, integration and functional testing?

606


What are default methods ?

568


what is instanceof operator used in java?

577


Can we override compareto method?

483


Explain the importance of finally block in java?

558






Why string objects are immutable in java?

554


Why does java have two ways to create child threads? Which way is better?

519


How many threads can I run java?

530


What is the size of string?

545


How big is a 32 bit integer?

514


Give us the name of the list layoutmanagers in java?

511


Explain the usage of this with constructors?

515


What is object-oriented paradigm?

602


Difference between object instantiation and construction ?

564


Can we override singleton class?

526