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

Frequently asked to experienced developers. Recently asked in many US interviews.
 Q1. 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


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


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


Frequently asked to fresh graduates.
 Q4. 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


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


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


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


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


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



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



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


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


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


 Q13. Write an SQL to find all records having all upper case alphanumeric characters in a field ?
admin
info@buggybread.com
Ans. Select * from Table where field = upper(field)

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

   Like      Discuss      Correct / Improve     sql   database


 Q14. Write an SQL to find all records having all numeric characters in a field ?
admin
info@buggybread.com
Ans. Select * from Table where isnumeric(field) = 1;

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

   Like      Discuss      Correct / Improve     sql   database


 Q15. Do you know of any DB statement that can be used if we would like to insert multiple rows into a table ? Database
Admin
info@buggybread.com
Ans. We can use INSERT ALL.

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

   Like      Discuss      Correct / Improve     database   insert   dml statement   sql


 Q16. What is the advantage of JPA ?Database
Admin
info@buggybread.com
Ans. Its a specification that guides the implementation of ORM frameworks. Implementations abiding by the specification would mean that one can be replaced with other in an application without much hassle. Only the Features that are added over the specification needs to be taken care of if any such change is made.

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

   Like      Discuss      Correct / Improve     jpa   hibernate   orm   technologies


 Q17. What things you will look for if you get following exception while making DB call ?

table or view does not exist
Database
Admin
info@buggybread.com
Ans. First will check if the table or view actually exist in the DB

If it does , Will make sure to see that the application has rights on the schema that holds the respective Table.

Will then make sure that we have prefixed the schema with the table name while accessing it.

Will then make sure that its not DB Cache that's causing it as the table DDL might have been created recently.

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

   Like      Discuss      Correct / Improve     sql   database   oracle   technical lead


 Q18. What's the benefit for specifying constraints like Not Null , Primary Key explicitly instead of specifying it against the column ?Database
Admin
info@buggybread.com
Ans. In case we specify them explicitly we can have control over constraint name as otherwise they will be system generated. It provides an ease in case we plan to drop the constraint in future.

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

   Like      Discuss      Correct / Improve     sql   database   oracle


 Q19. How can we disable a constraint ?Database
Admin
info@buggybread.com
Ans. alter table
table_name
DISABLE constraint
constraint_name;

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

   Like      Discuss      Correct / Improve     sql   database   oracle



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q20. Can we have foreign key reference to a non primary key column ?Database
Admin
info@buggybread.com
Ans. Yes, but the respective key in the foreign table should be declared Unique.

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

   Like      Discuss      Correct / Improve     sql   database   oracle     IRIS Software  Tata Consultancy (TCS)


 Q21. What should be done for auto generating primary key id in a table ?Database
admin
info@buggybread.com
Ans. We need to create a sequence.

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

   Like      Discuss      Correct / Improve     sql   database   oracle


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


 Q23. How to know the structure of a Table in Oracle ?Database
Admin
info@buggybread.com
Ans. DESC

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

   Like      Discuss      Correct / Improve     sql   database   oracle


 Q24. How to know the constraints on a Table in Oracle ?Database
Admin
info@buggybread.com
Ans. SELECT *
FROM user_constraints
WHERE table_name = ''

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

   Like      Discuss      Correct / Improve     sql   database   oracle


 Q25. How to know the default column value of a Table in Oracle ?Database
Admin
info@buggybread.com
Ans. Select DATA_DEFAULT
from DBA_TAB_COLUMNS
where TABLE_NAME = '' and COLUMN_NAME='';

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

   Like      Discuss      Correct / Improve     sql   database   oracle


 Q26. What are the advantages of using distributed database management system ?Database2016-11-30 16:05:24

Ans. Reliability and Continuity if some of the sites goes down.Easy Scaling up and Down as sites can be added or removed without impacting business continuity.

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

   Like      Discuss      Correct / Improve     dbms  database management system  distributed database management system     Elsevier


 Q27. When do we generally get this database error - integrity constraint violated - parent key not found ?2016-07-12 08:40:57

Ans. This error most likely will be thrown during an insert statement, while inserting a value within a foreign key column which doesnt exist within the Parent column. For example - Trying to add a dept number reference within a Employee Table when the Dept doesnt exist in the Dept Table.

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

   Like      Discuss      Correct / Improve     database  integrity constraint error  integrity constraint violated


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


 Q29. 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)



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



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


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


 Q32. How to count total number of tables in database ?Database2016-10-18 14:13:31

Ans. SELECT COUNT(*) FROM information_schema.tables

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

   Like      Discuss      Correct / Improve     database query     MagicBricks


 Q33. There is a Table Student having Student Id, Name and Total Marks. Can you please write an SQL that will display the maximum marks obtained by a student ?Database2016-10-18 14:21:04

Ans. SELECT MARKS FROM STUDENT ORDER BY MARKS DESC LIMIT 1;

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

   Like      Discuss      Correct / Improve     database query     MagicBricks


 Q34. What is CRUD ?Database2016-06-13 10:34:03

Ans. CRUD stands for "Create, read, update and delete" are the basic functions of persistence.

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

   Like      Discuss      Correct / Improve     CRUD  Persistence  Database  Database Operations     Logica  JP Morgan  FastPay      Basic        frequent


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


 Q36. When do we generally get the database error - Unique Constraint Violated ?2016-07-12 08:43:38

Ans. This error can result either on an insert, update or delete when any change in data results in duplicate record or subset of it having unique constraint on record or its subset. For example - If we have a unique constraint on a combination of columns and then trying to insert duplicate column values.

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

   Like      Discuss      Correct / Improve     database  Unique Constraint error  Unique Constraint violated


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


 Q38. What is the purpose of Commit and Rollback in Databases ?Database2016-07-14 14:28:55

Ans. When a DML is executed, the changes only stays in session and still not pushed to DB Tables, Commit is used to push those changes to the Tables.

In case we realize that we don't want to commit those changes and would like to ignore them, we can use rollback.

For example - You may like that for a banking transaction you would like to update the account balance only if the debit or credit record was correctly inserted, so you may like to encapsulate both DML's - insert for transaction and update for balance in a single transaction and would only commit if both succeeds else rollback.

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

   Like      Discuss      Correct / Improve     databases  commit  rollback     Amdocs  The Bank of New York Mellon (BNY Mellon)      Basic


 Q39. How to Bulk upload the data into Oracle database?Database2016-10-21 12:36:26

Ans. We can use external table feature of Oracle.

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

   Like      Discuss      Correct / Improve          HCL Technologies      Intermediate



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q40. Write an SQL Statement to add a foreign key constraint in oracle ?Database2016-11-08 14:27:31

Ans. ALTER TABLE <Table_Name> ADD CONSTRAINT <Constraint_Name> FOREIGN KEY (<Column_Name>) REFERENCES <Foreign_Table>(<Foreign_Column>);

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

   Like      Discuss      Correct / Improve     database  add foreign key constraint


 Q41. What is Dirty read in Database Transactions ?Database2016-11-14 13:11:55

Ans. A dirty read occurs when a transaction is allowed to read data from a row that has been modified by another running transaction but not yet committed.

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

   Like      Discuss      Correct / Improve     database transaction     Credit Agricole  Cassiopae  Infosys  Goldman Sachs  ISN Software  ProKarma  Sapient  Scotiabank


 Q42. Difference between JDBC and Hibernate ?Database2016-12-06 09:57:14

Ans. JDBC is a standard Java Api for Database communication whereas Hibernate is an ORM framework that uses JDBC to connect with Database.

Hibernate is another layer of object table mapping over JDBC that provide a database independent, object oriented and an efficient way of database communication.

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

   Like      Discuss      Correct / Improve     JDBC  Hibernate  JDBC vs Hibernate     CapTech  Oracle Argentina


 Q43. Difference between relational databases and NoSQL databases ?Database2016-12-13 11:06:42

Ans. https://www.mongodb.com/scale/nosql-vs-relational-databases

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

   Like      Discuss      Correct / Improve     database management  nosql database  relational database     Alibaba        frequent


 Q44. How to delete duplicate elements in a table ?Database2016-12-13 14:58:38

Ans. DELETE FROM TABLE WHERE ROW_NUM NOT IN ( SELECT MAX(ROW_ID) FROM TABLE GROUP BY DUPLICATE_FIELD )

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

   Like      Discuss      Correct / Improve          Myntra  Accenture


 Q45. With a Table employee having columns Id,Name,ManagerEmployeeId, Write a SQL to find the Manager with maximum number of employees ?Database2016-12-21 09:44:31

Ans. Select Name from EMPLOYEE where ID in (Select ManagerEmployeeId from EMPLOYEE
Group By ManagerEmployeeId
order by count(Id)
LIMIT 1)

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

   Like      Discuss      Correct / Improve     database  sql     Computer Sciences Corporation (CSC) India


  Q46. What is database Normalization ?Database2017-01-09 12:00:02

Ans. https://en.wikipedia.org/wiki/Database_normalization

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

   Like      Discuss      Correct / Improve     normalization  database     Sapient  Group Health  IGATE  Accenture  IBM  Oracle  United Health Group (UHG)  Envestnet      intermediate        frequent


 Q47. Which interface is responsible for transaction management in JDBC ?Database2017-01-12 14:23:29

Ans. Connection Interface

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

   Like      Discuss      Correct / Improve     jdbc


 Q48. What actions you take if there is an issue related to Database server ?Support2017-01-16 10:13:29

Ans. We involve DBA and try to solve it through them. By the time they are solving it , we keep the stake holders informed regarding the progress.

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

   Like      Discuss      Correct / Improve     database  database server  production support


 Q49. How should we handle errors while writing or accessing Stored Procedures?Database2017-01-19 13:55:55

Ans. Store Procedure returns the error code. Moreover we can put the call withing try block and catch SQL Exception.

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

   Like      Discuss      Correct / Improve     stored procedure  exception handling



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



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


 Q51. What are the methods to connect to database in Java ?Database2017-02-05 09:00:41

Ans. JDBC ( Java Database Connectivity ),ODBC (Open Database Connectivity), Hibernate, JPA ( Java Persistence API ), JOOQ,MyBatis

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

   Like      Discuss      Correct / Improve     database connection  jdbc  ORM  Hibernate     Amdocs


 Q52. Can the foreign key column have null values ?Database2017-02-25 08:32:47

 This question was recently asked at 'Volkswagen It services'.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          Volkswagen It services


 Q53. What are the benefits of using Prepared statements ?Database2017-03-09 11:32:07

Ans. 1. Precompilation , DB-side caching and reuse of same execution plan leads to overall faster execution.

2. Automatic prevention of SQL injection attacks by escaping special characters

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

   Like      Discuss      Correct / Improve     Prepared statements  benefits of prepared statements     ADP

Try 1 Question(s) Test


 Q54. What are the benefits of using prepared statements ? Does that benefit extend only if similar prepared statements are used within a application or it extends even with multiple applications having similar prepared statement ?Database2017-03-09 11:33:25

Ans. Prepared Statements helps in reuse of database execution plan which can be cached at Database level and hence helps achieving faster execution and performance. As cached ps objects are creating at Database level and not application level, the use and benefit extends across multiple applications.

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

   Like      Discuss      Correct / Improve     Prepared statements  benefits of prepared statements     ADP

Try 1 Question(s) Test


 Q55. Where the prepared Statement object creating - In Java application or DB ?Database2017-03-09 11:33:57

Ans. Prepared Statement objects are created and cached at database level.

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

   Like      Discuss      Correct / Improve     Prepared statements     ADP

Try 1 Question(s) Test


 Q56. Does null and empty value for a column in Table means same ?Database2017-03-16 09:49:31

Ans. No.

Null value means that the value is yet to be assigned or need not be assigned whereas empty value means that the blank value has already been assigned once. Null is the default for the null able columns that hasn't be assigned any value.

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

   Like      Discuss      Correct / Improve     


 Q57. What do you make out of this error

org.hibernate.exception.ConstraintViolationException: could not insert: [<Entity>]
Caused by: java.sql.SQLIntegrityConstraintViolationException: ORA-00001: unique constraint (<Constraint Name>) violated

and how would you go about debugging it ?
Database2017-03-22 13:12:50

Ans. Application is unable to insert a record as it violates a unique constraint.

The exception states the constraint and Table can be located by the Entity mapping. So I will go to the DB and will first check to which all columns the unique constraint applies. And then I will go and check the code and logs to see how come the duplicate column values were attempted to be inserted when they were not supposed to be.

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

   Like      Discuss      Correct / Improve     ConstraintViolationException  SQLIntegrityConstraintViolationException


 Q58. What are the different database constraint types ?Database2017-03-22 13:16:21

Ans. Not Null
Unique
Primary Key
Foreign Key
Check Constraint

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

   Like      Discuss      Correct / Improve          [database constraints]


 Q59. What is a check database constraint ?Database2017-03-22 13:17:05

Ans. Constraint specifies the values allowed in one or more columns of every row of a table.

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

   Like      Discuss      Correct / Improve     database constraint



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q60. What is a unique constraint ?Database2017-03-22 13:18:24

Ans. Unique constraint ensures that a columns or combination or columns are always unique in a table and hence doesn't allow null or duplicates to be entered for the column or combination of columns.

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

   Like      Discuss      Correct / Improve     unique constraint


 Q61. What is the relation between Primary Key, Unique and Not Null constraint ?Database2017-03-22 13:22:03

Ans. Primary Key constraint means that the column(s) should be unique and doesn't allow null. So Primary key constraint implies unique and not null constraint too.

Unique constraint implies not null constraint too as allowing null would violate uniqueness on those columns.

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

   Like      Discuss      Correct / Improve     database constraint


 Q62. What is an optimistic locking ?Database2017-03-29 12:40:27

Ans. It's the way for synchronization wherein we can store version information in the table , so that if the same entity is updated by two transactions, the last to commit changes is informed of the conflict, and does not override the other transaction's work.

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

   Like      Discuss      Correct / Improve     locking  optimistic locking  Synchronization


 Q63. Write a SQL to delete duplicate records in a tableDatabase2017-04-20 06:42:22

Ans. DELETE FROM TABLE WHERE ROW_NUM NOT IN ( SELECT MAX(ROW_ID) FROM TABLE GROUP BY DUPLICATE_FIELD )

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

   Like      Discuss      Correct / Improve          Amdocs  Accenture


 Q64. which one do you prefer - JDBC or Hibernate ?Database2017-05-03 15:35:50

 This question was recently asked at 'Captech'.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          Captech


 Q65. Where does database stored procedures gets stored ?Database2017-05-10 17:20:51

 This question was recently asked at 'iNautix Technologies'.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          iNautix Technologies


 Q66. What is the difference between Oracle , Cassandra and Redis ?Database2017-05-22 17:12:03

Ans. Oracle is a relational database. Cassandra is a noSQL Database whereas Redis is an inmemory cache.

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

   Like      Discuss      Correct / Improve     oracle  casandra  redis


 Q67. What is the order in which triggers gets fired ?Database2017-05-24 20:38:35

Ans. There is no specific order in which database fires the triggers if they are for the same operation. If we need to have a specific order for their execution, we should have them all in a stored procedure and the procedure should get executed upon the event.

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

   Like      Discuss      Correct / Improve     oracle  database  triggers  sequence of trigger execution  sequence in which triggers gets fired     UST Global


 Q68. What is a ternary operator ?Database2017-06-18 16:46:34

Ans. Ternary operator , also called conditional operator is used to decide which value to assign to a variable based on a Boolean value evaluation. It is used as

condition ? value1 : value2

For example

int y = (x > 0) ? x:0; // assign x if it's greater than 0, else assign 0

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

   Like      Discuss      Correct / Improve     operator  ternary operator      Basic


 Q69. What is the difference between JDBC, Hibernate and ODBC ?Database2017-06-18 17:52:39

 This question was recently asked at 'Oracle Argentina'.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     jdbc  odbc  hibernate  jdbc vc odbc  jdbc vs hibernate     Oracle Argentina



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q70. If Table A has 100 records and Table B has 50 records , how many records will the equi join of Table generate ?SQL2017-07-14 17:59:56

Ans. It depends on the join condition.

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

   Like      Discuss      Correct / Improve     equi join  sql join  database  sql


 Q71. If Table A has 100 records and Table B has 50 records , how many records will the left join of Table A with Table B generate ?SQL2017-07-14 18:00:37

Ans. 100 records

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

   Like      Discuss      Correct / Improve     database  sql  sql joins   left join


 Q72. If Table A has 100 records and Table B has 50 records , how many records will the right join of Table A with Table B generate ?SQL2017-07-14 18:01:01

Ans. 50 records

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

   Like      Discuss      Correct / Improve     database  sql  sql joins   right join


 Q73. If Table A has 0 records and Table B has 50 records , how many records will the equi join of Table generate ?SQL2017-07-14 18:01:50

Ans. 0 records

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

   Like      Discuss      Correct / Improve     database  sql  sql joins   equi join


 Q74. What is ORM or Object Relationship Mapping ?Database2017-08-02 08:32:10

 This question was recently asked at 'Infosys'.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     orm     Infosys        frequent


 Q75. Write a SQL to remove records with a duplicate field in a Table ?Database2017-08-17 10:59:44

 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     sql


 Q76. How Cassandra provides better Read performance than Oracle Indices ?Database2017-08-18 09:39:56

Ans. Cassandra uses Hash Search which provides a look time of O(1) whereas Oracle Indices uses Binary Search that provide a lookup time of O(Log n).

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

   Like      Discuss      Correct / Improve     cassandra  hash search  hash search vs binary search


 Q77. Difference between Normalization and Denormalization ? Database2017-08-18 09:42:11

Ans. Normalization is the process of splitting one Table into multiple so as to avoid Data duplication whereas Denormalization is the process of reducing Tables that creates data duplication but would remove joins in the queries.

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

   Like      Discuss      Correct / Improve     normalization  denormalization  normaization vs denormalization


 Q78. Which of the two Normalization / Denormalization facilitate better performance ? Which of the two facilitate better space management ?Database2017-08-18 09:42:46

Ans. DeNormalization facilitate better performance. Normalization remove data duplication and hence facilitate better database space management.

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

   Like      Discuss      Correct / Improve     normalization  denormalization  normalization vs denormalization


 Q79. Which of the following databases - Cassandra / Oracle - provides more flexibility about querying the database ?Database2017-08-18 09:44:08

Ans. Oracle as it is not modeled for a particular query or set of queries.

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

   Like      Discuss      Correct / Improve     Cassandra  Nosql database  nosql vs relational database



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q80. Which is the best NoSql Database for Performance ?Database2017-08-19 19:32:09

 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     Nosql Database


 Q81. Design a Database Schema to store Employee Information with each employee having multiple addresses. Database2017-08-24 13:48:56

Ans. We can have 2 entities i.e EMPLOYEE and ADDRESS and can have a relationship Table , EMPLOYEE_ADDRESS having one to may relationship between the two.

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

   Like      Discuss      Correct / Improve     database schema   design     Accenture


 Q82. Write a SQL to find 2nd Max value in a Table.Database2017-08-24 13:56:33

Ans. SELECT MIN(FIELD) FROM (SELECT TOP 2 FIELD FROM TABLE ORDER BY FIELD DESC)

or

SELECT MAX(FIELD) FROM TABLE WHERE FIELD NOT IN (SELECT MAX(FIELD) FROM TABLE)

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

   Like      Discuss      Correct / Improve     sql


 Q83. What is Dirty Read in Database Transactions ?Database
a. Data Read by Transaction 2 which hasn't yet updated by Transaction 1
b. Data Read by Transaction 2 which has been updated and commited by Transaction 1
c. Data Read by Transaction 2 which has been updated but not commited by Transaction 1
d. Inability of Transaction 2 to read Data when Transaction 1 is updating.

Ans.c. Data Read by Transaction 2 which has been updated but not commited by Transaction 1

 Q84. In majority of the cases, the following join will give maximum number of results ?Database
a. Inner Join
b. Outer Join
c. Left Join
d. Right Join

Ans.b. Outer Join

 Q85. Which if the following is true for SQL Joins ?Database
a. Left Join and Right Join gives equal number of Results
b. Outer Join and Inner Join gives equal number of Results
c. Inner Join gives maximum number of results records
d. Inner Join gives minimum number of result records

Ans.d. Inner Join gives minimum number of result records

 Q86. Which of the following is not true for Prepared Statements ?Database
a. Prepared Statements provides better performance
b. Prepared Statements prevent SQL Injection attacks
c. Prepared Statements provide ORM capabilities
d. Prepared Statement provides DB side caching

Ans.c. Prepared Statements provide ORM capabilities



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

6 person from are looking for questions for 'Database'. Connect with them to better prepare for your interview.
X Close this

Help Us Improve.
Please share your
interview experience.

Company Name:   


Questions Asked: