Languages-Java [3i Infotech Placement]: Sample Questions 59 - 61 of 141

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 59


Write in Short

Short Answer▾

When an array is passed it is by


  • An array is passed it is by pointer.
  • When an array is passed to a function, what is being passed is a pointer to the array.
  • In the formal parameter list, we can either specify the parameter an array or a pointer.
  • A function working on an array needs to know where to start and stop.
  • Another way to describe the array is by passing two pointer, with the first indicating the array starts and second array end.
  • The function can alter the value of the pointer itself, making it point to each array element in turn.

Question 60




Object class is a superclass of all other classes?




  • True-All Java classes ultimately descend from object.
  • It brings a common blueprint for all classes and have some list of functions.

Question 61


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.

Developed by: