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

Search Java Interview Questions


 2137 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 'Table' - 42 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


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


Very frequently asked across all types of companies.
  Q3. 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


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


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


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


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


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



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



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


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


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


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


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


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


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


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


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


 Q19. Which constraint cannot be specified as an explicit constraint and should be specified with the column only ?Database
Admin
info@buggybread.com
Ans. NOT NULL

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

   Like      Discuss      Correct / Improve     sql   oracle   database   ddl   constraint   table creation



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q20. How do we specify the criteria if it involves mapping between two entities or join between tables ?Hibernate
Admin
info@buggybread.com
Ans. The following code returns the list of Employee objects having employee name starting with A and Dept Name ( Department , Employee Mapped ).

session.createCriteria(Employee.class,"emp")
.createAlias("emp.department", "dept",Criteria.INNER_JOIN)
.add( Restrictions.like("name", "A%") )
.add(Restrictions.eq("dept.name","Finance")
.list();

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

   Like      Discuss      Correct / Improve     hibernate   hibernate criteria   hibernate table mapping


 Q21. What are stateless objects ? How are they different from immutable objects ? Which of these two is thread safe ?
Admin
info@buggybread.com
Ans. Stateless objects are the objects without instance fields (instance variables). The class may have compile time constants i.e static final fields.

Immutable objects are the objects which have state but the state cannot be changed after initialization.

Both are Thread safe.

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

   Like      Discuss      Correct / Improve     java   stateless objects   immutable objects   objects   singleton scope


 Q22. What are advantages of stateless and / or immutable objects ?
Admin
info@buggybread.com
Ans. They can be shared across multiple threads as they are thread safe.

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

   Like      Discuss      Correct / Improve     java   stateless objects   immutable objects   objects


 Q23. Which interface does java.util.Hashtable implement ?

a. List
b. Set
c. Collection
d. Map
Core Java
Anonymous
Ans. Map

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

   Like      Discuss      Correct / Improve     hashtable   java   collections


 Q24. Which of the following is false ?

a. HashMap came before HashTable.
b. HashMap allows null values whereas Hashtable doesn’t allow null values.
c. HashTable and HashMap allow Key-Value pairs.
d. Hashtable is synchronized whereas HashMap is not.
Anonymous
Ans. HashMap came before HashTable.

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

   Like      Discuss      Correct / Improve     map   hashmap   hashtable   collection   java

Try 2 Question(s) Test


 Q25. Which of the following is not a Table tag ? a. th b. td c. tb d.
Anonymous
Ans. tb

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

   Like      Discuss      Correct / Improve     html   table   html tags


 Q26. Which of the following class creates mutable objects ?

a. Boolean
b. File
c. String
d. StringBuffer
Anonymous
Ans. StringBuffer

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

   Like      Discuss      Correct / Improve     java   immutable


 Q27. Have you heard about the external table feature of Oracle ?Database2016-10-18 11:48:05

Ans. The external tables feature is a complement to existing SQL Loader functionality. It enables to access data in external sources as if it were in a table in the database. We have used it few times for replicating tables across different database systems.

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

   Like      Discuss      Correct / Improve     external table oracle     Infosys        rare


 Q28. What are some alternates to keeping Audit Tables ?Database2016-07-14 14:24:37

Ans. Audit Tables generally stores Raw information to be reviewed in case of problems or determining impact. If Database space is an issue , and the audit information is rarely retrieved, one design could be to use compressed file system.

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

   Like      Discuss      Correct / Improve     databases   audit tables   raw transaction information storage     Sapient


 Q29. What are the benefits of creating immutable objects ?Core Java2017-01-22 16:01:54

Ans. 1. Security and Safety - They can be shared across multiple threads as they are thread safe. Moreover, it protects then from bad state due to interception by the other code segment. One such problem due to mutability and access by alternate code segment could be the change of hash code and then the impact on its search with hash collections.

2. Reuse - In some cases they can be reused as only one copy would exist and hence it can be relied upon. For example - String Pool

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

   Like      Discuss      Correct / Improve     immutable objects     Knight Capital      Intermediate        frequent



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q30. Create a Table with 2 Columns and Insert a row into itDatabase2017-01-28 14:25:32

Ans. CREATE TABLE TABLE_NAME (
ID NUMBER PRIMARY KEY,
NAME VARCHAR(50) NOT NULL,
);

INSERT INTO TABLE_NAME(ID, NAME) VALUES(1, "Abc");

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

   Like      Discuss      Correct / Improve     ddl  dml  create table  insert records into table     Full Creative


 Q31. Difference between concurrentHashMap and HashTable ?Core Java2017-01-29 18:37:04

Ans. HashTable locks the complete collection to provide synchronization whereas ConcurrentHashMap only locks segments to achieve synchronization and hence better efficient and faster.

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

   Like      Discuss      Correct / Improve     concurrentHashMap  HashTable  Map  Collections     Talentica  BlackRock


 Q32. isnt the use of HashTable and ConcurrentHashMap the same, i.e providing synchronized map collection ?Core Java2017-01-29 18:38:52

Ans. Yes, they both aim at providing synchronized access to the Map collection. The only difference is in their implementation. ConcurrentHashMap came after HashTable and hence technically more efficient as it doesn't lock the complete map while accessing it.

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

   Like      Discuss      Correct / Improve     HashTable  ConcurrentHashMap  map  Collections


 Q33. How to implement a hashtable ?Data Structure2017-04-20 09:38:10

 This question was recently asked at 'MarkMonitor'.This question is still unanswered. Can you please provide an answer.


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

   Like      Discuss      Correct / Improve     hashtable     MarkMonitor


 Q34. Make the following class immutable

public class Employee {

   private long employeeId;

   private String employeeName;

   public long getEmployeeId() {
      return employeeId;
   }

public void setEmployeeId(long employeeId) {
      this.employeeId = employeeId;
   }

   public String getEmployeeName() {
      return employeeName;
   }

public void setEmployeeName(String employeeName) {
      this.employeeName = employeeName;
   }
}
Core Java2017-05-15 10:09:35

Ans. public class Employee {

   private long employeeId;

   private String employeeName;

   public Employee(long employeeId,String employeeName){
      this.employeeId = employeeId;
      this.employeeName = employeeName;
   }

   public long getEmployeeId() {
      return employeeId;
   }

   public long getEmployeeName() {
      return employeeName;
   }
}

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

   Like      Discuss      Correct / Improve     immutable  immutable class


 Q35. What are the examples of immutable objects in Java ?Core Java2017-05-29 08:35:00

Ans. Following Classes in Java SE creates immutable objects

String class
Wrapper Classes like Integer, Float etc.
StackTraceElement
Most Enum classes
File Class
Locale Class

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

   Like      Discuss      Correct / Improve     immutable objects  immutable     Persistent Systems      Basic        frequent


 Q36. What is the difference between being final and being immutable ? Are string final or immutable in Java ?Core Java2017-07-22 15:57:55

Ans. Being final in the sense of objects or object reference means that the reference cannot be reassigned to a different object whereas being immutable means that the object contents cannot be changed.

Strings in Java are immutable.

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

   Like      Discuss      Correct / Improve     string  immutable  final vs immutable


 Q37. Does Wrapper classes produces immutable objects ? Core Java2017-08-08 09:46:33

Ans. Yes

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

   Like      Discuss      Correct / Improve     wrapper classes  immutable


 Q38. Why shouldn't we use string concatenation extensively or in a loop ?Core Java2017-08-08 09:52:53

Ans. Because String being an immutable object creates a new object upon each concatenation cycle. If there is any such need , we should use String Builder whose object is immutable.

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

   Like      Discuss      Correct / Improve     string  string immutable     Ancestry


 Q39. Is immutability an advantage with Wrapper classes over primitive types ? Core Java2017-08-24 21:43:19

Ans. There is no concept of de referencing with primitive types and hence they are implicitly immutable. Having wrapper classes as mutable offers disadvantages compared to primitive types. Wrapper classes being immutable offer similar advantage as primitive types.It actually overshadows the disadvantage wrapper class could have if they are immutable.

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

   Like      Discuss      Correct / Improve     immutable classes  wrapper classes



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q40. Which immutable classes have you worked with ? Can you name some immutable Collections ? How to make an immutable collection ?Core Java2017-08-28 17:11:22

 This question was recently asked at 'Ancestry,HCL Technologies,Tata Consultancy (TCS)'.This question is still unanswered. Can you please provide an answer.


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

   Like      Discuss      Correct / Improve     immutability  immutable classes   immutable collections     Ancestry  HCL Technologies  Tata Consultancy (TCS)


 Q41. What are the benefits of immutability or Immutable classes ?Core Java2017-08-28 19:36:18

 This question was recently asked at 'Ancestry'.This question is still unanswered. Can you please provide an answer.


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

   Like      Discuss      Correct / Improve     immutable classes   benefits of immutable classes     Ancestry


 Q42. Which of the following class creates immutable objects ?Core Java
a. String
b. StringBuffer
c. StringBuilder
d. None of these create immutable objects.

Ans.a. String



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

X Close this

Help Us Improve.
Please share your
interview experience.

Company Name:   


Questions Asked: