First Soft Technologies – Fresher Interview Questions with Answers 

This blog explains about First Soft Technologies – Fresher Interview Questions with Answers and is explained below :


 1 . Difference between throw and throws in Java

There are many differences between throw and throws keywords. A list of differences between throw and throws are given below:

  Throw Throws
1) Java throw keyword is used to explicitly throw an exception. Java throws keyword is used to declare an exception.
2) Checked exception cannot be propagated using throw only. Checked exception can be propagated with throws.
3) Throw is followed by an instance. Throws is followed by class.
4) Throw is used within the method. Throws is used with the method signature.
5) You cannot throw multiple exceptions. You can declare multiple exceptions e.g.
public void method()throws IOException,SQLException.


2. Base class of exception

Catching base and derived classes as exceptions

Exception Handling – catching base and derived classes as exceptions:

If both base and derived classes are caught as exceptions then catch block of derived class must appear before the base class.

If we put base class first then the derived class catch block will never be reached. For example, following C++ code prints “Caught Base Exception”






using namespace std;


class Base {};

class Derived: public Base {};

int main()


   Derived d;

   // some other stuff

   try {

       // Some monitored code

       throw d;


   catch(Base b) { 

        cout<<“Caught Base Exception”;


   catch(Derived d) {  //This catch block is NEVER executed

        cout<<“Caught Derived Exception”;



   return 0;


3. Explain briefly about jdbc ?

JDBC Driver is a software component that enables java application to interact with the database. There are 4 types of JDBC drivers:

1.  JDBC-ODBC bridge driver

2.  Native-API driver (partially java driver)

3.  Network Protocol driver (fully java driver)

4.  Thin driver (fully java driver)

1) JDBC-ODBC bridge driver

The JDBC-ODBC bridge driver uses ODBC driver to connect to the database. The JDBC-ODBC bridge driver converts JDBC method calls into the ODBC function calls. This is now discouraged because of thin driver.

2) Native-API driver

The Native API driver uses the client-side libraries of the database. The driver converts JDBC method calls into native calls of the database API. It is not written entirely in java.

3) Network Protocol driver

The Network Protocol driver uses middleware (application server) that converts JDBC calls directly or indirectly into the vendor-specific database protocol. It is fully written in java.

4) Thin driver

The thin driver converts JDBC calls directly into the vendor-specific database protocol. That is why it is known as thin driver. It is fully written in Java language.

4. Explain about packages in java

A java package is a group of similar types of classes, interfaces and sub-packages.

Package in java can be categorized in two form, built-in package and user-defined package.

There are many built-in packages such as java, lang, awt, javax, swing, net, io, util, sql etc.

Here, we will have the detailed learning of creating and using user-defined packages.

Advantage of Java Package

1) Java package is used to categorize the classes and interfaces so that they can be easily maintained.

2) Java package provides access protection.

3) Java package removes naming collision.

Simple example of java package

The package keyword is used to create a package in java.

  1. //save as
  2. packagemypack;  
  3. publicclass Simple{  
  4. public static void main(String args[]){  
  5. out.println(“Welcome to package”);  
  6. }  
  7. }  


5. Describe about connection methods

A Connection is the session between java application and database. The Connection interface is a factory of Statement, PreparedStatement, and DatabaseMetaData i.e. object of Connection can be used to get the object of Statement and DatabaseMetaData. The Connection interface provide many methods for transaction management like commit(), rollback() etc.

Commonly used methods of Connection interface:

1) public Statement createStatement(): creates a statement object that can be used to execute SQL queries.
2) public Statement createStatement(int resultSetType,int resultSetConcurrency): Creates a Statement object that will generate ResultSet objects with the given type and concurrency.
3) public void setAutoCommit(boolean status): is used to set the commit status.By default it is true.
4) public void commit(): saves the changes made since the previous commit/rollback permanent.
5) public void rollback(): Drops all changes made since the previous commit/rollback.
6) public void close(): closes the connection and Releases a JDBC resources immediately.


6.How to implement driver manager

After you’ve installed the appropriate driver, it is time to establish a database connection using JDBC.

The programming involved to establish a JDBC connection is fairly simple. Here are these simple four steps −

  • Import JDBC Packages:Add import statements to your Java program to import required classes in your Java code.
  • Register JDBC Driver:This step causes the JVM to load the desired driver implementation into memory so it can fulfill your JDBC requests.
  • Database URL Formulation:This is to create a properly formatted address that points to the database to which you wish to connect.
  • Create Connection Object:Finally, code a call to the DriverManagerobject’s getConnection( ) method to establish actual database connection.

Import JDBC Packages

The Import statements tell the Java compiler where to find the classes you reference in your code and are placed at the very beginning of your source code.

To use the standard JDBC package, which allows you to select, insert, update, and delete data in SQL tables, add the following imports to your source code −

import java.sql.* ;  // for standard JDBC programsimport

java.math.* ; // for BigDecimal and BigInteger support

Register JDBC Driver

You must register the driver in your program before you use it. Registering the driver is the process by which the Oracle driver’s class file is loaded into the memory, so it can be utilized as an implementation of the JDBC interfaces.

You need to do this registration only once in your program. You can register a driver in one of two ways.