3i Infotech Papers: Sample Questions 995 - 996 of 1245

Examrace Placement Series prepares you for the toughest placement exams to top companies.

Question number: 995

» Basic CS » Data Structures



Under which circumstance should you create an index on a table?


Choice (4) Response


The table is small.


The table is updated frequently.


A columns values are static and contain a narrow range of values


Two columns are consistently used in the WHERE clause join condition of SELECT statements.




  • Index on table is created when there are thousands of rows and user wants to search the record on some conditions.

  • So indexes are created for where clauses- for columns used in the WHERE clauses or join conditions.

  • Creating an index on an empty table has no performance implications at the time of creation but performance is affected when data is added to the table.

  • Creating indexes on large tables should be planned to not affect database performance.

  • Preferred way to create indexes on large tables is to start with the clustered index and then build no clustered indexes.

  • Set the ONLINE option to ON when creating indexes on existing tables.

Question number: 996

» Languages » Java

Essay Question▾

Describe in Detail

How java can be connected to a database?


There are steps to connect any java application with the database using JDBC.

  • Register the driver class:

    • The forName () method of class registers the driver class

    • Method dynamically loads the driver class.

  • Create the connection object:

    • The getConnection () method of DriverManager class establishes connection with the database.
  • Create the statement object:

    • The createStatement () method of connection interface is used to create a SQL statement.

    • Object of the statement executes queries with the database.

  • Execute the query:

    • The executeQuery () method of statement interface executes queries to the database.

    • This method returns object of ResultSet which can get all the records of a table.

  • Close the connection object:

    • This is when statement and Result set will be closed automatically.

    • The close () method of connection interface closes the connection.