Languages [3i Infotech Placement]: Sample Questions 207 - 209 of 546

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

Question 207

Edit

Write in Short

Short Answer▾

What is the output of the following program?

  1. main ()
  2. {
  3.     inti =5;
  4.     printf (“%d”, i =+ +i == 6);
  5. }

Explanation

In the program

Table Shows the Program
int i = 5;
  • Given the integer variable i = 5
printf ( “% d” , i =+ + i == 6) ;
  • The expression can be treated as i = (++ i == 6) , because == is of higher precedence than = operator.
  • In the inner expression, ++ i is equal to 6 yielding true (1) .

Question 208

Edit

Describe in Detail

Essay▾

What is a structure?

Explanation

Define Structure in C
  • A structure is a user defined data type in C/C ++ .
  • Groups items of possibly different types into a single type.
  • Each element of a structure is called a member.
  • Widely used to store a record - that is collection of related information such as student information, employee information, product information, book information etc.
  • For example, a record of student can consists of student name, address, roll number and age.

SYNATX:

struct structure_name

{

⧵⧵ declaration of different data types

} ;

EXAMPLE:

struct Book

{

char name [15] ;

int price;

int page;

} ;

Question 209

Languages
Edit

Describe in Detail

Essay▾

How java can be connected to a database?

Explanation

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: