Interview Questions and Answers - Order By Newest Q41. Is JVM a overhead ?
Ans. Yes and No. JVM is an extra layer that translates Byte Code into Machine Code. So Comparing to languages like C, Java provides an additional layer of translating the Source Code. C++ Compiler - Source Code --> Machine Code Java Compiler - Source Code --> Byte Code , JVM - Byte Code --> Machine Code Though it looks like an overhead but this additional translation allows Java to run Apps on all platforms as JVM provides the translation to the Machine code as per the underlying Operating System. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   jvm   interpreter   platform independent   yes-no   advanced   architecture Q42. What is Byte Code ? Why Java's intermediary Code is called Byte Code ?
Ans. Bytecode is a highly optimized set of instructions designed to be executed by the Java run-time system. Its called Byte Code because each instruction is of 1-2 bytes. Sample instructions in Byte Code - 1: istore_1 2: iload_1 3: sipush 1000 6: if_icmpge 44 9: iconst_2 10: istore_2 Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   jvm   interpreter   platform independent   byte code Q43. Which of the following code is correct ? a. DateFormat df = DateFormat.getInstance(); b. DateFormat df = DateFormat.getDateInstance(); c. DateFormat df = DateFormat.getInstance(DateFormat.FULL); d. DateFormat df = DateFormat.getDateInstance(DateFormat.FULL); Core Java
Ans. All except c are correct. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   date   dateformat Q44. What is the use of parse method in DateFormat ?
Ans. It is used to parse String to get the Date Object with initialized date. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   date   dateformat Q45. Which of the following is not a valid NumberFormat initialization ? a. NumberFormat.getInstance() b. NumberFormat.getDateInstance() c. NumberFormat.getCurrencyInstance() d. NumberFormat.getNumberInstance() Core Java
Ans. b i.e NumberFormat.getDateInstance() Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   java.util.numberformat Q46. Which of the following code is correct ? a. Date date = DateFormat.newInstance(DateFormat.LONG, Locale.US).parse(str); b. Date date = DateFormat.newInstance(DateFormat.LONG, Locale.US).format(str); c. Date date = DateFormat.getDateInstance(DateFormat.LONG, Locale.US).parse(str); Core Java
Ans. c Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   java.util   date   dateformat Q47. What are the the methods to clear cache in Hibernate ? Hibernate
Ans. Evict() and clear(). Evist is used to clear a particular object from the cache whereas clear clears the complete local cache. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  hibernate   orm   hibernate cache Q48. What are different types of second level cache ? Hibernate
Ans. 1. EHCache ( Easy Hibernate )
2. OSCache ( Open Symphony )
3. Swarm Cache ( JBoss )
4. Tree Cache ( JBoss ) Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  hibernate   orm   hibernate cache   technical lead Asked in 7 Companies Q49. Can we disable first level cache ? What should one do if we don't want an object to be cached ? Hibernate
Ans. No.We can either call evict after the object retrieval or can use separate sessions. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  hibernate   orm   hibernate cache   architectureAns. Hibernate is a Java ORM Framework. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  hibernate   orm   frameworks   architecture Q51. What are the different types of inheritance in Hibernate ? Hibernate
Ans. Table Per Class , Table per Sub Class , Table per Concrete Class Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  hibernate   orm   inheritance hibernate Asked in 1 Companies Basic   frequent Q52. Which class elements are not persisted ? Hibernate
Ans. Static and Transient. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  hibernate   orm Q53. What will the following code do ? String dateStr = "2011 11 19"; DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date date = dateFormat.parse(dateStr); System.out.println(date);
Ans. It will throw the ParseException as the date format doesn't abide with the format of the specified date. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  date   utility classes   dateformat   exception   parseexception Q54. What is the difference between JPA and Hibernate ? Hibernate
Ans. JPA or Java Persistence API is a standard specification for ORM implementations whereas Hibernate is the actual ORM implementation or framework. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  jpa   hibernate   orm   architecture   technologies Asked in 2 Companies Q55. What is the advantage of JPA ? Database
Ans. Its a specification that guides the implementation of ORM frameworks. Implementations abiding by the specification would mean that one can be replaced with other in an application without much hassle. Only the Features that are added over the specification needs to be taken care of if any such change is made. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  jpa   hibernate   orm   technologies Q56. Which is the default Input Formats defined in Hadoop ? a. SequenceFileInputFormat b. ByteInputFormat c. KeyValueInputFormat d. TextInputFormat
Ans. TextInputFormat Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  hadoop   hadoop input format Q57. Which of the following is not an input format in Hadoop ? a. TextInputFormat b. ByteInputFormat c. SequenceFileInputFormat d. KeyValueInputFormat
Ans. ByteInputFormat Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  hadoop   hadoop input formatFrequently asked in face to face interviews. Q58. Write a program to print fibonacci series. Core Java
Ans. int count = 15;
int[] fibonacci = new int[count];
fibonacci[0] = 0;
fibonacci[1] = 1;
for(int x=2; x < count; x++){
fibonacci[x] = fibonacci[x-1] + fibonacci[x-2];
}
for(int x=0; x< count; x++){
System.out.print(fibonacci[x] + " ");
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  ebay   fibonacci series Asked in 66 Companies basic   frequent Q59. What is the difference between following time formats ?
hh:mm:ss
HH:mm:ss
kk:mm:ss
KK:mm:ss Core Java
Ans. hh= hours in 1-12 format
HH= hours in 0-23 format
kk = Hours in 1-24 format
KK= hours in 0-11 format Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Date  Date Time Format  Date TimeFrequently asked to Fresh graduates. Q60. Write a program to implement Binary search ? Core Java
Ans. http://algs4.cs.princeton.edu/11model/BinarySearch.java.html Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  binary search  search Asked in 5 Companies basic   frequent Try 1 Question(s) Test Q61. What is a Database Procedure ? Database
Ans. Stored procedures are a batch of SQL statements along with programming constructs ( if else, loops etc ) and stored as a single program that can be called by different clients and hence reused.
Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  database  stored procedure Asked in 2 Companies basic   frequent Q62. What are some alternates to keeping Audit Tables ? Database
Ans. Audit Tables generally stores Raw information to be reviewed in case of problems or determining impact. If Database space is an issue , and the audit information is rarely retrieved, one design could be to use compressed file system. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  databases   audit tables   raw transaction information storage Asked in 1 Companies Q63. What is Java NumberFormatException ? Core Java
Ans. NumberFormatException is the exception that Java throws when we try to convert one data type to the Number data type but the value is not parsable to be a Number.
For example , the following code will result in the NumberFormatException
String string = "Buggy";
int strtoInt = Integer.parseInt(string); Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  exceptions  NumberFormatExceptionFrequently asked in Accenture. Q64. What is your biggest achievement at work ? General
Ans. [Open Ended Answer] Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  general question  non technical question Asked in 20 Companies   frequent Q65. What is the difference between ServletConfig and ServletContext ? Java EE
Ans. http://www.java4s.com/java-servlet-tutorials/difference-between-servletconfig-and-servletcontext-in-java/ Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  ServletConfig  ServletContext Asked in 1 Companies Q66. Is there any relationship between Web.xml and Spring.xml ? Spring
Ans. No, there is no relationship between web.xml and spring.xml but you have to configure spring.xml in web.xml in order initialize beans when application starts up Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  spring  web.xml  spring.xml  deployment descriptor Asked in 1 Companies Q67. What are the methods to connect to database in Java ? Database
Ans. JDBC ( Java Database Connectivity ),ODBC (Open Database Connectivity), Hibernate, JPA ( Java Persistence API ), JOOQ,MyBatis Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  database connection  jdbc  ORM  Hibernate Asked in 1 Companies Q68. What are the core OOPs concepts ? Core Java
Ans. Abstraction, Encapsulation, Polymorphism , Composition and Inheritance Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  core oops concepts Asked in 65 Companies basic   frequent This question was recently asked at 'Acute Informatics,General Atomics'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 2 Companies Q70. What is meant Java is "Write Once Run Anywhere" ? Core Java
Ans. It means that Java is compiled to byte code that is platform independent and hence can be run anywhere or any machine. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Write Once Run Anywhere  byte code  platform independent