Pages

Sunday, 1 March 2015

JAVA QUESTIONS

What are the types of statements in JDBC?
The JDBC API has 3 Interfaces,
·        Statement,
·        PreparedStatement,
·        CallableStatement
 The key features of these are as follows:
Statement
This interface is used for executing a static SQL statement and returning the results it produces.
The object of Statement class can be created using Connection.createStatement() method.
PreparedStatement
A SQL statement is pre-compiled and stored in a PreparedStatement object.
This object can then be used to efficiently execute this statement multiple times.
The object of PreparedStatement class can be created using Connection.prepareStatement() method. This extends Statement interface.
CallableStatement
This interface is used to execute SQL stored procedures.
This extends PreparedStatement interface.
The object of CallableStatement class can be created using Connection.prepareCall() method.

What is Connection pooling? What are the advantages of using a connection pool?
Connection Pooling is a technique used for sharing the server resources among requested clients. It was pioneered by database vendors to allow multiple clients to share a cached set of connection objects that provides access to a database.
Getting connection and disconnecting are costly operation, which affects the application performance, so we should avoid creating multiple connection during multiple database interactions. A pool contains set of Database connections which are already connected, and any client who wants to use it can take it from pool and when done with using it can be returned back to the pool.

Apart from performance this also saves you resources as there may be limited database connections available for your application.

Saturday, 28 February 2015

Testing Concepts

15. What are the Structure-based (white-box) testing techniques?
Structure-based testing techniques (which are also dynamic rather than static) use the internal structure of the software to derive test cases. They are commonly called 'white-box' or 'glass-box' techniques (implying you can see into the system) since they require knowledge of how the software is implemented, that is, how it works.
For example, a structural technique may be concerned with exercising loops in the software. Different test cases may be derived to exercise the loop once, twice, and many times. This may be done regardless of the functionality of the software.

16. What are the Experience-based testing techniques?
In experience-based techniques, people's knowledge, skills and background are a prime contributor to the test conditions and test cases. The experience of both technical and business people is important, as they bring different perspectives to the test analysis and design process.
Due to previous experience with similar systems, they may have insights into what could go wrong, which is very useful for testing.






Java Questions

What is the Difference between Enumeration and Iterator interface?
Enumeration and Iterator are the interface available in java.util package. The functionality of Enumeration interface is duplicated by the Iterator interface. New implementations should consider using Iterator in preference to Enumeration.
Iterators differ from enumerations in following ways:
Enumeration contains 2 methods namely
·        hasMoreElements()
·        nextElement()
whereas Iterator contains three methods namely
·        hasNext(),
·        next(),
·        remove().
Iterator adds an optional remove operation, and has shorter method names. Using remove() we can delete the objects but Enumeration interface does not support this feature.
Enumeration interface is used by legacy classes. Vector.elements() & Hashtable.elements() method returns Enumeration. Iterator is returned by all Java Collections Framework classes. java.util.Collection.iterator() method returns an instance of Iterator.

What are transient variables? What role do they play in Serialization process?
The transient keyword in Java is used to indicate that a field should not be serialized. Once the process of de-serialization is carried out, the transient variables do not undergo a change and retain their default value. Marking unwanted fields as transient can help you boost the serialization performance.

Friday, 27 February 2015

Testing Concepts

13. Consider the following techniques. Which are static and which are dynamic techniques?
Equivalence Partitioning.
Use Case Testing.
Data Flow Analysis.
Exploratory Testing.
Decision Testing.
Inspections.
Data Flow Analysis and Inspections are static; Equivalence Partitioning, Use Case Testing, Exploratory Testing and Decision Testing are dynamic.
14. What is the role of moderator in review process?
The moderator (or review leader) leads the review process. He or she determines, in co-operation with the author, the type of review, approach and the composition of the review team.
The moderator performs the entry check and the follow-up on the rework, in order to control the quality of the input and output of the review process.
The moderator also schedules the meeting, disseminates documents before the meeting, coaches other team members, paces the meeting, leads possible discussions and stores the data that is collected.


JAVA QUESTIONS

What is the difference between java.util.Iterator and java.util.ListIterator?
Iterator : Enables you to traverse through a collection in the forward direction only, for obtaining or removing elements
ListIterator : extends Iterator, and allows bidirectional traversal of list and also allows the modification of elements.
What is Metadata and why should I use it?
JDBC API has 2 Metadata interfaces
·        DatabaseMetaData
·        ResultSetMetaData.
 The DatabaseMetaData provides Comprehensive information about the database as a whole. This interface is implemented by driver vendors to let users know the capabilities of a Database Management System (DBMS) in combination with the driver based on JDBC technology ("JDBC driver") that is used with it. Below is a sample code which demonstrates how we can use the DatabaseMetaData

DatabaseMetaData md = conn.getMetaData();
 System.out.println("Database Name: " + md.getDatabaseProductName());
 System.out.println("Database Version: " + md.getDatabaseProductVersion());
 System.out.println("Driver Name: " + md.getDriverName());
 System.out.println("Driver Version: " + md.getDriverVersion());
The ResultSetMetaData is an object that can be used to get information about the types and properties of the columns in a ResultSet object. Use DatabaseMetaData to find information about your database, such as its capabilities and structure. Use ResultSetMetaData to find information about the results of an SQL query, such as size and types of columns. Below a sample code which demonstrates how we can use the ResultSetMetaData
ResultSet rs = stmt.executeQuery("SELECT a, b, c FROM TABLE2");
     ResultSetMetaData rsmd = rs.getMetaData();
     int numberOfColumns = rsmd.getColumnCount();

     boolean b = rsmd.isSearchable(1);

Thursday, 26 February 2015

Testing concepts

11. What is random/monkey testing? When it is used?

Random testing often known as monkey testing. In such type of testing data is generated randomly often using a tool or automated mechanism. With this randomly generated input the system is tested and results are analyzed accordingly. These testing are less reliable; hence it is normally used by the beginners and to see whether the system will hold up under adverse effects.

12. Which of the following are valid objectives for incident reports?

Provide developers and other parties with feedback about the problem to enable identification, isolation and correction as necessary.
Provide ideas for test process improvement.
Provide a vehicle for assessing tester competence.
Provide testers with a means of tracking the quality of the system under test. 








JAVA QUESTIONS

What is the difference between creating String as new() and literal?
When we create string with new() Operator, it’s created in heap and not added into string pool while String created using literal are created in String pool itself which exists in PermGen area of heap.
String s = new String("Test");
does not  put the object in String pool , we need to call String.intern() method which is used to put  them into String pool explicitly. its only when you create String object as String literal e.g. String s = "Test" Java automatically put that into String pool.
What does Class.forName() method do?
Method forName() is a static method of java.lang.Class. This can be used to dynamically load a class at run-time. Class.forName() loads the class if its not already loaded. It also executes the static block of loaded class. Then this method returns an instance of the loaded class. So a call to Class.forName('MyClass') is going to do following
·        Load the class MyClass.
·        Execute any static block code of MyClass.
·        Return an instance of MyClass.

JDBC Driver loading using Class.forName is a good example of best use of this method. The driver loading is done like this
Class.forName("org.mysql.Driver");
All JDBC Drivers have a static block that registers itself with DriverManager and DriverManager has static initializer method registerDriver() which can be called in a static blocks of Driver class. A MySQL JDBC Driver has a static initializer which looks like this:
static {
    try {
        java.sql.DriverManager.registerDriver(new Driver());
    } catch (SQLException E) {
        throw new RuntimeException("Can't register driver!");
    }
}
Class.forName() loads driver class and executes the static block and the Driver registers itself with the DriverManager.