Friday, August 3, 2012

What is the difference between array and hash (associative array) in Perl?

An array is a list of ordered items where as a hash is a set of key-value pairs of unordered items.
To be precise, hash is for mapping and arrays for ordering. Numerically indexed array is more efficient than that of the hash lookup.Hash is slower than array.

If you have things in a line or ordered or in a sequence, use an array. For instance:
- A list of files to read
- A list of people in a queue

If you have a bag of unordered things to look up, use a hash. For example:
- An index of last names, looked up by first name
- An index showing the size of files, looked up by name

What is difference CTLIB and DBLIB?

 An important difference between CTlib and DBlib lies in how the SYBASE environment variable
is handled. DBlib only checks for the SYBASE variable when it requires access to the interfaces file. This allows for definition of the SYBASE variable in the script. CTlib requires the SYBASE variable to be defined BEFORE initialization. If the variable is not defined then CTlib will not initialize properly and the script won't run.

Wednesday, August 1, 2012

What is the difference between "Sybase::BCP" and "Sybase::BLK"?

"Sybase::BCP" is based on "Sybase::CTlib" whereas "Sybase::BLK" on "Sybase::DBlib" though both serves as a simplified front end for Sybase's Bulk Copy library.

What is the maximum number of Index per table in MS SQL Server?

For SQL Server 2005:
 1 Clustered Index + 249 Nonclustered Index = 250 Index
For SQL Server 2008:
 1 Clustered Index + 999 Nonclustered Index = 1000 Index

What is the generic or full syntax of SELECT statement?

SELECT select_list
[ INTO new_table ]
FROM table_source
[ WHERE search_condition ]
[ GROUP BY group_by_expression ]
[ HAVING search_condition ]
[ ORDER BY order_expression [ ASC | DESC ] ]

What is the difference between Clustered and Non-Clustered Index?

Clustered Index
 - describes the order wherein the records are physically stored
 - only one per table
 - faster to read as data is physically stored in index order
 - to enhance insert & update, clustered indexes should be set on a field that is normally incremental i.e. Id or Timestamp

Non Clustered Index
 - defines a logical order that does not match the physical order on disk
 - can be used many times per table
 - quicker for insert and update operations than a clustered index

Can we have a Virtual Constructor?

A constructor assigns value to variables at compile time and the virtual table is created on the fly.
So it is impossible to a have a virtual constructor since the time a constructor is invoked the vtable won't be available in memory;

When does a Copy Constructor get invoked?

The following cases give rise to call a copy constructor:
 1. When an object is returned by value
 2. When an object is passed (to a function) by value as an argument
 3. When an object is thrown
 4 .When an object is caught
 5 .When an object is placed in a brace-enclosed initializer list

How do you debug specific block of code in shell scripting?

You can mention the block of code within "set -x" and "set +x" command. For example :

#!/usr/bin/sh

echo "Welcome"
set -x
echo "Rabindra!"
echo "Nayak"
set +x
echo " to the world!"

What and why are the operators that can't be overloaded?

We can't overload the 'sizeof', ':?', '::', '.' and '.*' operators in C++ since they take name as their argument whereas all other operators take value as argument.