Java - Interview Questions and Answers for 'Abs' | Search Java Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com
Share

Search Java Interview Questions


 2098 questions in repository.
 There are more than 200 unanswered questions.
Click here and help us by providing the answer.
Label / Company      Label / Company / Text

   



Interview Questions and Answers for 'Abs' - 273 question(s) found - Order By Newest

next 100
Very Very frequently asked. Among the first few questions in almost all interviews.Among Top 5 frequently asked questions.
  Q1. Difference between == and .equals() ?Core Java
Anonymous
Ans. "equals" is the method of object class which is supposed to be overridden to check object equality, whereas "==" operator evaluate to see if the object handlers on the left and right are pointing to the same object in memory.

x.equals(y) means the references x and y are holding objects that are equal. x==y means that the references x and y have same object.

Sample code:

String x = new String("str");
String y = new String("str");

System.out.println(x == y); // prints false
System.out.println(x.equals(y)); // prints true

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   string comparison   string   object class   ==    equals   object equality     Ebay  Cerner  GuideWire  Expeditors Associate  Revature  SAIC  ValueLabs  Realty Redefined  Bank Of America  Capgemini  HCL Technologies  Goldman Sachs  Symmetric Corp  Backstop Solutions  Frontier  IQOR   Science  Vanguard  eClinicalWorks  Experticity  Blue Cross and Blue Shield of Kansas  ComTrade  Banja Luka  Overstock.com  Intrasoft International  IBM  Apex Systems  infoview technologies      basic        frequent

Try 6 Question(s) Test


Advanced level question. Frequently asked in High end product companies. Frequently asked in Cognizant ( Based on 2 feedbacks )
  Q2. Why is String immutable in Java ?Core Java
Anonymous
Ans. 1. String Pool - When a string is created and if it exists in the pool, the reference of the existing string will be returned instead of creating a new object. If string is not immutable, changing the string with one reference will lead to the wrong value for the other references.

Example -

String str1 = "String1";
String str2 = "String1"; // It doesn't create a new String and rather reuses the string literal from pool

// Now both str1 and str2 pointing to same string object in pool, changing str1 will change it for str2 too

2. To Cache its Hashcode - If string is not immutable, One can change its hashcode and hence it's not fit to be cached.

3. Security - String is widely used as parameter for many java classes, e.g. network connection, opening files, etc. Making it mutable might possess threats due to interception by the other code segment.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   string   string class   immutable   advanced     Barclays  Jungo  Cloudera  Allston  Man Group  Prokarma  Optimus  Gamesys  ABS  TransPerfect  Fidelity  Deloitte  Zalando  Cognizant (CTS)  Zeta Interactive  SuccessFactors   EchoStar  InterGlobe Technologies  HCL Technologies  Intuit  JP Morgan  Optimus Information  Faichi Solutions  Blip  Adobe  Subex Limited  Remo Software  Allstate  IBM  Bizmatics  Bytecode Cyber Security  Calsoft Systems  IDS Infotech      expert        frequent

Try 4 Question(s) Test


Very frequently asked in different variations. Frequently asked in Deloitte ( 2 feedback ) , HCL Tech ( 3 feedback ) and Coginizant (CTS)
  Q3. Explain the scenerios to choose between String , StringBuilder and StringBuffer ?

or

What is the difference between String , StringBuilder and StringBuffer ?
Core Java
Anonymous
Ans. If the Object value will not change, use String Class because a String object is immutable.

If the Object value can change and will only be modified from a single thread, use StringBuilder because StringBuilder is unsynchronized(means faster).

If the Object value may change, and can be modified by multiple threads, use a StringBuffer because StringBuffer is thread safe(synchronized).

  Sample Code for String

  Sample Code for StringBuffer

  Sample Code for StringBuilder

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   string class   string   stringbuilder   stringbuffer     Cognizant (CTS)   San Jose State University (SJSU)  HCL Technologies   Deloitte  Sophos  Hitachi  JPMorgan Chase  IBM  Kony Labs  Keystone  ebay      basic        frequent

Try 3 Question(s) Test


Frequently asked in Infosys and HCL Technologies ( Based on 2 feedback )
 Q4. What are different ways of object creation in Java ?Core Java
Admin
info@buggybread.com
Ans. Using new operator - new xyzClass()

Using factory methods - xyzFactory.getInstance( )

Using newInstance( ) method - (Class.forName(xyzClass))emp.newInstance( )

By cloning an already available object - (xyzClass)obj1.clone( )

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   object creation   new operator   class.forname   cloning   ebay     Intelligrape  Infosys  Polaris  British Telecom (BT)  Vyom Labs  Deutsche Bank  HCL Technologies      expert


 Q5. What do you mean by "Java is a statically typed language" ?Core Java
Admin
info@buggybread.com
Ans. It means that the type of variables are checked at compile time in Java.The main advantage here is that all kinds of checking can be done by the compiler and hence will reduce bugs.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   statically typed language   variable declaration      basic        frequent


Very frequently asked to Fresh graduates.
  Q6. What is the difference between Encapsulation and Abstraction?Core Java
Anonymous
Ans. 1.Abstraction solves the problem at design level while encapsulation solves the problem at implementation level

2.Abstraction is used for hiding the unwanted data and giving relevant data. while Encapsulation means hiding the code and data into a single unit to protect the data from outside world.

3. Abstraction lets you focus on what the object does instead of how it does it while Encapsulation means hiding the internal details or mechanics of how an object does something.

4.For example: Outer Look of a Television, like it has a display screen and channel buttons to change channel it explains Abstraction but Inner Implementation detail of a Television how CRT and Display Screen are connect with each other using different circuits , it explains Encapsulation.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   oops concepts   encapsulation   abstraction   basic interview question     Synechron  Amazon  HCL Technologies  Tata Consultancy (TCS)  Wipro  Infosys Technologies  3DPLM Software Solutions      basic        frequent

Try 2 Question(s) Test


Very frequently asked. Favorite question in Walk in Drive of many Indian service companies. Frequently asked in HCL Technologies.
  Q7. What is the difference between final, finally and finalize() ?Core Java
Admin
info@buggybread.com
Ans. final - constant variable, objects cannot be de-referenced, restricting method overriding, restricting class sub classing.

finally - handles exception. The finally block is optional and provides a mechanism to clean up regardless of what happens within the try block. Use the finally block to close files or to release other system resources like database connections, statements etc.

finalize() - method helps in garbage collection. A method that is invoked before an object is discarded by the garbage collector, allowing it to clean up its state.

  Sample Code for final

  Sample Code for finally

  Sample Code for finalize

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   final   finally   finalize     Thomson Reuters  WITS  Antra  Jive  MorningStar  VanGuard   Alcatel Lucent  Morningstar  A9.com  EPAM  Nuance  SirsiDynix  NCR  VanGuard  Proofpoint Interview  Disney  Orbitz Worldwide  GFI Informatique  Canon  WITS  Simba Technologies  Marlabs  American Well  Global Relay  L&T Infotech  HCL Technologies  Tata Consultancy (TCS)  Wipro  Infosys  Accenture  Jive  Salesforce  Deegit  NTT DATA  Proofpoint  Morningstar  Bank Of America  Manhattan Associates  Optum  NorthPoint  Nok Nok Labs  Simba Technologies   Rhino Africa  Solutionreach  V Soft Consulting  EBay  Cognizant (CTS)  IBM  ExactTargetKewill  CV Holdings  Symphony  Cubic Web solutions  Star International  FatWire  Mindteck      basic        frequent

Try 4 Question(s) Test


Very frequently asked across all types of companies.
  Q8. Difference between HashMap and Hashtable?Core Java
Anonymous
Ans. Hashtable is synchronized whereas HashMap is not.HashMap allows null values whereas Hashtable doesnt allow null values.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   collections   hashmap   map   hashtable   basic interview question   ebay   tcs    hcl technologies   infosys technologies     Morgan Stanley  Yahoo  Q3 Technologies  PriceLine  Solution Rally  Coupang  HCL Technologies  Tata Consultancy (TCS)   Infosys Technologies  Accenture India  JPMorgan Chase  Priceline.com      basic        frequent

Try 2 Question(s) Test


 Q9. Why Char array is preferred over String for storing password?Core Java
Admin
info@buggybread.com
Ans. String is immutable in java and stored in String pool. Once it's created it stays in the pool until unless garbage collected, so even though we are done with password it's available in memory for longer duration and there is no way to avoid it. It's a security risk because anyone having access to memory dump can find the password as clear text.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   string class   string   immutable   string pool   garbage collection   advanced     General Motors  Amura Marketing Technologies  Bloomberg  Innovive      Expert



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



Frequently asked to experienced developers. Recently asked in many US interviews.
 Q10. What is database deadlock ? How can we avoid them?Database
Admin
info@buggybread.com
Ans. When multiple external resources are trying to access the DB locks and runs into cyclic wait, it may makes the DB unresponsive.

Deadlock can be avoided using variety of measures, Few listed below -

Can make a queue wherein we can verify and order the request to DB.

Less use of cursors as they lock the tables for long time.

Keeping the transaction smaller.



 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   database   architecture     MSCI  Vudu  Bank Of America  Sears      expert        frequent


Very frequently asked. Favorite question in Walk in Drive of many Indian service companies.
  Q11. What is the difference between ArrayList and LinkedList ?Core Java
admin
info@buggybread.com
Ans. Underlying data structure for ArrayList is Array whereas LinkedList is the linked list and hence have following differences -

1. ArrayList needs continuous memory locations and hence need to be moved to a bigger space if new elements are to be added to a filled array which is not required for LinkedList.

2. Removal and Insertion at specific place in ArrayList requires moving all elements and hence leads to O(n) insertions and removal whereas its constant O(1) for LinkedList.

3. Random access using index in ArrayList is faster than LinkedList which requires traversing the complete list through references.

4. Though Linear Search takes Similar Time for both, Binary Search using LinkedList requires creating new Model called Binary Search Tree which is slower but offers constant time insertion and deletion.

5. For a set of integers you want to sort using quicksort, it's probably faster to use an array; for a set of large structures you want to sort using selection sort, a linked list will be faster.

  Sample Code for ArrayList

  Sample Code for LinkedList

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     collections   java   data structures   arraylist   linkedlist     Deutsche Bank  Overstock.com  HCL Technologies  Infosys  EBay  The Advisory Board Company  Accuity  JC Penney  Cerner  Chase  Amazon  Deloitte  Deegit  Tata Consultancy  Cognizant (CTS)  IBM  Accenture  Mindtree  ESRI  QwikCilver Solutions  TMC Bonds  GumGum  EMC  Yelp  Classteacher Learning System  FactSet  Simply Hired  SalesForce  Royall & Company  Indeed  eClinicalWorks  TravelClick  State Farm  Manhattan Associates  GoEuro  Veeva Systems  Ness Technologies  Marlabs  Rolta  Volante Technologies  Happiest Minds Technologies  Coviam  Velocify  zanox  SimplyHired  IDBI Intech  Wissen Infotech  Nike  OnDot  PexSupply  Pramati Technologies  Credit Agricole  Mastek  Six Dee Telecom  Accuity  Kellton Tech      Basic        frequent

Try 1 Question(s) Test


Frequently asked to fresh graduates and less experienced.
 Q12. Why do we write public static void main ? Can we use some other syntax too for main ?Core Java
Admin
info@buggybread.com
Ans.
1. public is the access modifier that makes the method accessible from anywhere, static is the keyword that makes it accessible even without creating any object and using class name only , void means it doesnt return anything , String args[] is the array of argument that this method receives.

2. If I use Main , it will compile correctly as Java will treat it as just another method but it wont be the method "main" which Java looks for when it looks to execute the class and hence will throw

Error: Main method not found in class , please define the main method as:
public static void main(String[] args)

3. Main is not a keyword but a special string that Java looks for while initiating the main thread.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   main method     Cognizant (CTS)  Computer Solutions & Software International (CSSI)  Telcoinabox      basic        frequent

Try 1 Question(s) Test


 Q13. What are the advantages and disadvantages of static variables and static methods ?Core Java
Admin
info@buggybread.com
Ans. Advantages

Can do meta object operations ( like validating something before creating objects , keep count of number of objects )

Can do operations which have nothing to do with objects but still you want them to be tied to Class.

Disadvantages

Commonly used to static variables sometime leads to problems due to access by different objects.

Are not tied to objects so doesn't reflect pure Object Oriented approach.

Needs to be synchronized so as to avoid update conflicts by mutiple objects and threads.

Some limitation in testing as not all frameworks have facility to mock them. Powermock has but Mockito doesnt

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   static   static variables   static methods


 Q14. Can you give a real world example of Encapsulation and Abstraction ?Core Java2016-05-29 13:47:31

Ans. Car Engine is an example of encapsulation and abstraction. You ignite the car using an interface called starter and least bothered about how the tire actually moves (This is abstraction). The engine encapsulates the complete process to itself only and doesn't allow you to start the other components like the radiator etc ( this is excapsulation )

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     encapsulation  abstraction  oops  oops features  java features     MAQ Software  Daffodil Software  Quickstart Global  Alliance Global Services  InfoStretch  Intelligrape  Prowareness  Support.com  Cognizant (CTS)  BNT SOFT  Clairvoyant TechnoSolutions  Suyati Technologies  3DPLM Software Solutions


 Q15. What is JDBC? Describe the steps needed to execute a SQL query using JDBC.Database
Anonymous
Ans. The JDBC is a pure Java API used to execute SQL statements. It provides a set of classes and interfaces that can be used by developers to write database applications.

The steps needed to execute a SQL query using JDBC:

1. Open a connection to the database.
2. Execute a SQL statement.
3. Process th results.
4. Close the connection to the database.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   jdbc   db connectivity     Nucleus Software Exports  Caprus IT      basic        frequent


Very Frequently asked to fresh graduates and less experienced. Favorite question in Walk in drives.
  Q16. Difference between Overloading and Overriding ?Core Java
Anonymous
Ans. Overloading - Similar Signature but different definition , like function overloading.

Overriding - Overriding the Definition of base class in the derived class.

  Sample Code for overloading

  Sample Code for overriding

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   overloading   overriding   oops concepts   basic interview question     PC Technology  Cognizant (CTS)  Donlen   hybris Software  RedMane  Allerin Technologies  Gemalto  Allerin Technologies  HCL Technologies  Tata Consultancy (TCS)  Accenture India  Infosys Technologies  Polaris  United Healthcare India  IBM India  Xchanging  American Express  Antra  Flipp  Computer Sciences Corporation (CSC)  Garmin  NetSuite  Donlen  Hudsons Bay  Techlogix  SevOne  Synactive  Oodles Technologies  FDM Group  Marlabs  RedMane Technology  Faichi Solutions  TD  Tech Mahindra  Shutterfly  Luxoft  PC Technology  CCC Information Services  State Farm  Raja Software  Mastek  EPAM  Morgan Stanley  SummitWorks  Sony  Citibank  Emtec  LowerMyBills  Consilience  Xavor  AllState  FasTrak  AmTrust Financial  Walt Disney  Ultramain Systems  International Turnkey Systems  Knoldus Software  CA Technologies  Amdocs  FDM Group  Hybris  Fidelity  United Health Group (UHG)  Bluewhale Solutions  Pegasystems  Revature   Innoplexus  Vanguard  AptSource  Perficient  Grapecity  Subex  QuintilesIMS  NimbleUser  Expeditors Associate  Sapient  HR Cloud  Summitworks  Jabong.com  Kony Labs  Price Waterhouse Coopers (PWC)      basic        frequent

Try 1 Question(s) Test


  Q17. Difference between Vector and ArrayList ?Core Java
Anonymous
Ans. Vectors are synchronized whereas Array lists are not.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   basic interview question   vector   arraylist   collections   synchronization     Oracle  Lab49  Infosys  Wipro  Zoho  HCL Technologies  Tata Consultancy (CTS)  BirlaSoft  Emory  Xplana  British Telecom (BT)  Apex Systems  Capgemini  Accenture  3dplm Software Solution  AppKnox  eIntern  Landmark Information Group  ESystems  Orbitz Worldwide  HARMAN  Starmount  iConsultus  KARYA Technologies  Smart Chip  Cuelogic Technologies  Kronos  Trigent Software  Deloitte  ACI Worldwide  Unisys  Tavant Technologies  Referance data      basic        frequent


Very frequently asked in phone and walk in interviews.
  Q18. What are Marker Interfaces ? Name few Java marker interfaces ?Core Java
Anonymous
Ans. These are the interfaces which have no declared methods.Serializable and cloneable are marker interfaces.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   interfaces   marker interface   serializable   clonable     Qualtech Consultants  Computer Sciences Corporation (CSC)  Addteq  Infosys  Synechron  Amdocs  JPMorgan Chase  Qualtech Consultants  Velopsys Technologies  Amdocs  Ericsson  Oracle  Avaya  Copart  Innoplexus  Volvo Information Technology      intermediate        frequent

Try 1 Question(s) Test


 Q19. What are the disadvantages of using arrays ?Core Java
Admin
info@buggybread.com
Ans. Arrays are of fixed size and have to reserve memory prior to use. Hence if we don't know size in advance arrays are not recommended to use.

Arrays can store only homogeneous elements.

Arrays store its values in contentious memory location. Not suitable if the content is too large and needs to be distributed in memory.

There is no underlying data structure for arrays and no ready made method support for arrays, for every requriment we need to code explicitly

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   arrays   disadvantages of arrays   arrays memory   arrays vs variables



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



Advanced level question usually asked to senior developers , leads and architects.
 Q20. How does volatile affect code optimization by compiler?Core Java
Admin
info@buggybread.com
Ans. Volatile is an instruction that the variables can be accessed by multiple threads and hence shouldn't be cached. As volatile variables are never cached and hence their retrieval cannot be optimized.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   java keywords   volatile   synchronization   compiler optimization   variable caching   architecture     Embedded security  Driver engineer  Sokrati      expert


 Q21. What things should be kept in mind while creating your own exceptions in Java?Core Java
Admin
info@buggybread.com
Ans. All exceptions must be a child of Throwable.

If you want to write a checked exception that is automatically enforced by the Handle or Declare Rule, you need to extend the Exception class.

You want to write a runtime exception, you need to extend the RuntimeException class.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   exceptions   exception handling   user defined exceptions   throwable   architecture   library development   technical architect   technical lead


 Q22. If you are given a choice to implement the code to either Insert a Record or Update if already exist, Which approach will you follow ?

1. Insert into the DB Table. If exception occurs, update the existing record.
2. Check if the record exists and update it if it exists, If not insert a new record.
Solution
admin
info@buggybread.com
Ans. In first case, there would be 2 DB calls in worst case and 1 in best case. In 2nd approach there will be always 2 DB calls.

Decision on the approach should depend on the following considerations -

1. How costly is the call to DB ? Are we using indices , hibernate etc

If calls to DB are costly , 1st approach should be the choice.

2. Exception Book keeping load upon exception.

The benefit of saving 1st call in approach 1 should be bigger than the Book keeping for the exception.

3. Probability of the exception in first apparoach.

If the DB Table is almost empty, it makes sense to follow Approach 1 as majority of the 1st calls will pass through without exception.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     database   insert-update   db exceution plan   db strategy   design   architecture   technical lead


Very Frequently asked. Have been asked in HCL Technologies very frequently ( based on 2 feedback ). Among first few questions in many interviews.
  Q23. Differences between abstract class and interface ?Core Java
Admin
info@buggybread.com
Ans. Abstract classes can have both abstract methods ( method declarations ) as well as concrete methods ( inherited to the derived classes ) whereas Interfaces can only have abstract methods ( method declarations ).

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   classes   abstract class   interfaces     GlobalLogic  HCL Technologies  Tata Consultancy (TCS)  Infosys  Wipro  Mindtree  CapitalOne  Accenture  IBM India  Infoview Technologies  Salesforce  AT&T  United Health Group (UHG)  Verilogue  Amazon  Expeditors  Syntel  SalesForce  Cornerstone OnDemand  Expedia  OLA  NSF International  Copper Mobile  Think Future Technologies  MorphoTrust  Global Healthcare  Prodigious  Internet Brands  SciQuest  arvato Systems  iCIMS  Ideas2IT  virtusa polaris  Vitech Systems  Cognizant (CTS)      basic        frequent


 Q24. Which of the following Java feature promotes Code Re usability ?

a. Abstraction
b. Encapsulation
c. Inheritance
d. Polymorphism
Core Java
Anonymous
Ans. Inheritance

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   java concepts   java features   code reusability


Almost sure to be asked in every company using any Dependency Injection framework ( Spring, Guice etc )
  Q25. What is Dependency Injection or IOC ( Inversion of Control ) ?Design

Ans. It is a Design Pattern that facilitates loose coupling by sending the dependency information ( object references of dependent object ) while building the state of the object. Objects are designed in a manner where they receive instances of the objects from other pieces of code, instead of constructing them internally and hence provide better flexibility.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     design patterns   ioc ( Inversion of Control )  dependency injection     Nucleus Software Exports  HCL Technologies  Tata Consultancy (TCS)  HCL  Infosys  Cognizant (CTS)  Barclays  General Electric  Infosys Technologies  Elsevier  Sabre  ZapCom  Nike  Sogeti  CSG International  Lowes  DWS  Mitsui Bussan Logistics  Payment Processing Partners  Liquidnet  AmTrust Financial  VectorForm  Cybage  Vanderbilt University  Cigniti  Accenture  Ball Aerospace  GE Healthcare  1-800 Contacts  VinSolutions  Arrow Electronics  Monitise  Avenue Code  Thetus Corporation  Shodogg  Levi9  BuildLinks  Suyati Technologies  Kanerika Software  Alliance Inspection Management  Promega  Victorious  Zoll Data Systems  Parkmobile  PerceptiMed  Crate and Barrel  Carbonite  Concur  Codazen  GlobalLogic  AccuSoft  Attinad  Tillster  AppRiver  TrustPilot  Pearson  Kony  Art Technology Group  VeriSign  Accion Labs  IGS Energy  National Bankruptcy Services  RealPage  Green Dot  Indecomm Global  bebo Technologies  Open Solutions  Xoriant  NCR  Macmillan Cancer Support  NetSuite  Asynchrony Labs  DealDash  Vizio  Fiserv  Federal Reserve Bank of Minneapolis  Tinder  FICO  Trustwave      intermediate        frequent


 Q26. Why HashTable has been deprecated ?Core Java2016-07-08 10:01:58

Ans. HashTable has been Deprecated as an alternative ConcurrentHashMap has been provided which uses multiple buckets to store data and hence much better performance than hashtable. Moreover there is already a raw type hashmap. The only difference between the HashTable and HashMap is that Hashtable is synchronized whereas HashMap is not. Most of the synchronized collections have been deprecated and their raw alternative have been presented as preferred.

Synchronization has a cost. Using synchronized collection at a place where there is hardly any need of it would means useless utilization of resources. As these collections are rarely used in static context or shared among threads, Java might have thought it better to just provide the raw collection and let developer implement synchronization if he feels the need to do so.

As HashMap has been presented as default and preferred way of using Map with read optimized hashing, and ConcurrentHashMap has been provided for synchronized access which provides better performance than HashTable, Java thought it right to deprecate the use of HashTable.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     hashtable  synchronized collections  Why synchronized collections have been deprecated  Why HashTable has been deprecated  HashTable vs HashMap      expert

Try 3 Question(s) Test


Frequently asked to fresh graduates.
 Q27. What is ACID ?Database2016-11-04 08:09:44

Ans. ACID stands for Atomicity, Consistency, Isolation, Durability is a set of properties of database transactions.

Atomicity means all or nothing. i.e parts of a transaction shouldn't commit if any one of them fails. Either the whole transaction should succeed or it should be complete rollback.

Consistency means that any transaction should lead database from one stabe state to another.

Isolation means that the execution of transaction results in a system state that would be obtained if transactions were executed serially.

Durability means that when a transaction is committed it forms the permanent state of database.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     database  acid     CapitalOne   Tata Consultancy (TCS)  SilverRail Technologies  A9.com  Oracle  Sirius Computer Solutions      Intermediate

Try 1 Question(s) Test


 Q28. What are different types of variables a class can have ?Core Java2017-01-07 16:58:43

Ans. 1. Method local variables - These are declared and defined within a method ( instance or static methods ) and their scope is limited to the method itself. They are destructed once the execution of method completes. They are stored in stack memory.

2. Instance variables - These are declared as non static variables as part of the class.They are initialized as part of object creation ( constructor ) and are destructed by java's garbage collection mechanism and hence stored in heap.

3. Static variables - These are declared with the static keyword and are part of the class. They are initialized at the time of class loading and are destructed by java's garbage collection mechanism and hence stored in heap.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java variables


  Q29. What are Inner , Outer , Left and Right Joins in SQL ?Database2017-01-09 13:07:55

Ans. Inner join is the intersection of two tables on the condition defined by the where clause i.e will get records from both tables matched by a column.

Outer join is the union of two tables i.e will get all records from both tables and will put null in the columns where related records are not present.

Left Outer join is the left union of two tables i.e all records from the table on the left and values from the right table for related records else null for the columns from right table.

Right Outer join is the right union of two tables i.e all records from the table on the right and values from the left table for related records else null for the columns from left table.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     sql  inner join  outer join  right join  left join     EPAM  Antra  MSCI  HCL Technologies  Cognizant (CTS)  Morgan Stanley  Wipro  Infosys  Accenture  IBM  PayPal  A9.com  Curriculum Associates  Gold Coast IT  Kobie Marketing  Hybris  Aptroid Technologies  E2open  IGATE  SnapDeal  Verilogue  Span Infotech      basic        frequent



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



Very Frequently asked across all type of companies and across all levels.
  Q30. Difference between Public, Private, Default and Protected ?Core Java
Anonymous
Ans. Private - Not accessible outside object scope.

Public - Accessible from anywhere.

Default - Accessible from anywhere within same package.

Protected - Accessible from object and the sub class objects.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oop   access specifier   public   private   default   protected   basic interview question     HCL Technologies  Tata Consultancy (TCS)  IBM  Wipro  Deegit  Argonne National Laboratory  Motorola Mobility  Accenture  Deegit  Cerner      basic        frequent

Try 1 Question(s) Test


Very frequently asked. Favorite question in Walk in Drive of many Indian service companies.
  Q31. What is a Final Variable ?Core Java
Anonymous
Ans. Final variable is a variable constant that cannot be changed after initialization.

  Sample Code for final variable

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     oops   java   final   final variable   basic interview question     IBM  Goldman Sachs  TrueCar  Intertek  RedMane  Antra  HCL Technologies  Tata Consultancy (TCS)  Accenture  Forte Group  Mastercard      basic        frequent

Try 1 Question(s) Test


 Q32. When are static variables loaded in memory ?Core Java
Anonymous
Ans. They are loaded at runtime when the respective Class is loaded.

  Sample Code for static variable

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   static   static variable   memory      intermediate


 Q33. Can we serialize static variables ?Core Java
Anonymous
Ans. No. Only Object and its members are serialized. Static variables are shared variables and doesn't correspond to a specific object.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     serialization   java   oops   static   static variables     Deloitte      intermediate        rare

Try 2 Question(s) Test


 Q34. Can we use null as a key for a map collection ?Core Java
Anonymous
Ans. Yes , for HashMap. HashMap implements Map interface. HashMap allows one null key and any number of null values.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   collections   hashmap   map   hashtable   yes-no     BlackBerry


 Q35. Difference between Abstract and Concrete Class ?Core Java
Anonymous
Ans. Abstract classes are only meant to be sub classed and not meant to be instantiated whereas concrete classes are meant to be instantiated.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   abstract classes   basic interview question     Goldman Sachs      basic        frequent


Frequently asked question for intermediate developers.
  Q36. What is Volatile keyword used for ?Core Java
Anonymous
Ans. Volatile is a declaration that a variable can be accessed by multiple threads and hence shouldnt be cached.

  Sample Code for volatile

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   synchronization   volatile   java keywords     ABC Ltd   Ciena  Xchanging  Square  Infoview Technologies  HCL Technologies  EPAM  GrubHub  TeleMessage  TRUSTe  Informatica  Square  Medidata Solutions  Yellow Pages  eQ Technologic  Sutra Analytics  CustomerXPs  Globant  BB Holdings  Rakuten  Booking.com  BlackRock  Qualcomm  LSI Corporation  ARM Holdings  SpaceX  Toshiba  Peapod  Amadeus  Apptio  Tivo  EchoStar  HomeAway  Syscom Technologies  Aversan  Symantec  Samsung India  Axtria  Qualcomm  CGI Group      intermediate        frequent

Try 1 Question(s) Test


Very frequently asked. Usually asked with questions related to String.
  Q37. What is an Immutable Object ?Core Java
Anonymous
Ans. Object that can't be changed after instantiation.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   immutable     LiveSocialize Technologies  Oracle  Bureau Veritas  AudioCodes  GCPL Technologies  Infogain  Goldman Sachs  JP Morgan  Incture Technologies  Novell  Amisoft Technologies  Xactly Corp  Amisoft Technologies  Sunrun  Cognizant (CTS)  Hortonworks  AdNovum  Aquent   V-Soft  Sears  Idexcel  Infusion  Knight Capital  Bally Technologies  Yatra Online  Multivision (Virginia)  Portware LLC      basic        frequent

Try 2 Question(s) Test


Very Frequently asked. Usually asked along with String Class related questions.
 Q38. What is an immutable class ?Core Java
Anonymous
Ans. Class using which only immutable (objects that cannot be changed after initialization) objects can be created.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   immutable   immutable class   string class   basic interview question   ebay     Cognizant (CTS)  Hybris  YuMe  ebizAutos      Basic        frequent

Try 2 Question(s) Test


 Q39. How to implement an immutable class ?Core Java
Anonymous
Ans. We can make a class immutable by

1. Making all methods and variables as private.

2. Setting variables within constructor.

Public Class ImmutableClass{

private int member;
ImmutableClass(int var){
member=var;
}
}

and then we can initialize the object of the class as

ImmutableClass immutableObject = new ImmutableClass(5);

Now all members being private , you cant change the state of the object.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   immutable   immutable class   technical lead     Deloitte  Pramati Technologies  JPMorgan Chase  Mastercard      intermediate        frequent

Try 2 Question(s) Test



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q40. Does Declaring an object "final" makes it immutable ?Core Java
Anonymous
Ans. Only declaring variables as final makes them immutable. Making objects final means that the object handler cannot be used to target some other object but the object is still mutable.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   final   immutable   immutable object


Frequently asked to fresh graduates.
  Q41. Difference between Process and Thread ?Operating System
Anonymous
Ans. Process is a program in execution whereas thread is a separate path of execution in a program.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   threads   multi threading   operating system   basic interview question     Walt Disney  Goldman Sachs  Nuance  Bank of America  Cogent Infotech  Sogeti  Siemens  Veritas  Vudu  One97 Communications  Riverbed Technology  TK20  MZ  Utopia  LogicMonitor  Lockheed Martin  Lab49  IGATE  Intel Corp  Verint Systems  Kronos  Amazon.com  Citrix  Persistent Systems      basic        frequent


 Q42. What is a Property class ?Core Java
Anonymous
Ans. The properties class is a subclass of Hashtable that can be read from or written to a stream.

  Sample Code for Load Properties using Property Class

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   collections   hashtable   map   synchronization   synchronized


 Q43. Difference between Factory and Abstract Factory Design Pattern ?Design
Anonymous
Ans. Factory Pattern deals with creation of objects delegated to a separate factory class whereas Abstract Factory patterns works around a super-factory which creates other factories.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   design pattern   factory design pattern   abstract factory design pattern   technical lead      expert


 Q44. Why do member variables have default values whereas local variables don't have any default value ?
Core Java
Anonymous
Ans. member variable are loaded into heap, so they are initialized with default values when an instance of a class is created. In case of local variables, they are stored in stack until they are being used.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   jvm   memory management   variables   stack memory   heap memory   default values      expert


 Q45. How can we create objects if we make the constructor private ?Core Java
Anonymous
Ans. We can do so through a static public member method or static block.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   static   constructor   static method   static block  private     Jabong.com


 Q46. What is an Externalizable interface ?
Anonymous
Ans. Externalizable interface is used to write the state of an object into a byte stream in compressed format.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   serialization   externalizable interface   interface     Egen Solutions  Xpanxion  MphasiS


 Q47. Difference between serializable and externalizable interface ?
Anonymous
Ans. Serializable is a marker interface whereas externalizable is not.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   serialization   externalizable   interface   marker interface


 Q48. What are the design considerations while making a choice between using interface and abstract class ?Core Java
Anonymous
Ans. Keep it as a Abstract Class if its a "Is a" Relationsship and should do subset/all of the functionality. Keep it as Interface if its a "Should Do" relationship.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   abstract classes   interfaces   advanced     ADP  AI corporation


 Q49. What is JAXP ?Xml
Admin
info@buggybread.com
Ans. Stands for Java API for XML Processing. This provides a common interface for creating and using SAX, DOM, and XSLT APIs in Java regardless of which vendor’s implementation is actually being used.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   java api   xml   xml processing   jaxp   abbreviation   technologies



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q50. What is JAXB ?Xml
Admin
info@buggybread.com
Ans. Stands for Java API for XML Binding. This standard defines a mechanism for writing out Java objects as XML and for creating Java objects from XML structures.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   xml   markup language   java api for xml binding   jaxb   abbreviation   technologies     Xchanging


 Q51. Can we add duplicate keys in a HashMap ? What will happen if we attempt to add duplicate values ?
Admin
info@buggybread.com
Ans. No, We cannot have duplicate keys in HashMap. If we attempt to do so , the previous value for the key is overwritten.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   collections   hashmap   map   hashtable

Try 1 Question(s) Test


 Q52. What things you would care about to improve the performance of Application if its identified that its DB communication that needs to be improved ?Solution
Admin
info@buggybread.com
Ans. 1. Query Optimization ( Query Rewriting , Prepared Statements )

2. Restructuring Indexes.

3. DB Caching Tuning ( if using ORM )

4. Identifying the problems ( if any ) with the ORM Strategy ( If using ORM )

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   db   database   hibernate   orm   at&t   overstock.com   performance improvement   architecture   technical lead   architect      intermediate


 Q53. How is Abstraction implemented in Java ?Core Java
Admin
info@buggybread.com
Ans. Abstraction is provided in Java by following ways -

Coding to the ( Interfaces / Abstract Classes ) or contracts

By Encapsulating details within classes and exposing the minimal Door ( few public methods )

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops concepts   abstraction   interfaces   abstract class   encapsulation     Accenture  Bureau Veritas      basic        frequent


 Q54. What is the use of @GeneratedValue annotation in Hibernate?Hibernate
Admin
info@buggybread.com
Ans. This annotation is added to the auto increment column with the strategy to increment the column value. Usually this is added to the surrogate primary key column and specified with the Database Sequence.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     hibernate   hibernate annotations   @generatedvalue   database sequence


 Q55. What is the use of runnable interface if we can always create a new thread using Thread class ?Core Java
Admin
info@buggybread.com
Ans. It's a choice to be made whether to use first approach ( Thread class ) or second approach ( runnable interface ) by the programmer. The second facility has been given for cases where your class is already extending some parent class and hence cannot extend another class ( for Thread ) as Java doesn't allow multiple inheritance.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   threads   multithreading   runnable interface  concurrency


 Q56. Why do we need Thread class even in case we execute thread using runnable interface ?Core Java
Admin
info@buggybread.com
Ans. Thread class holds the definition of start method ( This is the method that starts execution of new thread and then calls run method within the scope of new thread ). Interfaces don't hold any definition and so does runnable. So it makes it necessary the usage of Thread class , whatever implementation you choose.

When your class extends the thread class, it carries the definition of start method from parent Thread class onto itself and hence new yourClass.start() helps starting a new thread and then executing run method in that new thread scope.

When you implement runnable interface , you are just making it sure to the JVM that you have implemented the required method ( run() ) which the Thread start method will look for upon executing start method.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   threads   multithreading   runnable interface   thread class


 Q57. If an Abstract class has only abstract methods, What's the difference between such a class and an interface ?Core Java2017-05-07 07:26:29

Ans. Such a class still can have member elements which can be inherited and hence facilitate code reuse. Moreover Abstract class can have non final static elements whereas interfaces are only allowed to have static final elements.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     abstract class   interfaces     Tata Consultancy (TCS)      Basic


 Q58. How does making string as immutable helps with securing information ? How does String Pool pose a security threat ?Core Java2017-06-22 11:32:57

Ans. String is widely used as parameter for many java classes, e.g. network connection, opening files, etc. Making it mutable might possess threats due to interception by the other code segment or hacker over internet.

Once a String constant is created in Java , it stays in string constant pool until garbage collected and hence stays there much longer than what's needed. Any unauthorized access to string Pool pose a threat of exposing these values.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     Security  String pool   string immutable


 Q59. How is string object immutable if we can concat a string to it ?Core Java2017-08-08 09:50:28

Ans. Because it doesn't make the change in the existing string but would create a new string by concatenating the new string to previous string. So Original string won't get changed but a new string will be created. That is why when we say

str1.concat("Hello");

It means nothing because we haven't specified the reference to the new string and we have no way to access the new concatenated string. Accessing str1 with the above code will still give the original string.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     string  string immutable  string concat



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q60. Can static method access instance variables ?Core Java
Anonymous
Ans. Though Static methods cannot access the instance variables directly, They can access them using instance handler.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     static   static method   java   oop   variables     Infoview Technologies      basic        frequent


Very frequently asked. Usually asked in this format or as difference with interfaces / concrete classes.
  Q61. What is an abstract class ?Core Java2017-01-10 13:12:20

Ans. Abstract class is the class that is not supposed to be instantiated. The purpose of the class to only have extension to the derived class.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     abstract class     Multivision  Starkey Hearing Technologies  Avaya  Tridium  LinkedIn  Acute Informatics      basic        frequent


 Q62. Which interface does java.util.Hashtable implement?Core Java
Anonymous
Ans. Java.util.Map

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   collections   hashtable   map      basic        rare


 Q63. Is runnable a Marker interface ?Core Java
Anonymous
Ans. No , it has run method declared.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   interfaces   marker interface   runnable   yes-no


 Q64. Difference between Factory and Strategy Design Pattern ?Design
Anonymous
Ans. Factory is a creational design pattern whereas Strategy is behavioral design pattern. Factory revolves around the creation of object at runtime whereas Strategy or Policy revolves around the decision at runtime.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   design pattern   factory   strategy   creational design pattern   behavioral design pattern     Alibaba      expert


 Q65. What will happen if we make the constructor private ?Core Java
Anonymous
Ans. We can't create the objects directly by invoking new operator.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   constructor   access specifier   private     Jabong.com      basic

Try 2 Question(s) Test


 Q66. Can we declare an abstract method private ?
Anonymous
Ans. No Abstract methods can only be declared protected or public.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   abstract   oops   access specifier   private   yes-no      intermediate        rare


 Q67. Whats the purpose of marker interfaces ?
Admin
info@buggybread.com
Ans. They just tell the compiler that the objects of the classes implementing the interfaces with no defined methods need to be treated differently.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   interfaces   marker interfaces   clonable   serializable      basic        frequent


Frequently asked in CTS ( Based on 2 feedback )
  Q68. What is the difference between comparable and comparator in java.util pkg?Core Java
Admin
info@buggybread.com
Ans. Comparable interface is used for single sequence sorting i.e.sorting the objects based on single data member where as comparator interface is used to sort the object based on multiple data members.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   java.util   comparable   comparator   collections     Verilogue  Accenture  Varian Medical Systems  L&T Infotech  Oracle  eIntern  Happiest Minds Technologies  HCL Technologies  Cognizant (CTS)  Cerner  Coviam  EdgeVerve Systems  Virtusa Polaris  Trimax IT Infrastructure & Services      basic        frequent


 Q69. What is the advantage of using arrays over variables ?
Admin
info@buggybread.com
Ans. Arrays provide a structure wherein multiple values can be accessed using single reference and index. This helps in iterating over the values using loops.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   arrays   loops   variables   basic interview question



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q70. What is a cloneable interface and what all methods does it contain?Core Java
Admin
info@buggybread.com
Ans. Cloneable is a declaration that the class implementing it allows cloning or bitwise copy of it's object state. It is not having any method because it is a MARKER interface.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   cloneable   marker interface     ADP


 Q71. Are there any global variables in Java, which can be accessed by other part of your program?
Admin
info@buggybread.com
Ans. No. Global variables are not allowed as it wont fit good with the concept of encapsulation.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   variables   global variables   yes no


 Q72. What is connection pooling?Database
Admin
info@buggybread.com
Ans. It's a technique to allow multiple clients to make use of a cached set of shared and reusable connection objects providing access to a database or other resource.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   jdbc   db connectivity   connection pooling   architecture     Cognizant (CTS)  IGATE  eMeasurematics      basic        frequent


 Q73. Why is Java considered Portable Language ?Core Java
Admin
info@buggybread.com
Ans. Java is a portable-language because without any modification we can use Java byte-code in any platform(which supports Java). So this byte-code is portable and we can use in any other major platforms.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   bytecode   jvm   compiler   portable   features of java   basic interview question


 Q74. What data type Variable can be used in a switch statement ?Core Java
Admin
info@buggybread.com
Ans. Variables used in a switch statement can only be a byte, short, int, or char ( and String with Java 7 and above )

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   switch   variable   data type      basic        rare


  Q75. What is Comparable Interface?Core Java
Admin
info@buggybread.com
Ans. It is used to sort collections and arrays of objects using the collections.sort() and java.utils. The objects of the class implementing the Comparable interface can be ordered.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   collections   comparable interface     innoPath  Mobisoft Infotech  BNP Paribas  Nokia  Unicon  HERE Maps  Verilogue      intermediate        frequent

Try 1 Question(s) Test


 Q76. What environment variables do I need to set on my machine in order to be able to run Java programs?
Admin
info@buggybread.com
Ans. CLASSPATH and PATH are the two variables.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   classpath   path   environment variables   jvm


 Q77. What is Externalizable interface?Core Java
Admin
info@buggybread.com
Ans. Externalizable is an interface which contains two methods readExternal and writeExternal. These methods give you a control over the serialization mechanism.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   serialization   externalizable interface     MPhasis  Egen Solutions      intermediate        rare


 Q78. Difference between Abstraction and Implementation hiding ?
Anonymous
Ans. Implementation Hiding is a broader concept. Abstraction is a way of implementation hiding in OOP's.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   oops concepts   abstraction   hiding information   build management


 Q79. What are the examples of Abstraction in Java ?
Admin
info@buggybread.com
Ans. function calling - hides implementation details
wrapper classes
new operator - Creates object in memory, calls constructor

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   oops concepts   abstraction



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q80. Why String is popular HashMap key in Java?Core Java
Admin
info@buggybread.com
Ans. Since String is immutable, its hashcode is cached at the time of creation and it doesnt need to be calculated again. This makes it a great candidate for key in a Map and its processing is fast than other HashMap key objects. This is why String is mostly used Object as HashMap keys.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   string class   string   immutable   hashmap   immutable   hashcode   hash code   advanced     TD Bank  HCL Technologies      expert        frequent


 Q81. Will the static block be executed in the following code ? Why ?

class Test
{
static
{
System.out.println("Why I am not executing ");
}
public static final int param=20;
}

public class Demo
{
public static void main(String[] args)
{
System.out.println(Test.param);
}
}
Admin
info@buggybread.com
Ans. No the static block won't get executed as the referenced variable in the Test class is final. Compiler replaces the content of the final variable within Demo.main method and hence actually no reference to Test class is made.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   static   static block   final variable

Try 1 Question(s) Test


 Q82. Will static block for Test Class execute in the following code ?

class Test
{
static
{
System.out.println("Executing Static Block.");
}
public final int param=20;

public int getParam(){
return param;
}
}

public class Demo
{
public static void main(String[] args)
{
System.out.println(new Test().param);
}
}
Admin
info@buggybread.com
Ans. Yes.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   static   static block   final variable   yes no

Try 1 Question(s) Test


  Q83. Write a Program to check if 2 strings are Anagrams ?Core Java2016-11-30 20:52:37

Ans. public void checkIfAnagram(String str1,String str2){
boolean anagram = true;
for(char c:str1.toCharArray()){
if(!str2.contains(String.valueOf(c))){
System.out.println("Strings are Anagrams");
anagram = false;
}

if(anagram == true){
System.out.println("Strings are not Anagrams");
}
}
}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve      check if 2 strings are Anagrams     Amazon  DataMetica  Hewlett Packard (HP)  Opera Solutions  AirWatch  Booking.com  JP Morgan  Verdantis  AppDynamics  QSI Healthcare  Vistaar Technologies  Maventic  5AM Solutions  Rare Mile Technologies  Shutterfly  Fiberlink  Veeva Systems  Flipkart  eHarmony  Splunk  Zoho  Betterment  WisdmLabs  Adap.tv  Spotify  Yahoo  Wissen Infotech  GlobalLogic      basic        frequent


 Q84. Difference between Inner and Outer Join ?Database
Admin
info@buggybread.com
Ans. Inner join is the intersection of two tables on a particular columns whereas Outer Join is the Union of two tables.



 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     sql   joins   inner join   outer join     Hewlett Packard (HP)      basic        frequent


 Q85. What is a Cursor ?Database
Admin
info@buggybread.com
Ans. It's a facility that allows traversal over the records pulled from a table or combination of tables. Its like iterator in Java.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     databases   sql   cursors   packages     Jade Global  Paychex  Credence Analytics  CMSS Pvt Ltd      basic        frequent


 Q86. What are temp tables ?
Admin
info@buggybread.com
Ans. These are the tables that are created temporarily and are deleted once the Stored Procedure is complete.

For example - we may like to pull some info from a table and then do some operations on that data and then store the output in final output table. We can store the intermediary values in a temp table and once we have final output with us, we can just delete it.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     database   sql   temp tables   tables


 Q87. what will be the output ?

class Animal {
public void eat() throws Exception {
}
}

class Dog2 extends Animal {
public void eat(){}
public static void main(){
Animal an = new Dog2();
an.eat();
}
}
Core Java
Admin
info@buggybread.com
Ans. Compile Time Error: Unhandled exception type Exception

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   code   coding   overridding   late binding   exception handling   abstract class   abstract methods


 Q88. Does SQL allow null values ? Can we use it within Where clause ?
Admin
info@buggybread.com
Ans. Yes , we can have null values for columns in SQL. Null value represent that the columns value is unknown or haven't been filled. Yes, We can use it within where clause to get the rows with null values.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     sql   sql null values   sql where clause   databases


 Q89. What is the problem with this code ?

class BuggyBread1 {

   private BuggyBread2 buggybread2;

   public static void main(String[] args){
      try {
         BuggyBread1 buggybread1 = new BuggyBread1();
         ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream(new File("newFile.txt")));
         objectOutputStream.writeObject(buggybread1);
      } catch (Exception e) {
         e.printStackTrace();
      }
   }
}
Core Java
Admin
info@buggybread.com
Ans. Though we are trying to serialize BuggyBread1 object but we haven't declared the class to implement Serializable.

This will throw java.io.NotSerializableException upon execution.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   io   file   fileio   coding   code   serialization   notserializableexception   exception



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q90. Will this code run fine if BuggyBread2 doesn't implement Serializable interface ?

class BuggyBread1 implements Serializable{
   private BuggyBread2 buggybread2 = new BuggyBread2();

   public static void main(String[] args){
      try {
         BuggyBread1 buggybread1 = new BuggyBread1();
         ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream(new File("newFile.txt")));
         objectOutputStream.writeObject(buggybread1);
      } catch (Exception e) {
         e.printStackTrace();
      }
   }
}
Core Java
Admin
info@buggybread.com
Ans.  No, It will throw java.io.NotSerializableException.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   io   file   fileio   coding   code   serialization   notserializableexception   exception


 Q91. Will this code Work ? If not , Why ?

java.util.Calendar c = new java.util.Calendar();
Core Java
Admin
info@buggybread.com
Ans. No. It gives the error "Cannot Instantiate the type Calendar". Calendar is an abstract class and hence Calendar object should be instantiated using Calendar.getInstance().

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   date   calendar   abstract class   yes-no


 Q92. Is java.util.Date an abstract Class ? Is java.util.Calendar an abstract Class ?Core Java
Admin
info@buggybread.com
Ans. Date is not a abstract class whereas Calendar is.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   date   calendar   abstract class


Very Frequently asked. Favorite question in walkins and telephonic interviews. Usually among first few questions. Asked in different variants. Must know for intermediate and expert professionals.Among Top 10 frequently asked questions.
  Q93. What is rule regarding overriding equals and hashCode method ?Core Java
Admin
info@buggybread.com
Ans. A Class must override the hashCode method if its overriding the equals method.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   collections   hashcode  hash code   equals   collections     Cognizant (CTS)  CapitalOne  Tata Consultancy (TCS)  HCL Technologies  Deloitte  Wipro  Infosys  Sabre  Sophos   Tieto  Addteq  Priceline.com  Cisco Systems  Visa Inc  Vibrant Media  Audience Science  GT Nexus  OpenCrowd  Instinet  Kronos  Elsevier  IMC Financial  LG Mobile  Dun & Bradstreet  WBUT  codecentric  Satmetrix  Interactive Brokers  Roposo  SecureView  Azuga  Envestnet  Criteo  Skillz  MobileIron  Walmart  R Systems  Overstock.com  Verilogue  Goldstone Technologies  FatWire  LinkedIn  Southwest Airlines      intermediate        frequent

Try 1 Question(s) Test


 Q94. How TreeMap orders the elements if the Key is a String ?
Admin
info@buggybread.com
Ans. As String implements Comparable, It refers to the String compareTo method to identify the order relationship among those elements.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   collections   comparable interface   treemap   compareto


 Q95. Can we add heterogeneous elements into TreeMap ?
Admin
info@buggybread.com
Ans. No, Sorted collections don't allow addition of heterogeneous elements as they are not comparable.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   collections   comparable interface   treemap


 Q96. Will it create any problem if We add elements with key as user defined object into the TreeMap ?
Admin
info@buggybread.com
Ans. It won't create any problem if the objects are comparable i.e we have that class implementing Comparable interface.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   collections   treemap   comparable interface


  Q97. Can we have null keys in TreeMap ?Core Java
Admin
info@buggybread.com
Ans. No, results in exception.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   collections   treemap     Visa  Prokarma  Sabre  Polaris  Deloitte  Cognizant (CTS)      Basic        frequent


Very frequently asked Hibernate interview question.
  Q98. What are different types of associations in Hibernate ?Hibernate
Admin
info@buggybread.com
Ans. There are 4 types of associations in Hibernate

One to One
One to Many
Many to One
Many to Many

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     hibernate   associations     Overstock.com  BirlaSoft  Fiserv  Overstock.com  Tata Consultancy (TCS)  Wipro  Tech Mahindra  Infosys  HCL Technologies  Fidelity  Sabre        frequent


 Q99. What is the difference between these 2 annotations ?

@Entity ( name ="EMPLOYEES")
@Entity @Table ( name=""EMPLOYEES"" )

@Entity ( name="EMP")
@Table ( name="EMPLPYEES" )
Hibernate
Admin
info@buggybread.com
Ans. First Annotation will set the Entity name as EMPLOYEES and hence will try to map with the same Table name.

The second annotation will make the Entity mapped to table EMPLOYEES irrespective of the Entity Name ( which is class name in this case ).

Third Annotations will set the different names for Enitity and Table and will explicitly map them.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     hibernate   hibernate annotations   entity annotation   table annotation



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q100. What is the difference between int[] x; and int x[]; ?Core Java
admin
info@buggybread.com
Ans. No Difference. Both are the acceptable ways to declare an array.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   array   arrays   array declaration   difference between     ABC Ltd   Infosys  InfoTrellis      basic


next 100


Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner



comments powered by Disqus
 

Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked:
         

X Close this

53 person from are looking for questions for 'Abs'. Connect with them to better prepare for your interview.Click here and post a message

X Close this

Help Us Improve.
Please share your
interview experience.

Company Name:   


Questions Asked: