1) Name the four basic data types in “C” language?
The four basic data types in “c” language are as follows
(i) Char
(ii) Int
(iii) Float
(iv) Double
2) Describe at least five different format specifiers?
%d: -An integer whole number
%f: -a floating point number
%c: -a single character
%p: -a machine memory address
3) Define and explain scanf () function?
The Scanf () function can be used to get input into a program and it requires two arguments. First a format specifier defines the type of data to be entered, then the name of the variable in which the input will be stored. This scanf () function is responsible for giving input into the program.
4) What are the maximum and minimum possible ranges of values for long and short type?
If the int variable is created by default as a ‘long’ type it typically will have a possible range of values from a maximum of +214748347 and a minimum of -2147483648. For ‘short’ type these are the maximum and minimum values +327676 and minimum -32768.
(While answering this question you can specify the approximate value raised to power).
5) What exactly is a ‘variable scope’, ‘local variables’ and ‘global variables’?
The extent to which a variable is accessible in a program is called the ‘variable scope’.
Variables declared internally inside a function are known as ‘local’ variables.
Variables declared externally outside a function are known as ‘global’ variables.
6) What are signed values?
When an int variable is declared it can by default contain either positive of negative integer values. These are known as ‘signed’ values. The range of positive values is determined by your system.
7) Explain about register variables relative to compiler?
A register variable declaration informs the compiler that the specified variable will be heavily used by the program. The intention is for the compiler to place register variables in the machine register of the computer to speed access times. Local internal variables can only be declared as register variables.
8) State some significant uses of arrays in C programming?
One of the most significant uses of arrays in c programming concerns with their ability to store strings of text. Each element in an array of the char data type can store a single character. Adding the special null character escape sequence in the arrays final element promotes the array to string. It can be referenced using the array name and can be displayed using the %s format specifier.
9) What is enum used for and state its format?
The enum keyword provides a handy way to create a sequence of integer constants in a concise manner. Optionally the declaration can include a name for the sequence after the enum keyword. The constant names follow with a comma and placed within braces. The name assigned can be used to call the function again at later stage. The constants can be assigned any individual value but the following constant will always increment it by one.
10) Explain about the constants which help in debugging?
A #if directive test can be offered with #else and #else if directives. This allows conditional branching of the program to run sections of the code according to the result. Constants defined with a #define directive can be undefined with the #undef directive. The #ifdef directive has a companion directive #ifndef. These commands can be useful when debugging problem code to hide and unhide sections of the program.
11) Define and explain about! Operator?
The logical operator! NOT is a unary operator that is used before a single operand. It returns the inverse value of the given operand so if the variable “c” had a value of true then! C would return value of false. The not operator is very much useful in C programs because it can change the value of variables with successful iterations. This ensures that on each pass the value is changed.
12) What is operator precedence?
Operator precedence defines the order in which C evaluates expressions.
e.g. in the expression a=6+b*3, the order of precedence determines whether the addition or the multiplication is completed first. Operators on the same row have equal precedence.
13) Explain about the functions strcat() and strcmp()?
This function concatenates the source string at the end of the target string. Strcmp() function compares two strings to find out whether they are the same or different. The two strings are compared character by character until there is a mismatch or end of one of the strings is reached, whichever occurs first. If in case two strings are identical, a value of zero is returned. If there is no matches between two strings then a difference of the two non matching values are returned according to ASCII values.
14) Why do we use structures?
We use structures for different purposes which are
1) Construct individual arrays
E.g. 1) one array for storing names, another array for storing prices, and another for storing number of pages.
2) Use a structure variable.
A structure contains a number of data types grouped together. These data types may or may not be of the same type.
15) State the difference between sprint () and sscanf() Functions?
The sprint() function works similar to the printf() function except for one small difference, instead of sending the output to the screen as printf() does, this function writes the output to an array of characters. Once str has been built, its contents can be displayed on the screen.
16) How do you write data to low level disk I/O?
In low level disk I/O, data cannot be written as individual characters, or as strings or as formatted data. There is only one way data can be written to read in low level disk I/O functions as buffer full of bytes. Writing a buffer full of data resembles the fwrite() function.
17) Define these functions fopen(), fread(), fwrite() and fseek()?
Fopen(): - On opening a file, a pointer is set up which points to the first record in the file.
Fread(): - The pointer moves to the next record while reading a file. It always reads the file where the pointer is pointed.
Fwrite(): -The pointer moves to the beginning of the next record on closing the file the pointer is deactivated. This pointer writes the record where the pointer is currently places.
Fseek(): - Function lets us move the pointer from one record to another.
18) State the difference between Unions and structures?
Both structures and unions are used to group a number of different variables together. But while a structure enables us treat a number of different variables stored at different places in memory, a union enables us to treat the same space in memory as a number of different variables.
19) What are the different styles present in WS_OVERLAPPEDWINDOW?
The different styles present in windows are WS_OVERLAPPED, WS_CAPTION, WS_THICKFRAME, WS_MINIMIZEBOX, and WS_MAXIMIZEBOX.
All these macros are #defined in the ‘windows.h’ header file.
20) What are the rules for constructing real constants?
Real constants are often called Floating point constants. The real constants could be written in two forms fractional form and exponential form.
These are the following rules while constructing real constants
1) A real constant must have at least one digit
2) It must have a decimal point
3) It could be wither positive or negative
4) Default sign is positive
5) No commas or blanks are allowed within a real constant.
c,c++(Part-III) interview question and answers
Q. What is an incomplete type?
Answer: Incomplete types refers to pointers in which there is non availability of the implementation of the referenced location or it points to some location whose value is not available for modification.
Example:
int *i=0x400 // i points to address 400
*i=0; //set the value of memory location pointed by i.
Incomplete types are otherwise called uninitialized pointers.
Q. What is a dangling pointer?
Answer: A dangling pointer arises when you use the address of an object after its lifetime is over. This may occur in situations like returning addresses of the automatic variables from a function or using the address of the memory block after it is freed.
Q. Differentiate between the message and method.
Answer:
Message Method
Objects communicate by sending messages Provides response to a message.
to each other.
A message is sent to invoke a method. It is an implementation of an operation.
Q. What is an adaptor class or Wrapper class?
Answer: A class that has no functionality of its own. Its member functions hide the use of a third party software component or an object with the non-compatible interface or a non- object- oriented implementation.
Q. What is a Null object?
Answer: It is an object of some class whose purpose is to indicate that a real object of that class does not exist. One common use for a null object is a return value from a member function that is supposed to return an object with some specified properties but cannot find such an object.
Q. What is a Null object?
Answer: It is an object of some class whose purpose is to indicate that a real object of that class does not exist. One common use for a null object is a return value from a member function that is supposed to return an object with some specified properties but cannot find such an object.
Q. What is class invariant?
Answer: A class invariant is a condition that defines all valid states for an object. It is a logical condition to ensure the correct working of a class. Class invariants must hold when an object is created, and they must be preserved under all operations of the class. In particular all class invariants are both preconditions and post-conditions for all operations or member functions of the class.
Q. What do you mean by Stack unwinding?
Answer: It is a process during exception handling when the destructor is called for all local objects between the place where the exception was thrown and where it is caught.
Q. Define precondition and post-condition to a member function.
Answer:
Precondition: A precondition is a condition that must be true on entry to a member function. A class is used correctly if preconditions are never false. An operation is not responsible for doing anything sensible if its precondition fails to hold.
For example, the interface invariants of stack class say nothing about pushing yet another element on a stack that is already full. We say that isful() is a precondition of the push operation.
Post-condition: A post-condition is a condition that must be true on exit from a member function if the precondition was valid on entry to that function. A class is implemented correctly if post-conditions are never false.
For example, after pushing an element on the stack, we know that isempty() must necessarily hold. This is a post-condition of the push operation.
Q. What are the conditions that have to be met for a condition to be an invariant of the class?
Answer:
The condition should hold at the end of every constructor.
The condition should hold at the end of every mutator(non-const) operation.
Q. What are proxy objects?
Answer:
Objects that stand for other objects are called proxy objects or surrogates.
Example:
template
class Array2D
{
public:
class Array1D
{
public:
T& operator[] (int index);
const T& operator[] (int index) const;
...
};
Array1D operator[] (int index);
const Array1D operator[] (int index) const;
...
};
The following then becomes legal:
Array2Ddata(10,20);
........
Answer: Incomplete types refers to pointers in which there is non availability of the implementation of the referenced location or it points to some location whose value is not available for modification.
Example:
int *i=0x400 // i points to address 400
*i=0; //set the value of memory location pointed by i.
Incomplete types are otherwise called uninitialized pointers.
Q. What is a dangling pointer?
Answer: A dangling pointer arises when you use the address of an object after its lifetime is over. This may occur in situations like returning addresses of the automatic variables from a function or using the address of the memory block after it is freed.
Q. Differentiate between the message and method.
Answer:
Message Method
Objects communicate by sending messages Provides response to a message.
to each other.
A message is sent to invoke a method. It is an implementation of an operation.
Q. What is an adaptor class or Wrapper class?
Answer: A class that has no functionality of its own. Its member functions hide the use of a third party software component or an object with the non-compatible interface or a non- object- oriented implementation.
Q. What is a Null object?
Answer: It is an object of some class whose purpose is to indicate that a real object of that class does not exist. One common use for a null object is a return value from a member function that is supposed to return an object with some specified properties but cannot find such an object.
Q. What is a Null object?
Answer: It is an object of some class whose purpose is to indicate that a real object of that class does not exist. One common use for a null object is a return value from a member function that is supposed to return an object with some specified properties but cannot find such an object.
Q. What is class invariant?
Answer: A class invariant is a condition that defines all valid states for an object. It is a logical condition to ensure the correct working of a class. Class invariants must hold when an object is created, and they must be preserved under all operations of the class. In particular all class invariants are both preconditions and post-conditions for all operations or member functions of the class.
Q. What do you mean by Stack unwinding?
Answer: It is a process during exception handling when the destructor is called for all local objects between the place where the exception was thrown and where it is caught.
Q. Define precondition and post-condition to a member function.
Answer:
Precondition: A precondition is a condition that must be true on entry to a member function. A class is used correctly if preconditions are never false. An operation is not responsible for doing anything sensible if its precondition fails to hold.
For example, the interface invariants of stack class say nothing about pushing yet another element on a stack that is already full. We say that isful() is a precondition of the push operation.
Post-condition: A post-condition is a condition that must be true on exit from a member function if the precondition was valid on entry to that function. A class is implemented correctly if post-conditions are never false.
For example, after pushing an element on the stack, we know that isempty() must necessarily hold. This is a post-condition of the push operation.
Q. What are the conditions that have to be met for a condition to be an invariant of the class?
Answer:
The condition should hold at the end of every constructor.
The condition should hold at the end of every mutator(non-const) operation.
Q. What are proxy objects?
Answer:
Objects that stand for other objects are called proxy objects or surrogates.
Example:
template
class Array2D
{
public:
class Array1D
{
public:
T& operator[] (int index);
const T& operator[] (int index) const;
...
};
Array1D operator[] (int index);
const Array1D operator[] (int index) const;
...
};
The following then becomes legal:
Array2Ddata(10,20);
........
C# (Part-II) interview question and answers
1) Explain about C#?
C # is also known as c sharp. It is a programming language introduced by Microsoft. C# contains features similar to Java and C++. It is specially designed to work with Microsoft .NET platform.
2) Explain about the rules for naming classes in C#?
These are the rules for naming classes in c sharp.
• Must begin with a letter. This letter may be followed by a sequence of letters, digits (0-9), or ‘_’. The first character in a class name cannot be a digit.
• Must not contain any embedded space or symbol like ? - + ! @ # % & * ( ) { } [ ] , : ; ‘ “ \ and/. However an underscore _ can be used wherever a space is required.
• Must not use a keyword for a class name.
3) What are the rules to be followed while naming variables in C#.
The following rules are used for naming variables in C#.
* Must begin with a letter or an underscore _ which may be followed by a sequence of letters, digits (0-9), or ‘_’. The first character in a variable name cannot be a digit.
* Must not contain any embedded space or symbol like ? - + ! @ # % & * ( ) { } [ ] , : ; ‘ “ \ and/. However an underscore _ can be used wherever a space is required.
• Must be unique
• Can have any number of characters
• Keywords cannot be used as variable names.
4) What are the different types of Data?
There are two different types of data supported by C#. They are
1) Value types: -They directly contain data. When you declare an int variable, the system allocates memory to store the value.
2) Reference type: -The reference types do not maintain data but they contain a reference to the variables, which are stored in memory. This means that if the value in the memory location is modified by one of the variables, the other variables automatically reflect the changes value
5) Explain about member functions?
A function is a set of statements that perform a specific task in response to a message. The functions of a class are called member functions in Csharp. Member functions are declared inside the class. The function declaration introduces the function in the class and the function definition contains the function code.
6) Explain about comment entry?
Comments are a part of the program and are used to explain the code. Compilers ignore comment entries. If a comment entry spans more than one line, it has to be enclosed within ‘/*’ and ‘*/’. The symbol ‘//’ treats the rest of code within the same line as a comment.
7) What are operators?
Applications use operators to process the data entered by a user. Operators like + and – are used to process variables and return a value. An operator is a set of one or more characters that is used for computations or comparisons. Operators can transform one or more data values, called operands into a new data value.
8) Explain about the break statement?
A break statement is used to exit the switch statement. This prevents the execution of the remaining case structures by ending the execution of the switch case construct. Each break statement terminates the enclosing switch statement and the flow of control. If none of the cases match the default case is invoked.
9) Define encapsulation?
Encapsulation literally means to enclose in or as if in a capsule. Encapsulation is defined as the process of enclosing one or more items within a physical or logical package. It involves preventing access to nonessential details.
10) Define access specifier with reference to class?
An access specifier defines the scope of a class member. A class member refers to the variables and functions in a class. A program can have one or more classes. You may want some members of a class to be accessible to other classes. But, you may not want some other members of the class to be accessible outside the class.
11) Describe about private access specifier?
The private access specifier allows a class to hide its member variables and member functions from other class objects and functions. Therefore, the private member of a class is not visible outside a class. If a member is declared private, only the functions of that class can access the member. Even the instance of the class cannot access its members
12) Explain about protected internal access specifier?
This specifier allows a class to hide its member variables and member functions to be accessed from other class objects and functions, except the child class, within the application. The protected internal access specifier becomes important while implementing inheritance.
13) Define parameter by value?
Pass by value is the default mechanism for passing parameters to a method. The simplest definition of a value parameter is a data type name followed by a variable name. When a method is called, a new storage location is created for each value parameter. The values of the corresponding expressions are copied into them. The expression supplied for each value parameter must be similar to the declaration of the value parameter.
14) State the methods through which parameters can be passed?
Parameters can be passed by using any one of the following mechanism.
Value: -They are sometimes called in or out parameters; therefore, the data can be transferred into the method but cannot be transferred out.
Reference: -Are sometimes called in or out parameters, therefore, the data can be transferred into the method and out again.
Output: -Are sometimes called out parameters, data can be transferred out of the method.
15) Explain about reference parameter?
A reference parameter is a reference to a memory location of a data member. Unlike a value parameter, a reference parameter does not create a new storage location. Instead a reference parameter represents the same location in memory as the variable that is supplied in the method call.
16) How do you use a structure?
A structure is a value type data type. When you want a single variable to hold related data of various data types, you can create a structure. To create a structure you use the struct keyword.
17) What is an enumerator?
Enumeration is a value data type, which means that enumeration contains its own values and cannot inherit or pass inheritance. Enumerator allows you to assign symbolic names or integral constants.
C # is also known as c sharp. It is a programming language introduced by Microsoft. C# contains features similar to Java and C++. It is specially designed to work with Microsoft .NET platform.
2) Explain about the rules for naming classes in C#?
These are the rules for naming classes in c sharp.
• Must begin with a letter. This letter may be followed by a sequence of letters, digits (0-9), or ‘_’. The first character in a class name cannot be a digit.
• Must not contain any embedded space or symbol like ? - + ! @ # % & * ( ) { } [ ] , : ; ‘ “ \ and/. However an underscore _ can be used wherever a space is required.
• Must not use a keyword for a class name.
3) What are the rules to be followed while naming variables in C#.
The following rules are used for naming variables in C#.
* Must begin with a letter or an underscore _ which may be followed by a sequence of letters, digits (0-9), or ‘_’. The first character in a variable name cannot be a digit.
* Must not contain any embedded space or symbol like ? - + ! @ # % & * ( ) { } [ ] , : ; ‘ “ \ and/. However an underscore _ can be used wherever a space is required.
• Must be unique
• Can have any number of characters
• Keywords cannot be used as variable names.
4) What are the different types of Data?
There are two different types of data supported by C#. They are
1) Value types: -They directly contain data. When you declare an int variable, the system allocates memory to store the value.
2) Reference type: -The reference types do not maintain data but they contain a reference to the variables, which are stored in memory. This means that if the value in the memory location is modified by one of the variables, the other variables automatically reflect the changes value
5) Explain about member functions?
A function is a set of statements that perform a specific task in response to a message. The functions of a class are called member functions in Csharp. Member functions are declared inside the class. The function declaration introduces the function in the class and the function definition contains the function code.
6) Explain about comment entry?
Comments are a part of the program and are used to explain the code. Compilers ignore comment entries. If a comment entry spans more than one line, it has to be enclosed within ‘/*’ and ‘*/’. The symbol ‘//’ treats the rest of code within the same line as a comment.
7) What are operators?
Applications use operators to process the data entered by a user. Operators like + and – are used to process variables and return a value. An operator is a set of one or more characters that is used for computations or comparisons. Operators can transform one or more data values, called operands into a new data value.
8) Explain about the break statement?
A break statement is used to exit the switch statement. This prevents the execution of the remaining case structures by ending the execution of the switch case construct. Each break statement terminates the enclosing switch statement and the flow of control. If none of the cases match the default case is invoked.
9) Define encapsulation?
Encapsulation literally means to enclose in or as if in a capsule. Encapsulation is defined as the process of enclosing one or more items within a physical or logical package. It involves preventing access to nonessential details.
10) Define access specifier with reference to class?
An access specifier defines the scope of a class member. A class member refers to the variables and functions in a class. A program can have one or more classes. You may want some members of a class to be accessible to other classes. But, you may not want some other members of the class to be accessible outside the class.
11) Describe about private access specifier?
The private access specifier allows a class to hide its member variables and member functions from other class objects and functions. Therefore, the private member of a class is not visible outside a class. If a member is declared private, only the functions of that class can access the member. Even the instance of the class cannot access its members
12) Explain about protected internal access specifier?
This specifier allows a class to hide its member variables and member functions to be accessed from other class objects and functions, except the child class, within the application. The protected internal access specifier becomes important while implementing inheritance.
13) Define parameter by value?
Pass by value is the default mechanism for passing parameters to a method. The simplest definition of a value parameter is a data type name followed by a variable name. When a method is called, a new storage location is created for each value parameter. The values of the corresponding expressions are copied into them. The expression supplied for each value parameter must be similar to the declaration of the value parameter.
14) State the methods through which parameters can be passed?
Parameters can be passed by using any one of the following mechanism.
Value: -They are sometimes called in or out parameters; therefore, the data can be transferred into the method but cannot be transferred out.
Reference: -Are sometimes called in or out parameters, therefore, the data can be transferred into the method and out again.
Output: -Are sometimes called out parameters, data can be transferred out of the method.
15) Explain about reference parameter?
A reference parameter is a reference to a memory location of a data member. Unlike a value parameter, a reference parameter does not create a new storage location. Instead a reference parameter represents the same location in memory as the variable that is supplied in the method call.
16) How do you use a structure?
A structure is a value type data type. When you want a single variable to hold related data of various data types, you can create a structure. To create a structure you use the struct keyword.
17) What is an enumerator?
Enumeration is a value data type, which means that enumeration contains its own values and cannot inherit or pass inheritance. Enumerator allows you to assign symbolic names or integral constants.
Perl (Part-I) interview question and answers
1) What are the two different types of data perl handles?
Perl handles two types of data they are
(i) Scalar Variables and
(ii) Lists
Scalar variables hold a single data item whereas lists hold multiple data items.
2) What are scalar variables?
Scalar variables are what many programming languages refer to as simple variables. They hold a single data item, a number, a string, or a perl reference. Scalars are called scalars to differentiate them from constructs that can hold more than one item, like arrays.
3) Explain about lists?
A list is a construct that associates data elements together and you can specify a list by enclosing those elements in parenthesis and separating them with commas. They could themselves be arrays, hashes or even other lists. Lists do not have a specific list data type.
4) Name all the prefix dereferencer in perl?
The symbol that starts all scalar variables is called a prefix dereferencer. The different types of dereferencer are.
(i) $-Scalar variables
(ii) %-Hash variables
(iii) @-arrays
(iv) &-subroutines
(v) Type globs-*myvar stands for @myvar, %myvar.
5) Explain about an ivalue?
An ivalue is an item that can serve as the target of an assignment. The term I value originally meant a “left value”, which is to say a value that appears on the left. An ivalue usually represents a data space in memory and you can store data using the ivalues name. Any variable can serve as an ivalue.
6) How does a “grep” function perform?
Grep returns the number of lines the expression is true. Grep returns a sublist of a list for which a specific criterion is true. This function often involves pattern matching. It modifies the elements in the original list.
7) Explain about Typeglobs?
Type globs are another integral type in perl. A typeglob`s prefix derefrencer is *, which is also the wild card character because you can use typeglobs to create an alias for all types associated with a particular name. All kinds of manipulations are possible with typeglobs.
8) Is there any way to add two arrays together?
Of course you can add two arrays together by using push function. The push function adds a value or values to the end of an array. The push function pushes the values of list onto the end of the array. Length of an array can be increased by the length of list.
9) How to use the command shift?
Shift array function shifts off the first value of the array and returns it, thereby shortening the array by one element and moving everything from one place to the left. If you don’t specify an array to shift, shift uses @ ARGV, the array of command line arguments passed to the script or the array named @-.
10) What exactly is grooving and shortening of the array?
You can change the number of elements in an array simply by changing the value of the last index of/in the array $#array. In fact, if you simply refer to a non existent element in an array perl extends the array as needed, creating new elements. It also includes new elements in its array.
11) What are the three ways to empty an array?
The three different ways to empty an array are as follows
1) You can empty an array by setting its length to a negative number.
2) Another way of empting an array is to assign the null list ().
3) Try to clear an array by setting it to undef, but be aware when you set to undef.
12) How do you work with array slices
An array slice is a section of an array that acts like a list, and you indicate what elements to put into the slice by using multiple array indexes in square brackets. By specifying the range operator you can also specify a slice.
13) What is meant by splicing arrays explain in context of list and scalar.
Splicing an array means adding elements from a list to that array, possibly replacing elements now in the array. In list context, the splice function returns the elements removed from the array. In scalar context, the splice function returns the last element removed.
14) What are the different types of perl operators?
There are four different types of perl operators they are
(i) Unary operator like the not operator
(ii) Binary operator like the addition operator
(iii) Tertiary operator like the conditional operator
(iv) List operator like the print operator
Terms have the highest precedence in perl. Terms include variables, quotes, expressions in parenthesis etc. List operators have the same level of precedence as terms. Specifically, these operators have very strong left word precedence.
16) What is a short circuit operator?
The C-Style operator, ll, performs a logical (or) operation and you can use it to tie logical clauses together, returning an overall value of true if either clause is true. This operator is called a short-circuit operator because if the left operand is true the right operand is not checked or evaluated.
17) What are the different forms of goto in perl? Explain?
The three forms of goto are as follows. They are
(i) Goto label
(ii) Goto name
(iii) Goto expr
The first form, goto LABEL, transfers execution to the statement labeled LABEL. The second form, goto EXPR, expects EXPR to evaluate to a label. The last form goto &name is used with subroutines. This goto statement is used only when there is a necessity as it can create havoc in a program.
18) What are the different types of eval statements?
There are two different types of eval statements they are eval EXPR and eval BLOCK. Eval EXPR executes an expression and eval BLOCK executes BLOCK. Eval Block executes an entire block, BLOCK. First one is used when you want your code passed in the expression and the second one is used to parse the code in the block.
19) Determine the difference between my and local?
The fundamental difference between my and local is that my creates a new variable, whereas local saves a copy of an existing variable.
20) Explain about returning values from subroutines (functions)?
The return value of the subroutine is the value of the last expression evaluated or you can explicitly use a return statement to exit the subroutine specifying the return value. That return value is evaluated in the appropriate content depending on the content of the subroutine call.
Perl handles two types of data they are
(i) Scalar Variables and
(ii) Lists
Scalar variables hold a single data item whereas lists hold multiple data items.
2) What are scalar variables?
Scalar variables are what many programming languages refer to as simple variables. They hold a single data item, a number, a string, or a perl reference. Scalars are called scalars to differentiate them from constructs that can hold more than one item, like arrays.
3) Explain about lists?
A list is a construct that associates data elements together and you can specify a list by enclosing those elements in parenthesis and separating them with commas. They could themselves be arrays, hashes or even other lists. Lists do not have a specific list data type.
4) Name all the prefix dereferencer in perl?
The symbol that starts all scalar variables is called a prefix dereferencer. The different types of dereferencer are.
(i) $-Scalar variables
(ii) %-Hash variables
(iii) @-arrays
(iv) &-subroutines
(v) Type globs-*myvar stands for @myvar, %myvar.
5) Explain about an ivalue?
An ivalue is an item that can serve as the target of an assignment. The term I value originally meant a “left value”, which is to say a value that appears on the left. An ivalue usually represents a data space in memory and you can store data using the ivalues name. Any variable can serve as an ivalue.
6) How does a “grep” function perform?
Grep returns the number of lines the expression is true. Grep returns a sublist of a list for which a specific criterion is true. This function often involves pattern matching. It modifies the elements in the original list.
7) Explain about Typeglobs?
Type globs are another integral type in perl. A typeglob`s prefix derefrencer is *, which is also the wild card character because you can use typeglobs to create an alias for all types associated with a particular name. All kinds of manipulations are possible with typeglobs.
8) Is there any way to add two arrays together?
Of course you can add two arrays together by using push function. The push function adds a value or values to the end of an array. The push function pushes the values of list onto the end of the array. Length of an array can be increased by the length of list.
9) How to use the command shift?
Shift array function shifts off the first value of the array and returns it, thereby shortening the array by one element and moving everything from one place to the left. If you don’t specify an array to shift, shift uses @ ARGV, the array of command line arguments passed to the script or the array named @-.
10) What exactly is grooving and shortening of the array?
You can change the number of elements in an array simply by changing the value of the last index of/in the array $#array. In fact, if you simply refer to a non existent element in an array perl extends the array as needed, creating new elements. It also includes new elements in its array.
11) What are the three ways to empty an array?
The three different ways to empty an array are as follows
1) You can empty an array by setting its length to a negative number.
2) Another way of empting an array is to assign the null list ().
3) Try to clear an array by setting it to undef, but be aware when you set to undef.
12) How do you work with array slices
An array slice is a section of an array that acts like a list, and you indicate what elements to put into the slice by using multiple array indexes in square brackets. By specifying the range operator you can also specify a slice.
13) What is meant by splicing arrays explain in context of list and scalar.
Splicing an array means adding elements from a list to that array, possibly replacing elements now in the array. In list context, the splice function returns the elements removed from the array. In scalar context, the splice function returns the last element removed.
14) What are the different types of perl operators?
There are four different types of perl operators they are
(i) Unary operator like the not operator
(ii) Binary operator like the addition operator
(iii) Tertiary operator like the conditional operator
(iv) List operator like the print operator
Terms have the highest precedence in perl. Terms include variables, quotes, expressions in parenthesis etc. List operators have the same level of precedence as terms. Specifically, these operators have very strong left word precedence.
16) What is a short circuit operator?
The C-Style operator, ll, performs a logical (or) operation and you can use it to tie logical clauses together, returning an overall value of true if either clause is true. This operator is called a short-circuit operator because if the left operand is true the right operand is not checked or evaluated.
17) What are the different forms of goto in perl? Explain?
The three forms of goto are as follows. They are
(i) Goto label
(ii) Goto name
(iii) Goto expr
The first form, goto LABEL, transfers execution to the statement labeled LABEL. The second form, goto EXPR, expects EXPR to evaluate to a label. The last form goto &name is used with subroutines. This goto statement is used only when there is a necessity as it can create havoc in a program.
18) What are the different types of eval statements?
There are two different types of eval statements they are eval EXPR and eval BLOCK. Eval EXPR executes an expression and eval BLOCK executes BLOCK. Eval Block executes an entire block, BLOCK. First one is used when you want your code passed in the expression and the second one is used to parse the code in the block.
19) Determine the difference between my and local?
The fundamental difference between my and local is that my creates a new variable, whereas local saves a copy of an existing variable.
20) Explain about returning values from subroutines (functions)?
The return value of the subroutine is the value of the last expression evaluated or you can explicitly use a return statement to exit the subroutine specifying the return value. That return value is evaluated in the appropriate content depending on the content of the subroutine call.
c,c++(Part-II) interview question and answers
Q. Name some pure object oriented languages.
Answer:
Smalltalk,
Java,
Eiffel,
Sather.
Q. Name the operators that cannot be overloaded.
Answer:
sizeof . .* .-> :: ?:
Q. What is a node class?
Answer:
A node class is a class that,
relies on the base class for services and implementation,
provides a wider interface to te users than its base class,
relies primarily on virtual functions in its public interface
depends on all its direct and indirect base class
can be understood only in the context of the base class
can be used as base for further derivation
can be used to create objects.
A node class is a class that has added new services or functionality beyond the services inherited from its base class.
Q. What is an orthogonal base class?
Answer: If two base classes have no overlapping methods or data they are said to be independent of, or orthogonal to each other. Orthogonal in the sense means that two classes operate in different dimensions and do not interfere with each other in any way. The same derived class may inherit such classes with no difficulty.
Q. What is a container class? What are the types of container classes?
Answer: A container class is a class that is used to hold objects in memory or external storage. A container class acts as a generic holder. A container class has a predefined behavior and a well-known interface. A container class is a supporting class whose purpose is to hide the topology used for maintaining the list of objects in memory. When a container class contains a group of mixed objects, the container is called a heterogeneous container; when the container is holding a group of objects that are all the same, the container is called a homogeneous container.
Q. What is a protocol class?
Answer: An abstract class is a protocol class if:
it neither contains nor inherits from classes that contain member data, non-virtual functions, or private (or protected) members of any kind.
it has a non-inline virtual destructor defined with an empty implementation,
all member functions other than the destructor including inherited functions, are declared pure virtual functions and left undefined.
Q. What is a mixin class?
Answer: A class that provides some but not all of the implementation for a virtual base class is often called mixin. Derivation done just for the purpose of redefining the virtual functions in the base classes is often called mixin inheritance. Mixin classes typically don't share common bases.
Q. What is a concrete class?
Answer: A concrete class is used to define a useful object that can be instantiated as an automatic variable on the program stack. The implementation of a concrete class is defined. The concrete class is not intended to be a base class and no attempt to minimize dependency on other classes in the implementation or behavior of the class.
Q.What is the handle class?
Answer: A handle is a class that maintains a pointer to an object that is programmatically accessible through the public interface of the handle class.
Explanation:
In case of abstract classes, unless one manipulates the objects of these classes through pointers and references, the benefits of the virtual functions are lost. User code may become dependent on details of implementation classes because an abstract type cannot be allocated statistically or on the stack without its size being known. Using pointers or references implies that the burden of memory management falls on the user. Another limitation of abstract class object is of fixed size. Classes however are used to represent concepts that require varying amounts of storage to implement them.
A popular technique for dealing with these issues is to separate what is used as a single object in two parts: a handle providing the user interface and a representation holding all or most of the object's state. The connection between the handle and the representation is typically a pointer in the handle. Often, handles have a bit more data than the simple representation pointer, but not much more. Hence the layout of the handle is typically stable, even when the representation changes and also that handles are small enough to move around relatively freely so that the user needn’t use the pointers and the references.
Q. What is an action class?
Answer: The simplest and most obvious way to specify an action in C++ is to write a function. However, if the action has to be delayed, has to be transmitted 'elsewhere' before being performed, requires its own data, has to be combined with other actions, etc then it often becomes attractive to provide the action in the form of a class that can execute the desired action and provide other services as well. Manipulators used with iostreams is an obvious example.
Explanation:
A common form of action class is a simple class containing just one virtual function.
class Action
{
public:
virtual int do_it( int )=0;
virtual ~Action( );
}
Given this, we can write code say a member that can store actions for later execution without using pointers to functions, without knowing anything about the objects involved, and without even knowing the name of the operation it invokes. For example:
class write_file : public Action
{
File& f;
public:
int do_it(int)
{
return fwrite( ).suceed( );
}
};
class error_message: public Action
{
response_box db(message.cstr( ),"Continue","Cancel","Retry");
switch (db.getresponse( ))
{
case 0: return 0;
case 1: abort();
case 2: current_operation.redo( );return 1;
}
};
A user of the Action class will be completely isolated from any knowledge of derived classes such as write_file and error_message.
Answer:
Smalltalk,
Java,
Eiffel,
Sather.
Q. Name the operators that cannot be overloaded.
Answer:
sizeof . .* .-> :: ?:
Q. What is a node class?
Answer:
A node class is a class that,
relies on the base class for services and implementation,
provides a wider interface to te users than its base class,
relies primarily on virtual functions in its public interface
depends on all its direct and indirect base class
can be understood only in the context of the base class
can be used as base for further derivation
can be used to create objects.
A node class is a class that has added new services or functionality beyond the services inherited from its base class.
Q. What is an orthogonal base class?
Answer: If two base classes have no overlapping methods or data they are said to be independent of, or orthogonal to each other. Orthogonal in the sense means that two classes operate in different dimensions and do not interfere with each other in any way. The same derived class may inherit such classes with no difficulty.
Q. What is a container class? What are the types of container classes?
Answer: A container class is a class that is used to hold objects in memory or external storage. A container class acts as a generic holder. A container class has a predefined behavior and a well-known interface. A container class is a supporting class whose purpose is to hide the topology used for maintaining the list of objects in memory. When a container class contains a group of mixed objects, the container is called a heterogeneous container; when the container is holding a group of objects that are all the same, the container is called a homogeneous container.
Q. What is a protocol class?
Answer: An abstract class is a protocol class if:
it neither contains nor inherits from classes that contain member data, non-virtual functions, or private (or protected) members of any kind.
it has a non-inline virtual destructor defined with an empty implementation,
all member functions other than the destructor including inherited functions, are declared pure virtual functions and left undefined.
Q. What is a mixin class?
Answer: A class that provides some but not all of the implementation for a virtual base class is often called mixin. Derivation done just for the purpose of redefining the virtual functions in the base classes is often called mixin inheritance. Mixin classes typically don't share common bases.
Q. What is a concrete class?
Answer: A concrete class is used to define a useful object that can be instantiated as an automatic variable on the program stack. The implementation of a concrete class is defined. The concrete class is not intended to be a base class and no attempt to minimize dependency on other classes in the implementation or behavior of the class.
Q.What is the handle class?
Answer: A handle is a class that maintains a pointer to an object that is programmatically accessible through the public interface of the handle class.
Explanation:
In case of abstract classes, unless one manipulates the objects of these classes through pointers and references, the benefits of the virtual functions are lost. User code may become dependent on details of implementation classes because an abstract type cannot be allocated statistically or on the stack without its size being known. Using pointers or references implies that the burden of memory management falls on the user. Another limitation of abstract class object is of fixed size. Classes however are used to represent concepts that require varying amounts of storage to implement them.
A popular technique for dealing with these issues is to separate what is used as a single object in two parts: a handle providing the user interface and a representation holding all or most of the object's state. The connection between the handle and the representation is typically a pointer in the handle. Often, handles have a bit more data than the simple representation pointer, but not much more. Hence the layout of the handle is typically stable, even when the representation changes and also that handles are small enough to move around relatively freely so that the user needn’t use the pointers and the references.
Q. What is an action class?
Answer: The simplest and most obvious way to specify an action in C++ is to write a function. However, if the action has to be delayed, has to be transmitted 'elsewhere' before being performed, requires its own data, has to be combined with other actions, etc then it often becomes attractive to provide the action in the form of a class that can execute the desired action and provide other services as well. Manipulators used with iostreams is an obvious example.
Explanation:
A common form of action class is a simple class containing just one virtual function.
class Action
{
public:
virtual int do_it( int )=0;
virtual ~Action( );
}
Given this, we can write code say a member that can store actions for later execution without using pointers to functions, without knowing anything about the objects involved, and without even knowing the name of the operation it invokes. For example:
class write_file : public Action
{
File& f;
public:
int do_it(int)
{
return fwrite( ).suceed( );
}
};
class error_message: public Action
{
response_box db(message.cstr( ),"Continue","Cancel","Retry");
switch (db.getresponse( ))
{
case 0: return 0;
case 1: abort();
case 2: current_operation.redo( );return 1;
}
};
A user of the Action class will be completely isolated from any knowledge of derived classes such as write_file and error_message.
Delphi(part-I) Interview Questions and answers
1) State and explain about Delphi?
Delphi is a product of Borland international. This powerful language tool is useful to create applications for Windows and it is primarily useful to create client side and server side applications. Cross platform compatibility is also a main feature of Delphi. It is an object oriented language and it is used to create applications with minimal coding.
2) How do you work with INI files in Delphi?
These files are very useful when creating applications under cross platform. These files are very useful to create cross platform applications. Delphi uses .INI format in the form of .dsk file which makes a user to store important information about desktop. Comments can be added by specifying a semicolon. Also they are separated by an equal to sign.
3) How to create UDL files in Delphi?
UDL files are very helpful if you want to store the server connection information outside the application which can be retrieved later during connecting time. This is very useful in creating UDL files which are very helpful where hard coded connection string is not acceptable. Also try to save the documents in the form of .udl which will help you to connect databases easily.
4) How to save binary files in Delphi?
Binary files are saved to Binary large object field which supports data of varying formats and indefinite size. This is in contrast to the file system which stores files of small data types. Binary large object field in Delphi allows changes to be made to data and methods. Loadfromfile class is used to store, manipulate, and transform data.
5) How to save images to a database with Delphi?
DBimage is compatible and can be used to save images with bitmap extension. If you would like to save images of other types then it is advisable to use Timage component which saves images. If you want to save an image at the start first it should be included in the stream and then transform into a database.
6) Explain about creating n tired applications using Delphi?
Using n tired applications you can create applications much faster with a minimal effort. The application server resides in the middle layer and acts as an intermediate between client and database server. Creating a web server in Delphi is a little bit different from other creations of application server.
7) How application server is different from other type of servers?
The only difference from an application server to other types of server is due to the presence of remote data module. Tremotedatamodulecomponent application can be created from the new items dialog box. It uses IAppserversoap interface which makes it possible to connect a client side service applications. Client side connection is sorted in application server.
8) Explain about event handler?
You can use event handlers to make sure that the transactions and operations confirm to the business code of ethic. They can significantly affect the data packets which are being sent out to the server for update. Data packets are very useful in giving critical updates at runtime.
9) Explain about Delphi`s VCL?
Delphi is easier to use rather than the API`s. It has strong windows connection and Borland has made things possible for portability on windows. It has a strong library and it maps windows 32. It supports API`s for properties and events. Borland is taking enough measures for back portability for windows.
10) How do you display & in Delphi?
Delphi has a host of visual controls. If you would like to display and or the ampersand in between two sentences then you have to actually specify && between two sentences whereby Delphi will understand that you are actually specifying and between two sentences and not an accelerator.
11) Explain about the Delphi IDE?
Delphi has a very sophisticated drag and drop controls. With Delphi IDE you can create rich applications for windows. With its IDE you can compile, debug, and design your projects. It has a main window which has lots and lots of buttons which perform different functions on your project. Through this main window you give title to your project. There is also a component section through which you can select different component functions which can perform various task.
12) What are packages in Delphi?
Packages can make the size of your program (.exe) much smaller. Borland package libraries are dll files which provide extension for programs so that they can be executed. When you specify a certain extension to a program, it makes your hard disk to locate those types of files very easily. Packages contain Delphi components which are visual and easy to operate.
13) Explain about the textual description of the form?
This form describes the properties, properties of the components and the components for itself. This is known as the binary file and this contains description of the different types present. This has been introduced in Delphi 5. On loading this file in the code editor of Delphi makes the program visual in text form. This is not a text file but gives you wrong impression about it being a text form.
14) Explain about DPR?
Apart from two important files (PAS and DFM) there is a third file known as (DPR) or Delphi project file. Delphi project file is automatically built by the compiler. There are two ways to edit the file one is through manually and the other is through Delphi project manager. The source file which you will be seeing is a Pascal source file. All the commands which are describing the file can be seen here.
15) Describe about help file in Delphi?
Help command in Delphi is very resourceful either to a professional or to a beginner. Different properties, functions and methods are listed in the help section for each component. Also the help properties, functions and methods are described in the form of Acrobat adobe reader. There are also tips and hints for programmers which help you in programming Delphi. You can search the help file for different support functions.
16) Describe about the project menu?
This project menu has commands which help you in managing a project. You can add a specific project and also you can remove the project file. Pascal source files can be added as well as removed from the project file. Enterprise edition has two more commands such as web deploy options and web deploy. Syntax check button can make you check the source program of the file.
17) Explain about data base form wizard?
This is one of the important data base wizards in Delphi. This command is available in the Database form wizard section in the forms page. Application wizard and Dialog wizard are also present in Delphi. Two forms appear out of which you have to select one form. You would also have an option to choose from two forms master and beginner.
Delphi is a product of Borland international. This powerful language tool is useful to create applications for Windows and it is primarily useful to create client side and server side applications. Cross platform compatibility is also a main feature of Delphi. It is an object oriented language and it is used to create applications with minimal coding.
2) How do you work with INI files in Delphi?
These files are very useful when creating applications under cross platform. These files are very useful to create cross platform applications. Delphi uses .INI format in the form of .dsk file which makes a user to store important information about desktop. Comments can be added by specifying a semicolon. Also they are separated by an equal to sign.
3) How to create UDL files in Delphi?
UDL files are very helpful if you want to store the server connection information outside the application which can be retrieved later during connecting time. This is very useful in creating UDL files which are very helpful where hard coded connection string is not acceptable. Also try to save the documents in the form of .udl which will help you to connect databases easily.
4) How to save binary files in Delphi?
Binary files are saved to Binary large object field which supports data of varying formats and indefinite size. This is in contrast to the file system which stores files of small data types. Binary large object field in Delphi allows changes to be made to data and methods. Loadfromfile class is used to store, manipulate, and transform data.
5) How to save images to a database with Delphi?
DBimage is compatible and can be used to save images with bitmap extension. If you would like to save images of other types then it is advisable to use Timage component which saves images. If you want to save an image at the start first it should be included in the stream and then transform into a database.
6) Explain about creating n tired applications using Delphi?
Using n tired applications you can create applications much faster with a minimal effort. The application server resides in the middle layer and acts as an intermediate between client and database server. Creating a web server in Delphi is a little bit different from other creations of application server.
7) How application server is different from other type of servers?
The only difference from an application server to other types of server is due to the presence of remote data module. Tremotedatamodulecomponent application can be created from the new items dialog box. It uses IAppserversoap interface which makes it possible to connect a client side service applications. Client side connection is sorted in application server.
8) Explain about event handler?
You can use event handlers to make sure that the transactions and operations confirm to the business code of ethic. They can significantly affect the data packets which are being sent out to the server for update. Data packets are very useful in giving critical updates at runtime.
9) Explain about Delphi`s VCL?
Delphi is easier to use rather than the API`s. It has strong windows connection and Borland has made things possible for portability on windows. It has a strong library and it maps windows 32. It supports API`s for properties and events. Borland is taking enough measures for back portability for windows.
10) How do you display & in Delphi?
Delphi has a host of visual controls. If you would like to display and or the ampersand in between two sentences then you have to actually specify && between two sentences whereby Delphi will understand that you are actually specifying and between two sentences and not an accelerator.
11) Explain about the Delphi IDE?
Delphi has a very sophisticated drag and drop controls. With Delphi IDE you can create rich applications for windows. With its IDE you can compile, debug, and design your projects. It has a main window which has lots and lots of buttons which perform different functions on your project. Through this main window you give title to your project. There is also a component section through which you can select different component functions which can perform various task.
12) What are packages in Delphi?
Packages can make the size of your program (.exe) much smaller. Borland package libraries are dll files which provide extension for programs so that they can be executed. When you specify a certain extension to a program, it makes your hard disk to locate those types of files very easily. Packages contain Delphi components which are visual and easy to operate.
13) Explain about the textual description of the form?
This form describes the properties, properties of the components and the components for itself. This is known as the binary file and this contains description of the different types present. This has been introduced in Delphi 5. On loading this file in the code editor of Delphi makes the program visual in text form. This is not a text file but gives you wrong impression about it being a text form.
14) Explain about DPR?
Apart from two important files (PAS and DFM) there is a third file known as (DPR) or Delphi project file. Delphi project file is automatically built by the compiler. There are two ways to edit the file one is through manually and the other is through Delphi project manager. The source file which you will be seeing is a Pascal source file. All the commands which are describing the file can be seen here.
15) Describe about help file in Delphi?
Help command in Delphi is very resourceful either to a professional or to a beginner. Different properties, functions and methods are listed in the help section for each component. Also the help properties, functions and methods are described in the form of Acrobat adobe reader. There are also tips and hints for programmers which help you in programming Delphi. You can search the help file for different support functions.
16) Describe about the project menu?
This project menu has commands which help you in managing a project. You can add a specific project and also you can remove the project file. Pascal source files can be added as well as removed from the project file. Enterprise edition has two more commands such as web deploy options and web deploy. Syntax check button can make you check the source program of the file.
17) Explain about data base form wizard?
This is one of the important data base wizards in Delphi. This command is available in the Database form wizard section in the forms page. Application wizard and Dialog wizard are also present in Delphi. Two forms appear out of which you have to select one form. You would also have an option to choose from two forms master and beginner.
Subscribe to:
Posts (Atom)