Java - Interview Questions and Answers for 'Cognizant (cts)' | 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 'Cognizant (cts)' - 63 question(s) found - Order By Newest

Advanced level question. Frequently asked in High end product companies. Frequently asked in Cognizant ( Based on 2 feedbacks )
  Q1. 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)
  Q2. 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


 Q3. How can we run a java program without making any object?Core Java
Anonymous
Ans. By putting code within static method. With Java 6 and earlier versions, even static block can be used.

  Sample Code for static block

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

   Like      Discuss      Correct / Improve     java   oops   static   static method   static block     American Express  Cognizant (CTS)      basic        frequent

Try 1 Question(s) Test


Very frequently asked. Favorite question in Walk in Drive of many Indian service companies. Frequently asked in HCL Technologies.
  Q4. 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. Favorite question in Walk in Drive of many Indian service companies.
  Q5. 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.
 Q6. 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


 Q7. 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


Very Frequently asked to fresh graduates and less experienced. Favorite question in Walk in drives.
  Q8. 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


Frequently asked question in companies using hibernate.
  Q9. Difference between first level and second level cache in hibernate ?Hibernate
Admin
info@buggybread.com
Ans. 1. First level cache is enabled by default whereas Second level cache needs to be enabled explicitly.

2. First level Cache came with Hibernate 1.0 whereas Second level cache came with Hibernate 3.0.

3. First level Cache is Session specific whereas Second level cache is shared by sessions that is why First level cache is considered local and second level cache is considered global.

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

   Like      Discuss      Correct / Improve     hibernate   orm   hibernate cache   architecture   technical lead     EFI  Geometric  QuinStreet  Cognizant (CTS)  ZS Associates  Walt Disney      Intermediate        frequent



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q10. What are the contents of Hibernate configuration file ( hibernate.cfg.xml ) ?Hibernate
Admin
info@buggybread.com
Ans. HBM Files ( Mapping )
DB Connection ( DB Connection String , User Name , Password , Pool Size )
SQL Dialect ( SQL variant to be generated )
Show SQL ( Show / No show SQL on Console )
Auto Commit ( True / False )

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

   Like      Discuss      Correct / Improve     hibernate   configuration   barclays     Mphasis  Mccoy Global Links  Availity  Infosys  GlobalLogic  Cognizant (CTS)  Overstock.com  Erricson  Erricson India  HCL Technologies  Tata Consultancy (TCS)


Very Frequently asked.
 Q11. Explain throw, throws , try and catch in Java ?Core Java
Admin
info@buggybread.com
Ans. throw is used to re throw an exception.

throws is used to declare that the method throws the respective exceptions.

try block is used to identify if the respective block has thrown any exception.

catch is used to catch the exception that has been thrown by the respective try block.

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

   Like      Discuss      Correct / Improve     java   exception handling   throw   throws   try   catch     Vidram Solutions  Cognizant (CTS)      basic        frequent


Very Frequently asked. Have been asked in HCL Technologies very frequently ( based on 2 feedback ). Among first few questions in many interviews.
  Q12. 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


Almost sure to be asked in every company using any Dependency Injection framework ( Spring, Guice etc )
  Q13. 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


Frequently asked. Among first few questions in the J2EE segment of interview.
  Q14. What is the use of deployment descriptor ?Java EE2016-06-04 22:46:40

Ans. Deployment Descriptor which is usually web.xml is used to specify the classes, resources and configuration of the application and how the web server uses them to serve web requests.This file is usually added to WEB-INF folder and contains following

* Servlet entries and url mapping
* Plugins
* Some info regarding authentication / filters
* Landing Page
* Event Handlers

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

   Like      Discuss      Correct / Improve     web.xml   servlets  deployment descriptor     The NewBury Corp  Fast Dolphin  uCertify  General Electric  Cognizant (CTS)  Web coop  HCL Technologies  Tara Consultancy (TCS)  Wipro  Infosys  Cognizant (CTS)  Sonatype  IBM  computer science corporation (CSC)      basic        frequent

Try 1 Question(s) Test


  Q15. 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


Frequently asked to fresh graduates and less experienced developers.
 Q16. Explain multithreading in Java ?Core Java
Anonymous
Ans. 1. Multithreading provides better interaction with the user by distribution of task

2. Threads in Java appear to run concurrently, so it provides simulation for simultaneous activities.The processor runs each thread for a short time and switches among the threads to simulate sim-ultaneous execution (context-switching) and it make appears that each thread has its own processor.By using this feature, users can make it appear as if multiple tasks are occurring simultaneously when, in fact, each is running for only a brief time before the context is switched to the next thread.

3. We can do other things while waiting for slow I/O operations.In the java.iopackage, the class InputStreamhas a method, read(), that blocks until a byte is read from the stream or until an IOExceptionis thrown. The thread that executes this method cannot do anything elsewhile awaiting the arrival of another byte on the stream.

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

   Like      Discuss      Correct / Improve     java   threads   multi threading  concurrency   multithreading     Hamsini ECommerce   Cognizant (CTS)  Cumulus Systems  Cognizant (CTS)      intermediate        frequent

Try 1 Question(s) Test


Frequently asked in all types of companies especially Indian Services companies. Frequently asked in CTS (Based on 2 feedback)
 Q17. What is the use of hashcode in Java ?Core Java
Anonymous
Ans. Hashcode is used for bucketing in Hash implementations like HashMap, HashTable, HashSet etc. The value received from hashcode() is used as bucket number for storing elements. This bucket number is the address of the element inside the set/map. when you do contains() then it will take the hashcode of the element, then look for the bucket where hashcode points to and if more than 1 element is found in the same bucket (multiple objects can have the same hashcode) then it uses the equals() method to evaluate if object are equal, and then decide if contain() is true or false, or decide if element could be added in the set or not.

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

   Like      Discuss      Correct / Improve     java   collections   hashcode   advanced     Cognizant (CTS)  Compro Technologies  VigLink  Proofpoint      intermediate        frequent

Try 1 Question(s) Test


 Q18. Different ways of implementing Threads in Java ?Core Java
Anonymous
Ans. Threads in Java can be implement either by Extending Thread class or implementing runnable interface.

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

   Like      Discuss      Correct / Improve     java   threads   multi threading     Cognizant (CTS)      basic        frequent


  Q19. What is Serialization ? Why do we need it ?Core Java
Anonymous
Ans. Storing the state of an object in a file or other medium is called serialization.

Classes can communicate only if they are built together ( as they need Byte code for communication ). What if we need to enable communication between different applications ( i.e they have been built independently or even they reside at different locations ), We need a mechanism that will transfer the Bean state to a Medium than can be transferred to the receiving application.

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

   Like      Discuss      Correct / Improve     java   oops   serialization     Computer Sciences Corporation (CSC) India   Tieto  Uproar  Priceline.com  HCL Technologies  Cognizant (CTS)      basic        frequent

Try 1 Question(s) Test



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q20. What is the use of Transient Keyword ?Core Java
Anonymous
Ans. It in Java is used to indicate that a field should not be serialized.

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

   Like      Discuss      Correct / Improve     java   oops   serialization   transient   java keywords     Cognizant (CTS)  The Advisory Board Company      intermediate        frequent

Try 2 Question(s) Test


Very frequently asked. Usually asked with questions related to String.
  Q21. 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.
 Q22. 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


 Q23. Explain Autoboxing ?Core Java
Anonymous
Ans. Autoboxing is the automatic conversion that the Java compiler makes between the primitive types and their corresponding object wrapper classes

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

   Like      Discuss      Correct / Improve     java   java5   autoboxing   wrapper classes     Cognizant (CTS)      basic        frequent


 Q24. Is it necessary that each try block to be followed by catch block ? Core Java
Anonymous
Ans. It should be followed by either catch or finally block.

  Sample Code for Retry in case of exception

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

   Like      Discuss      Correct / Improve     java   exceptions   exception handling   try   catch   finally  Oracle OCA Test     Accenture  Cognizant (CTS)      basic        frequent

Try 1 Question(s) Test


Frequently asked to fresh graduates.
 Q25. Explain Thread States ?Operating System
Admin
info@buggybread.com
Ans. Runnable - waiting for its turn to be picked for execution by the thread schedular based on thread priorities.

Running - The processor is actively executing the thread code. It runs until it becomes blocked, or voluntarily gives up its turn.

Waiting: A thread is in a blocked state while it waits for some external processing such as file I/O to finish.

Sleeping - Java threads are forcibly put to sleep (suspended) with Thread.sleep. they can resume using Thread.resume method.

Blocked on I/O - Will move to runnable after I/O condition like reading bytes of data etc changes.

Blocked on synchronization - Will move to Runnable when a lock is acquired.

Dead - The thread is finished working.

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

   Like      Discuss      Correct / Improve     java   threads   multi threading   scheduling   thread states   basic interview question     Cognizant (CTS)      basic        frequent

Try 2 Question(s) Test


 Q26. What is PermGen or Permanent Generation ?Core Java
Admin
info@buggybread.com
Ans. The memory pool containing all the reflective data of the java virtual machine itself, such as class and method objects. With Java VMs that use class data sharing, this generation is divided into read-only and read-write areas. The Permanent generation contains metadata required by the JVM to describe the classes and methods used in the application. The permanent generation is populated by the JVM at runtime based on classes in use by the application. In addition, Java SE library classes and methods may be stored here.

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

   Like      Discuss      Correct / Improve     java   jvm   memory management   permgen   permanent generation   advanced   architecture     JP Morgan  SAP  Informatica  Credit Agricole  EXFO  EMC  Credit Agricole  Cognizant (CTS)  JP Morgan      expert


Very frequently asked in companies using SOA.
  Q27. What are RESTful Web Services ?Rest
Admin
info@buggybread.com
Ans. REST or Representational State Transfer is a flexible architecture style for creating web services that recommends the following guidelines -
1. http for client server communication,
2. XML / JSON as formatiing language ,
3. Simple URI as address for the services and,
4. stateless communication.

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

   Like      Discuss      Correct / Improve     java   web services   rest   java   j2ee  architecture     Synechron  CapitalOne  Overstock.com  Ebay  At&t  HCL Technologies  Barclays  Tata Consultancy (TCS)  Cognizant (CTS)  Wipro  Infosys  EPAM  Mphasis      intermediate        frequent


Frequently asked in Tech Mahindra ( Based on 3 inputs )
  Q28. What is the difference between List, Set and Map ?Core Java
Anonymous
Ans. List - Members are stored in sequence in memory and can be accessed through index.
Set - There is no relevance of sequence and index. Sets doesn't contain duplicates whereas multiset can have duplicates.
Map - Contains Key , Value pairs.

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

   Like      Discuss      Correct / Improve     java   collections   list   set   map     Cognizant (CTS)  Ebay   Infosys   HCL Technologies   Tech Mahindra  Cumulus Systems  Mindteck      basic        frequent

Try 1 Question(s) Test


Frequently asked at HCL Technologies ( Based on 3 feedback )
  Q29. Difference between Checked and Unchecked exceptions ?Core Java
Anonymous
Ans. Checked exceptions and the exceptions for which compiler throws an errors if they are not checked whereas unchecked exceptions and caught during run time only and hence can't be checked.

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

   Like      Discuss      Correct / Improve     java   exceptions   checked exceptions   unchecked exceptions   exception handling   basic interview question     Verilogue  F5 Network  Pegasystems  PegaSystems  SAP  Ciber  Conde Nast  Pramati Technologies  IBM  JP Morgan  HCL Technologies  Tata Consultancy (TCS)  Cognizant (CTS)  Cogent Infotech  MarketAxess  defense group  NETS INTERNATIONAL  Accenture  Integra Micro  ColdLight Solutions  Endeavor      basic        frequent

Try 1 Question(s) Test



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



Frequently asked.
  Q30. What is an Iterator?Core Java
Anonymous
Ans. Iterator is an interface that provides methods to iterate over any Collection.

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

   Like      Discuss      Correct / Improve     java   collections   iterator     Magic Software  Maverick Software  Wipro  IBM  HCL Technologies  Tata Consultancy (TCS)  Cognizant (CTS)  Wipro  Accenture      basic        frequent


 Q31. What are transient variables in java?Core Java
Anonymous
Ans. Transient variables are variable that cannot be serialized.

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

   Like      Discuss      Correct / Improve     java   serialization   transient     Cognizant (CTS)      intermediate        rare


Usually asked only to fresh graduates.
 Q32. What is the initial state of a thread when it is created and started?
Anonymous
Ans. Ready state.

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

   Like      Discuss      Correct / Improve     operating system   threads   multi threading   java   thread states     Cognizant (CTS)      basic        frequent


Frequently asked in CTS ( Based on 2 feedback )
  Q33. 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


 Q34. Explain Method Local Inner Classes ?Core Java
Admin
info@buggybread.com
Ans. You can create a non-static local class inside a body of code. Interfaces cannot have local classes, and you cannot create local interfaces.

Local classes are accessible only from the body of the code in which the class is defined. The local classes are completely inaccessible outside the body of the code in which the class is defined.

You can extend a class or implement interfaces while defining a local class.

A local class can access all the variables available in the body of the code in which it is defined. You can pass only final variables to a local inner class.

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

   Like      Discuss      Correct / Improve     java   oops   inner classes   local classes   classes   method local inner classes     Cognizant (CTS)


 Q35. 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


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.
  Q36. 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


  Q37. 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


 Q38. What is a ConcurrentHashMap ?Core Java
Admin
info@buggybread.com
Ans. ConcurrentHashMap is a hashMap that allows concurrent modifications from multiple threads as there can be multiple locks on the same hashmap.

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

   Like      Discuss      Correct / Improve     java   collections   hashmap   map   concurrenthashmap   concurrenthashmap  concurrency   general electric   ge     Cognizant (CTS)  Synechron  General Electric  MakeMyTrip.com  Nomura Securities  Xpanxion  Royal Bank of Scotland (RBS)  ProKarma  Talentica  Citi  EdgeVerve Systems  Six Dee Telecom  ReqRoute  Qumulo  Goldman Sachs  HSBC Holdings  AlertMe.com  BlackRock  Helpchat  Bally Technologies  Hubzu  Xpanxion  Coromandel Infotech  Paytm  YuMe  InfoGain  Markit  Wells Fargo  Geometric  Acloudzyn Technologies  Roposo        rare


Frequently asked these days as there are major changes in Java 8.
  Q39. What are new features introduced with Java 8 ?Core Java
Admin
info@buggybread.com
Ans. Lambda Expressions , Interface Default and Static Methods , Method Reference , Parameters Name , Optional , Streams, Concurrency.

  Sample Code for Lambda

  Sample Code for interface default

  Sample Code for Optional

  Sample Code for Streams

  Sample Code for java.time

  Sample Code for Predicate

  Sample Code for Consumer

  Sample Code for MapMerge

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

   Like      Discuss      Correct / Improve     java   java8   technical lead   technical architect     Kayak.com  Luxoft  Overstock.com  Span Infotech  Wealthfront  EMC  L&T Infotech  Vistana  Luxoft  GoodData  DreamWorks Animation  Cognizant (CTS)      expert        frequent



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q40. Does java allow implementation of multiple interfaces having Default methods with Same name and Signature ?Core Java
Admin
info@buggybread.com
Ans. No. Compilation error.

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

   Like      Discuss      Correct / Improve     java   java8   default method   yes-no     cognizant (CTS)      intermediate


 Q41. What are the advantages and disadvantages of CopyOnWriteArrayList ?Core Java
Admin
info@buggybread.com
Ans. This collections class has been implemented in such a manner that it can never throw ConcurrentModificationException. As it performs update and write operations by creating a new copy of ArrayList, It's slower compared to ArrayList.

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

   Like      Discuss      Correct / Improve     java   collections   list   arraylist   copyonwritearraylist   advantages-disadvantages   ConcurrentModificationException     Cognizant (CTS)  Engine Singapore  Credit Agricole  Roposo      Expert


Frequently asked in Tata Consultancy (TCS) interview ( Based on 2 Feedback )
 Q42. What are the technologies used in Jira ?Tools
Admin
info@buggybread.com
Ans. JIRA is written in Java and uses the Pico IOC container,Apache OFBiz entity engine, and WebWork technology stack. For remote procedure calls (RPC), JIRA supports REST, SOAP, and XML RPC.

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

   Like      Discuss      Correct / Improve     java   jira   issue management   defect management     Tata Consultancy (TCS)  Cognizant (CTS)  Hanya Technologies  SiliconIndia  eka software      expert


Must know at all levels. Among Top 10 frequently asked questions in Java. Very frequently asked to fresh graduates or less experienced professionals.
  Q43. What is Inheritance ?Core Java

Ans. Its a facility for code reuse and independent extension wherein a derived class inherits the properties of parent class.

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

   Like      Discuss      Correct / Improve     inheritance  oops concepts  java concepts  code reuse  code re-use   classes  derived classes     Maverick Software  Infosys  HCL Technologies  Tata Consultancy (TCS)  Cognizant (CTS)  Myntra  Capital One  Barclays  Accenture  Infoview Technologies  Wipro      basic        frequent


 Q44. How is static and dynamic polymorphism achieved in Java ?Core Java

Ans. Static polymorphism is the polymorphic resolution identified at compile time and is achieved through function overloading whereas dynamic polymorphism is the polymorphic resolution identified at runtime and is achieved through method overriding.

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

   Like      Discuss      Correct / Improve     static polymorphism   dynamic polymorphism   polymorphism   overloading   overriding     Cognizant (CTS)      basic        frequent


 Q45. Write a java program to implement Quick sort ?Core Java2016-10-18 10:49:19

Ans. http://www.programcreek.com/2012/11/quicksort-array-in-java/

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

   Like      Discuss      Correct / Improve     quick sort  sort     Cognizant (CTS)  SalesForce        frequent


Frequently asked to Fresh graduates.
 Q46. Write a program to implement Binary search ?Core Java2016-10-18 10:49:58

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     Cognizant (CTS)  Click Labs  Infoview Technologies  Mahindra Comviva  Acute Informatics      basic        frequent

Try 1 Question(s) Test


 Q47. Which data structure would you recommend for ordered and sorted data?Core Java2016-10-18 11:00:06

Ans. TreeSet and TreeMap are used for maintaining sorted elements.

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

   Like      Discuss      Correct / Improve     ordered collections  sorted collections     Cognizant (CTS)      basic        frequent


 Q48. Explain Exception Hierarchy in Java SE ?Core Java2016-10-18 11:02:09

Ans. http://www.programcreek.com/2009/02/diagram-for-hierarchy-of-exception-classes/

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

   Like      Discuss      Correct / Improve     exception hierarchy   exceptions     Cognizant (CTS)


 Q49. What is a Database Procedure ?Database2016-10-18 11:27:59

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     Cognizant (CTS)      basic        frequent



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q50. What is a Database sequence ?Database2016-10-18 11:30:07

Ans. Its a feature wherein database creates unique values incremental values to be stored as primary key for the table.

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

   Like      Discuss      Correct / Improve     database   sequence     Cognizant (CTS)


  Q51. What is a Database Trigger ?Database2016-10-18 11:31:17

Ans. A trigger is a special kind of stored procedure that automatically gets executed upon an event in the database server.

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

   Like      Discuss      Correct / Improve     database   trigger     Cognizant (CTS)  Acclaris  RedMane  Oracle  Mediaocean  Monsanto  Synchronoss  Unbounded Solutions  Clover  Jabong.com      basic        frequent


 Q52. What do you know about JQuery ?Java EE2016-10-18 11:34:55

Ans. jQuery is a cross platform JavaScript library designed to simplify the client-side scripting of HTML. JQuery is the most popular JavaScript library.

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

   Like      Discuss      Correct / Improve     jquery     Cognizant (CTS)


 Q53. Can we have try statement without catch? If try statement contains return will the finally block be executed? What happens if there is an exception inside finally block?Core Java2016-10-18 11:37:51

Ans. Yes, with finally.

Yes, finally block will be executed even if there is no exception in try block.

If finally throws an exception, the exception gets thrown to the calling module.

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

   Like      Discuss      Correct / Improve     exception handling     Cognizant (CTS)      intermediate


Very Frequently asked to fresh graduates and less experienced.
 Q54. What are the principle concepts of Object Oriented Programming ?Core Java2016-10-18 13:53:31

Ans. Abstraction Polymorphism Inheritance Encapsulation

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

   Like      Discuss      Correct / Improve     oops  oops concepts     Cognizant (CTS)      basic        frequent


All these acronyms JDK,JRE,JVM etc are very frequently asked.
 Q55. Difference between JDK and JRE ?Core Java2016-06-11 11:35:18

Ans. JRE or Java Runtime Environment is the Java Virtual Machine on which class files are executed. It includes borwser plugins that facilitates execution of class files in browsers.

JDK or Java Development Kit includes JRE , compiler and development tools.

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

   Like      Discuss      Correct / Improve     JDK  JRE  JDK vs JRE  Difference between     Cognizant (CTS)  Aspire Infinite Solutions  Infoview Technologies   Tieto      basic        frequent


  Q56. What is a self Join and give an example of a self Join ?Database2016-06-30 20:13:35

Ans. When a Table Join itself , it's a Self Join. For example - we like to know the pair of department names where first dept has lesser employees than the later.

Select D1.name , D2.name from Dept D1, Dept D2 where D1.employee_count < D2.employee_count

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

   Like      Discuss      Correct / Improve     sql  joins  self join  self-join  Pair of employee names with first having lesser salary than later  Pair of department names where first dept has lesser employees than the later     Accenture  West Monroe Partners  Oracle  eBay  Impetus Technologies  Bank of America  Fannie Mae  Wize Commerce  Kleward Consulting  Pyramid Consulting  Interra Information Technologies  Trigent Software  Xtreme Media  IGATE  Nagarro  Six Sigma  Nityo Infotech  Fujitsu  BlazeClan  Twist Bioscience  Invoyent  Cognizant (CTS)  i2c      basic        frequent


 Q57. Difference between GET and POST Requests ?Web Service2016-07-22 15:00:21

Ans. GET is supposed to get information from the server. Client sends the minimal information so that Server can respond with the response body on basis of request. For example - You want to get complete employment record for employee id 123

POST is supposed to send the information for submission. Payload or a Body is usually sent so that it can be persisted on the server. For example - Sending the complete information of an employee ( id, name , dept etc ) to the server for persisting it.

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

   Like      Discuss      Correct / Improve     get vs post   web service   rest     Wayfair  Finacus Solutions  Elsevier  Cognizant (CTS)  FlipKart      basic        frequent


 Q58. What are the benefits of Enums ?Core Java2016-09-07 09:05:01

Ans. Enums in Java are used to declare predefined objects and then reuse them. they offer many benefits

1. Enum instance are type safe and thread safe.

2. Enum instances are singleton and hence reused.

3. If we use Enums with Switch , It makes sure that the passed argument is either of its instance and hence provides a safeguard.

4. If we use Enum with Sorted Collections we can sort the elements with a predefined priorities ( as per constant declaration in enum )

5. We can use Enum as a Factory by defining its constructor.

6. We can store related constant data within enum. For example - If we know the values for the map upfront, we can alternatively use an enum.

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

   Like      Discuss      Correct / Improve          Sapient  HCL Technologies  Tata Consultancy (TCS)  Cognizant (CTS)  Accenture


 Q59. What are the disadvantages of multithreading ?Core Java2016-10-11 08:47:41

Ans. 1. Switching Overheads - Even though multi threading aims at improving performance by reducing the wait time and hence improving overall throughput, there is a cost of switching resources between threads and sometime this cost can surpass the benefits if there isnt much wait for IO or external communication.

2. Debugging is hard with multi threaded code.

3. Deadlock - Execution of multi threaded code many a times lead to deadlock due to shared resources.

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

   Like      Discuss      Correct / Improve     multithreading  threads     Cognizant (CTS)  Wipro  Deloitte  IBM



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



Very Frequently asked to Senior Software Engineers or Developers.
  Q60. Describe some of the Design Patterns you have used ?Design2016-12-01 16:31:17

Ans. [Open Ended Answer]

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

   Like      Discuss      Correct / Improve     design patterns     Goldman Sachs  Lexis Nexis  Elsevier  HCL Technologies  Tata Consultancy (TCS)  Infosys Technologies  Fidelity Investments  Nucleus Software Exports  General Electric  Cognizant (CTS)  Amdocs  MathWorks  Xebia  Goldstone technologies  Horizon Solutions  ECI Telecom      intermediate        frequent


  Q61. What is an exception and exception handling in Java ?Core Java2017-01-09 13:01:40

Ans. An Exception in java is the occurrence during computation that is anomalous and is not expected.

Exception handling is the mechanism which is used to handle such situations.


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

   Like      Discuss      Correct / Improve     exception handling     EPAM  Deloitte  Choice Hotels  Future Group  Cognizant (CTS)  Wipro  Infosys  HCL Technologies  Accenture  Amdocs  IBM  Ultramain Systems      basic        frequent


 Q62. What is a Webdriver ?Testing2017-02-02 08:25:41

Ans. Selenium WebDriver is a tool for automating web application testing.It helps in replicating the manual tester behavior like keyboard entry, mouse events etc and then matching the output against the expected.

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

   Like      Discuss      Correct / Improve     selenium  webdriver     Global Software Resources  FICO Software  Walt Disney  Softcrylic  Sky  23andMe  Endurance Group  CitiusTech  Hitachi Consulting  Crest Premedia  LivingSocial  TEKSystems  Jabong.com  Think Future Technologies  Dollar Shave Club  Zendesk  Five9  Aptify  Symphony Teleca  Collabera  Xpanxion  Fourth Technologies  Freedom Financial  Aurigo Software Technologies  Forte Group  Wipro  Infosys  Pearson  Overstock  Elsevier  Capgemini  Cognizant (CTS)  Tech Mahindra  OLA Software  Mphasis  GrayLocus  Bhavna


 Q63. Explain Generics in Java ?Core Java2017-08-01 12:00:02

Ans. Generics are a facility of generic programming that were added to the Java programming language in 2004 within J2SE5.0. They allow "a type or method to operate on objects of various types while providing compile-time type safety.

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

   Like      Discuss      Correct / Improve     generics     TIAA.Cognizant (CTS)  HCL Technologies  Infosys Technologies  Accenture




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

4 person from are looking for questions for 'Cognizant (cts)'. Connect with them to better prepare for your interview.
X Close this

Help Us Improve.
Please share your
interview experience.

Company Name:   


Questions Asked: