siva tcs technical questions

Upload: naveen-debbad

Post on 09-Apr-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/8/2019 Siva Tcs Technical Questions

    1/93

    Question

    1. What does static variable mean?2. What is a pointer?3. What are the uses of a pointer?4. What is a structure?5. What is a union?6. What are the differences between structures and union?7. What are the differences between structures and arrays?8. In header files whether functions are declared or defined?9. What are the differences between malloc () and calloc ()?10. What are macros? What are its advantages and disadvantages?11. Difference between pass by reference and pass by12. What is static identifier?13. Where is the auto variables stored?14. Where does global, static, and local, register 15. Difference between arrays and linked list?16. What are enumerations?17. Describe about storage allocation and scope of 18. What are register variables? What are the advantages19. What is the use of typedef?20. Can we specify variable field width in a scanf()21. Out of fgets() and gets() which function is safe to use and why?22. Difference between strdup and strcpy?23. What is recursion?

    24. Differentiate between a for loop and a while loop? What are it uses?25. What is storage class.What are the different storage classes in C?26. What the advantages of using Unions?27. What is the difference between Strings and Arrays?28. What is a far pointer? where we use it?29. What is a huge pointer?30. What is a normalized pointer ,how do we normalize a pointer?31. What is near pointer.32. In C, why is the void pointer useful? When would you use it?33. What is a NULL Pointer? Whether it is same as an uninitialized pointer?34. Are pointers integer ?

    35. What does the error Null Pointer Assignment means and what causes this error?36. What is generic pointer in C?37. Are the expressions arr and &arr same for an array of integers?38. How pointer variables are initialized ?39. What is static memory allocation ?40. What is dynamic memory allocation?41. What is the purpose of realloc ?42. What is pointer to a pointer.

  • 8/8/2019 Siva Tcs Technical Questions

    2/93

    43. What is an array of pointers ?44. Difference between linker and linkage ?45. Is it possible to have negative index in an array?46. Why is it necessary to give the size of an array in an array declaration ?47. What modular programming ?

    48. What is a function ?49. What is an argument ?50. What are built in functions ?51. Difference between formal argument and actual argument ?52. Is it possible to have more than one main() function in a C program ?53. What is the difference between an enumeration and a set of pre-processor # defines?54. How are Structure passing and returning implemented by the complier?55. What is the similarity between a Structure, Union and enumeration?56. Can a Structure contain a Pointer to itself?57. How can we read/write Structures from/to data files?58. Write a program which employs Recursion ?

    59. Write a program which uses Command Line Arguments?60. Difference between array and pointer ?61. What do the c and v in argc and argv stand for?62. What are C tokens ?63. What are C identifiers?64. Difference between syntax vs logical error?65. What is preincrement and post increment ?66. Write a program to interchange 2 variables without using the third one.67. What is the maximum combined length of command line arguments including the space

    between adjacent arguments?68. What are bit fields? What is the use of bit fields in a Structure declaration?69. What is a preprocessor, What are the advantages of preprocessor ?70. What are the facilities provided by preprocessor ?71. What are the two forms of #include directive ?72. How would you use the functions randomize() and random()?73. What do the functions atoi(), itoa() and gcvt() do?74. How would you use the functions fseek(), freed(), fwrite() and ftell()?75. What is the difference between the functions memmove() and memcpy()?76. What is a file ?77. What are the types of file?78. What is a stream ?79. What is meant by file opening ?81. What is a file pointer ?82. How is fopen()used ?83. How is a file closed ?84. What is a random access file ?85. What is the purpose of ftell ?86. What is the purpose of rewind() ?87. Difference between a array name and a pointer variable ?88. Represent a two-dimensional array using pointer ?

  • 8/8/2019 Siva Tcs Technical Questions

    3/93

    89. Difference between an array of pointers and a pointer to an array ?90. Can we use any name in place of argv and argc as command line arguments ?91. What are the pointer declarations used in C?92. Differentiate between a constant pointer and pointer to a constant ?93. Is the allocated space within a function automatically deallocated when the function returns?

    94. Discuss on pointer arithmetic?95. What are the invalid pointer arithmetic ?96. What are the advantages of using array of pointers to string instead of an array of strings?97. Are the expressions *ptr ++ and ++ *ptr same ?98. What would be the equivalent pointer expression foe referring the same element asa[p][q][r][s] ?99. Are the variables argc and argv are always local to main ?100. Can main () be called recursively?101. Can we initialize unions?102. Whats the difference between these two declarations?103. Why doesnt this code: a[i] = i++; work?

    104. Why doesnt struct x { };x thestruct; work?105. Why cant we compare structures?106. How are structure passing and returning implemented?

  • 8/8/2019 Siva Tcs Technical Questions

    4/93

    9. What is a linked list? Ans: A linked list is a linear collection of data elements, called nodes, where the linear order isgiven by pointers. Each node has two parts first part contain the information of the elementsecond part contains the address of the next node in the list.

    1.

    What does static variable mean? Ans: Static variables are the variables which retain their values between the function calls. Theyare initialized only once their scope is within the function in which they are defined.

    2. What is a pointer? Ans: Pointers are variables which stores the address of another variable. That variable may be ascalar (including another pointer), or an aggregate (array or structure). The pointed-to object may

    be part of a larger object, such as a field of a structure or an element in an array.

    3. What are the uses of a pointer? Ans: Pointer is used in the following cases

    i) It is used to access array elementsii) It is used for dynamic memory allocation.iii) It is used in Call by referenceiv) It is used in data structures like trees, graph, linked list etc.

    4. What is a structure? Ans: Structure constitutes a super data type which represents several different data types in asingle unit. A structure can be initialized if it is static or global.

    5. What is a union? Ans: Union is a collection of heterogeneous data type but it uses efficient memory utilization

    technique by allocating enough memory to hold the largest member. Here a single area of memory contains values of different types at different time. A union can never be initialized.

    6. What are the differences between structures and union? Ans: A structure variable contains each of the named members, and its size is large enough tohold all the members. Structure elements are of same size.A union contains one of the named members at a given time and is large enough to hold thelargest member. Union element can be of different sizes.

    7. What are the differences between structures and arrays? Ans: Structure is a collection of heterogeneous data type but array is a collection of homogeneous data types.Array1-It is a collection of data items of same data type.2-It has declaration only3-.There is no keyword.4- array name represent the address of the starting element.Structure 1-It is a collection of data items of different data type.

  • 8/8/2019 Siva Tcs Technical Questions

    5/93

    2- It has declaration and definition3- keyword struct is used4-Structure name is known as tag it is the short hand notation of the declaration.

    8 . In header files whether functions are declared or defined?

    Ans: Functions are declared within header file. That is function prototypes exist in a header file,not function bodies. They are defined in library (lib).

    9. What are the differences between malloc () and calloc ()? Ans: Malloc Calloc 1-Malloc takes one argument Malloc(a);where a number of bytes 2-memoryallocated contains garbage values1-Calloc takes two arguments Calloc(b,c) where b no of object and c size of object2-It initializes the contains of block of memory to zerosMalloc takes one argument, memoryallocated contains garbage values.It allocates contiguous memory locations. Calloc takes two arguments, memory allocatedcontains all zeros, and the memory allocated is not contiguous.

    10 . What are macros? What are its advantages and disadvantages? Ans: Macros are abbreviations for lengthy and frequently used statements. When a macro iscalled the entire code is substituted by a single line though the macro definition is of severallines.The advantage of macro is that it reduces the time taken for control transfer as in case of function.The disadvantage of it is here the entire code is substituted so the program becomeslengthy if a macro is called several t imes.

    11 . Difference between pass by reference and pass by value?

    Ans: Pass by reference passes a pointer to the value. This allows the callee to modify thevariable directly.Pass by value gives a copy of the value to the callee. This allows the callee tomodify the value without modifying the variable. (In other words, the callee simply cannotmodify the variable, since it lacks a reference to it.)

    12 . What is static identifier? Ans: A file-scope variable that is declared static is visible only to functions within that file. Afunction-scope or block-scope variable that is declared as static is visible only within that scope.Furthermore, static variables only have a single instance. In the case of function- or block-scopevariables, this means that the variable is not automatic and thus retains its value acrossfunction invocations.

    13 . Where is the auto variables stored? Ans: Auto variables can be stored anywhere, so long as recursion works. Practically, theyrestored onthe stack. It is not necessary that always a stack exist. You could theoretically allocate functioninvocation records from the heap.

  • 8/8/2019 Siva Tcs Technical Questions

    6/93

    14 . Where does global, static, and local, register variables, free memory and C Programinstructions get stored? Ans: Global: Wherever the linker puts them. Typically the BSS segment on many platforms.Static: Again, wherever the linker puts them. Often, theyre intermixed with the globals. Theonly difference between globals and statics is whether the linker will resolve the symbols across

    compilation units.Local: Typically on the stack, unless the variable gets register allocated andnever spills.Register: Nowadays, these are equivalent to Local variables. They live on the stack unless they get register-allocated.

    15 . Difference between arrays and linked list? Ans: An array is a repeated pattern of variables in contiguous storage. A linked list is a set of structures scattered through memory, held together by pointers in each element that point to thenext element. With an array, we can (on most architectures) move from one element to the next

    by adding a fixed constant to the integer value of the pointer. With a linked list, there is a next pointer in each structure which says what element comes next.

    16.

    What are enumerations? Ans: They are a list of named integer-valued constants. Example:enum color { black , orange=4,yellow, green, blue, violet };This declaration defines the symbols black, orange, yellow,etc. to have the values 1, 4, 5, etc. The difference between an enumeration and a macrois that the enum actually declares a type, and therefore can be type checked.

    17 . Describe about storage allocation and scope of global, extern, static, local and registervariables? Ans: Globals have application-scope. Theyre available in any compilation unit that includes anappropriate declaration (usually brought from a header file). Theyre stored wherever the linker

    puts them, usually a place called the BSS segment.Extern? This is essentially global.Static: Stored the same place as globals, typically, but only available to the compilation unit thatcontains them. If they are block-scope global, only available within that block and its subblocks.Local: Stored on the stack, typically. Only available in that block and its subblocks.(Although pointers to locals can be passed to functions invoked from within a scope where thatlocal is valid.)Register: See tirade above on local vs. register. The only difference is thatthe C compiler will not let you take the address of something youve declared as register.

    18 . What are register variables? What are the advantages of using register variables? Ans: If a variable is declared with a register storage class,it is known as register variable.Theregister variable is stored in the cpu register instead of main memory.Frequently used variablesare declared as register variable as its access time is faster.

    19. What is the use of typedef? Ans: The typedef help in easier modification when the programs are ported to another machine.A descriptive new name given to the existing data type may be easier to understand the code.

  • 8/8/2019 Siva Tcs Technical Questions

    7/93

    20 . Can we specify variable field width in a scanf() format string? If possible how? Ans : All field widths are variable with scanf(). You can specify a maximum field width for agivenfield by placing an integer value between the % and the field type specifier. (e.g. %64s). Such aspecifier will still accept a narrower field width.

    The one exception is %#c (where # is an integer). This reads EXACTLY # characters, and it istheonly way to specify a fixed field width with scanf().

    21 . Out of fgets() and gets() which function is safe to use and why? Ans: fgets() is safer than gets(), because we can specify a maximum input length. Neither one iscompletely safe, because the compiler cant prove that programmer wont overflow the buffer he

    pass to fgets ().

    22 . Difference between strdup and strcpy? Ans: Both copy a string. strcpy wants a buffer to copy into. strdup allocates a buffer usingmalloc().Unlike strcpy(), strdup() is not specified by ANSI .

    25 . What is storage class? What are the different storage classes in C? Ans: Storage class is an attribute that changes the behavior of a variable. It controls the lifetime,scope and linkage. The storage classes in c are auto, register, and extern, static, typedef.

    26 . What the advantages of using Unions? Ans: When the C compiler is allocating memory for unions it will always reserve enough roomfor thelargest member.

    27 . What is the difference between Strings and Arrays? Ans: String is a sequence of characters ending with NULL .it can be treated as a one dimensional

    arrayof characters terminated by a NULL character.

    28 . What is a far pointer? Where we use it? Ans: In large data model (compact, large, huge) the address B0008000 is acceptable because inthesemodel all pointers to data are 32bits long. If we use small data model(tiny, small, medium) theabove address wont work since in these model each pointer is 16bits long. If we are working ina small data model and want to access the address B0008000 then we use far pointer. Far pointer is always treated as a 32bit pointer and contains a segment address and offset address both of 16bits each. Thus the address is represented using segment : offset format B000h:8000h. For anygiven memory address there are many possible far address segment : offset pair. The segmentregister contains the address where the segment begins and offset register contains the offset of data/code from where segment begins.

    29. What is a huge pointer? Ans: Huge pointer is 32bit long containing segment address and offset address. Huge pointersarenormalized pointers so for any given memory address there is only one possible huge address

  • 8/8/2019 Siva Tcs Technical Questions

    8/93

    segment: offset pair. Huge pointer arithmetic is doe with calls to special subroutines so itsarithmetic slower than any other pointers.

    30 . What is a normalized pointer, how do we normalize a pointer? Ans: It is a 32bit pointer, which has as much of its value in the segment register as possible.

    Sincea segment can start every 16bytes so the offset will have a value from 0 to F. for normalization convert the address into 20bit address then use the 16bit for segment address and4bit for the offset address. Given a pointer 500D: 9407,we convert it to a 20bitabsolute address549D7,Which then normalized to 549D:0007.

    31 . What is near pointer? Ans: A near pointer is 16 bits long. It uses the current content of the CS (code segment) register (if the pointer is pointing to code) or current contents of DS (data segment) register (if the pointer is

    pointing to data) for the segment part, the offset part is stored in a 16 bit near pointer. Using near pointer limits the data/code to 64kb segment.

    32 . In C, why is the void pointer useful? When would you use it? Ans: The void pointer is useful because it is a generic pointer that any pointer can be cast intoand

    back again without loss of information.

    33 . What is a NULL Pointer? Whether it is same as an uninitialized pointer? Ans: Null pointer is a pointer which points to nothing but uninitialized pointer may point toanywhere.

    34 . Are pointers integer?

    Ans: No, pointers are not integers. A pointer is an address. It is a positive number.

    35 . What does the error Null Pointer Assignment means and what causes this error? Ans: As null pointer points to nothing so accessing a uninitialized pointer or invalid locationmay cause an error.

    36 . What is generic pointer in C? Ans: In C void* acts as a generic pointer. When other pointer types are assigned to generic

    pointer,conversions are applied automatically (implicit conversion).

    37.

    Are the expressions arr and &arr same for an array of integers? Ans: Yes for array of integers they are same.

    38 . IMP>How pointer variables are initialized? Ans: Pointer variables are initialized by one of the following ways.I. Static memory allocationII. Dynamic memory allocation

  • 8/8/2019 Siva Tcs Technical Questions

    9/93

    39. What is static memory allocation? Ans: Compiler allocates memory space for a declared variable. By using the address of operator,thereserved address is obtained and this address is assigned to a pointer variable. This way of assigning pointer value to a pointer variable at compilation time is known as static memory

    allocation.

    40 . What is dynamic memory allocation? Ans: A dynamic memory allocation uses functions such as malloc() or calloc() to get memorydynamically. If these functions are used to get memory dynamically and the values returned bythese function are assigned to pointer variables, such a way of allocating memory at run time isknown as dynamic memory allocation.

    41 . What is the purpose of realloc? Ans: It increases or decreases the size of dynamically allocated array. The function realloc(ptr,n) uses two arguments. The first argument ptr is a pointer to a block of memory for which

    the size is to be altered. The second argument specifies the new size. The size may be increasedor decreased. If sufficient space is not available to the old region the function may create a newregion.

    42 . What is pointer to a pointer? Ans: If a pointer variable points another pointer value. Such a situation is known as a pointer to a

    pointer.Example:int *p1,**p2,v=10;P1=&v; p2=&p1;Here p2 is a pointer to a pointer.

    43 . What is an array of pointers? Ans: if the elements of an array are addresses, such an array is called an array of pointers.

    44 . Difference between linker and linkage? Ans: Linker converts an object code into an executable code by linking together the necessary

    built infunctions. The form and place of declaration where the variable is declared in a programdetermine the linkage of variable.

    45 . Is it possible to have negative index in an array? Ans: Yes it is possible to index with negative value provided there are data stored in thislocation. Even if it is illegal to refer to the elements that are out of array bounds, the compiler will not produce error because C has no check on the bounds of an array.

    46 . Why is it necessary to give the size of an array in an array declaration? Ans: When an array is declared, the compiler allocates a base address and reserves enough spacein

  • 8/8/2019 Siva Tcs Technical Questions

    10/93

    memory for all the elements of the array. The size is required to allocate the required space andhence size must be mentioned.

    47 . What modular programming? Ans: If a program is large, it is subdivided into a number of smaller programs that are called

    modules or subprograms. If a complex problem is solved using more modules, this approach isknown as modular programming.

    48 . What is a function? Ans: A large program is subdivided into a number of smaller programs or subprograms. Eachsubprogramspecifies one or more actions to be performed for the larger program. Such sub programs arecalled functions.

    49. What is an argument? Ans: An argument is an entity used to pass data from the calling to a called function.

    50 . What are built in functions? Ans: The functions that are predefined and supplied along with the compiler are known as built-in functions. They are also known as library functions.

    51 . Difference between formal argument and actual argument? Ans: Formal arguments are the arguments available in the function definition. They are preceded

    bytheir own data type. Actual arguments are available in the function call. These arguments aregivenas constants or variables or expressions to pass the values to the function.

    52 . Is it possible to have more than one main() function in a C program ? Ans: The function main() can appear only once. The program execution starts from main.

    53 . What is the difference between an enumeration and a set of pre-processor # defines? Ans: There is hardly any difference between the two, except that #defines has a global effect(throughout the file) whereas an enumeration can have an effect local to the block if desired.Some advantages of enumeration are that the numeric values are automatically assigned whereasin #define we have to explicitly define them. A disadvantage is that we have no control over thesize of enumeration variables.

    54.

    How are Structure passing and returning implemented by the complier? Ans: When structures are passed as argument to functions, the entire structure is typically pushed onthe stack. To avoid this overhead many programmer often prefer to pass pointers to structureinstead of actual structures. Structures are often returned from functions in a location pointed to

    by an extra, compiler-supported hidden argument to the function.

  • 8/8/2019 Siva Tcs Technical Questions

    11/93

    55 . IMP>what is the similarity between a Structure, Union and enumeration? Ans: All of them let the programmer to define new data type.

    56 . Can a Structure contain a Pointer to itself? Ans: Yes such structures are called self-referential structures.

    57 . How can we read/write Structures from/to data files? Ans: To write out a structure we can use fwrite() as Fwrite( &e, sizeof(e),1,fp);Where e is astructurevariable. A corresponding fread() invocation can read the structure back from file. callingfwrite() it writes out sizeof(e) bytes from the address &e. Data files written as memory imageswith fwrite(),however ,will not be portable, particularly if they contain floating point fields or Pointers. This is because memory layout of structures is machine and compiler dependent. Therefore, structures written as memory images cannot necessarily be read back by

    programs running on other machine, and this is the important concern if the data files yourewriting will ever be interchanged between machines.

    58 . Write a program which employs Recursion? Ans: int fact(int n) { return n > 1 ? n * fact(n 1) : 1; }

    59. Write a program which uses Command Line Arguments? Ans:

    #includevoid main(int argc,char *argv[]){int i;

    clrscr();for(i=0;i printf(\n%d,argv[i]);}

    60 . Difference between array and pointer? Ans:Array1- Array allocates space automatically2- It cannot be resized3- It cannot be reassigned4- sizeof (arrayname) gives the number of bytes occupied by the array.Pointer 1-Explicitly assigned to point to an allocated space.2-It can be sized using realloc()3-pointer can be reassigned.4-sizeof (p) returns the number of bytes used to store the pointer variable p.

  • 8/8/2019 Siva Tcs Technical Questions

    12/93

    61 . What do the c and v in argc and argv stand for? Ans: The c in argc(argument count) stands for the number of command line argument the

    program isinvoked with and v in argv(argument vector) is a pointer to an array of character stringthat contain the arguments.

    62.

    IMP>what are C tokens? Ans: There are six classes of tokens: identifier, keywords, constants, string literals, operators andother separators.

    63 . What are C identifiers? Ans: These are names given to various programming element such as variables, function,arrays.It is a combination of letter, digit and underscore.It should begin with letter. Backspace isnot allowed.

    64 . Difference between syntax vs logical error? Ans:

    Syntax Error1-These involves validation of syntax of language.2-compiler prints diagnostic message.

    Logical Error 1-logical error are caused by an incorrect algorithm or by a statement mistyped in such a waythat it doesnt violet syntax of language.2-difficult to find.

    65 . What is preincrement and post increment? Ans: ++n (pre increment) increments n before its value is used in an assignment operation or any

    expression containing it. n++ (post increment) does increment after the value of n is used.

    67 . What is the maximum combined length of command line arguments including the spacebetween adjacent arguments? Ans: It depends on the operating system.

    68 . What are bit fields? What is the use of bit fields in a Structure declaration? Ans: A bit field is a set of adjacent bits within a single implementation based storage unit that wewill call a word.The syntax of field definition and access is based on structure.Struct {unsigned int k :1;unsigned int l :1;unsigned int m :1;}flags;the number following the colon represents the field width in bits.Flag is a variable that containsthree bit fields.

  • 8/8/2019 Siva Tcs Technical Questions

    13/93

    69. What is a preprocessor, what are the advantages of preprocessor? Ans: A preprocessor processes the source code program before it passes through the compiler.1- a preprocessor involves the readability of program2- It facilitates easier modification3- It helps in writing portable programs

    4- It enables easier debugging5- It enables testing a part of program6- It helps in developing generalized program

    70 . What are the facilities provided by preprocessor? Ans: 1-file inclusion2-substitution facility3-conditional compilation

    71 . What are the two forms of #include directive?

    Ans: 1.#includefilename2.#includethe first form is used to search the directory that contains the source file.If the search fails in thehome directory it searches the implementation defined locations.In the second form ,the

    preprocessor searches the file only in the implementation defined locations.

    72 . How would you use the functions randomize() and random()? Ans: Randomize() initiates random number generation with a random value.Random() generates random number between 0 and n-1;

    73 . What do the functions atoi(), itoa() and gcvt() do? Ans: atoi() is a macro that converts integer to character.itoa() It converts an integer to stringgcvt() It converts a floating point number to string

    74 . How would you use the functions fseek(), freed(), fwrite() and ftell()? Ans: fseek(f,1,i) Move the pointer for file f a distance 1 byte from location i.fread(s,i1,i2,f) Enter i2 dataitems,each of size i1 bytes,from file f to string s.fwrite(s,i1,i2,f) send i2 data items,each of size i1 bytes from string s to file f.ftell(f) Return the current pointer position within file f.

    The data type returned for functions fread,fseek and fwrite is int and ftell is long int.

    75 . What is the difference between the functions memmove() and memcpy()? Ans: The arguments of memmove() can overlap in memory. The arguments of memcpy()cannot.

  • 8/8/2019 Siva Tcs Technical Questions

    14/93

    76 . What is a file? Ans: A file is a region of storage in hard disks or in auxiliary storage devices.It contains bytes of information .It is not a data type.

    77 . IMP>what are the types of file?

    Ans: Files are of two types1-high level files (stream oriented files) :These files are accessed using library functions2-low level files(system oriented files) :These files are accessed using system calls

    78 . IMP>what is a stream? Ans: A stream is a source of data or destination of data that may be associated with a disk or other I/O device. The source stream provides data to a program and it is known as input stream. Thedestination stream eceives the output from the program and is known as output stream.

    79. What is meant by file opening?

    Ans: The action of connecting a program to a file is called opening of a file. This requirescreatingan I/O stream before reading or writing the data.

    8 0 . What is FILE? Ans: FILE is a predefined data type. It is defined in stdio.h file.

    8 1 . What is a file pointer? Ans: The pointer to a FILE data type is called as a stream pointer or a file pointer. A file pointer

    points to the block of information of the stream that had just been opened.

    82

    .How is fopen()used ? Ans: The function fopen() returns a file pointer. Hence a file pointer is declared and it is

    assignedasFILE *fp;fp= fopen(filename,mode);filename is a string representing the name of the file and the mode represents:r for read operationw for write operationa for append operationr+,w+,a+ for update operation

    8 3 .How is a file closed ? Ans: A file is closed using fclose() functionEg. fclose(fp);Where fp is a file pointer.

    8 4 . What is a random access file? Ans: A file can be accessed at random using fseek() function

  • 8/8/2019 Siva Tcs Technical Questions

    15/93

    fseek(fp,position,origin);fp file pointer

    position number of bytes offset from originorigin 0,1 or 2 denote the beginning ,current position or end of file respectively.

    85

    .What is the purpose of ftell ? Ans: The function ftell() is used to get the current file represented by the file pointer.

    ftell(fp);returns a long integer value representing the current file position of the file pointed by thefile pointer fp.If an error occurs ,-1 is returned.

    8 6 . What is the purpose of rewind() ? Ans: The function rewind is used to bring the file pointer to the beginning of the file.Rewind(fp);Where fp is a file pointer.Also we can get the same effect byfeek(fp,0,0);

    8 7 . Difference between a array name and a pointer variable? Ans: A pointer variable is a variable where as an array name is a fixed address and is not avariable. A

    pointer variable must be initialized but an array name cannot be initialized. An array name beinga constant value , ++ and operators cannot be applied to it.

    8 9. Difference between an array of pointers and a pointer to an array? Ans: Array of pointers1- Declaration is: data_type *array_name[size];

    2-Size represents the row size.3- The space for columns may be dynamically

    Pointers to an array 1-Declaration is data_type ( *array_name)[size];2-Size represents the column size.

    9 0 . Can we use any name in place of argv and argc as command line arguments ? Ans: yes we can use any user defined name in place of argc and argv;

    9 1 . What are the pointer declarations used in C?

    Ans: 1- Array of pointers, e.g , int *a[10]; Array of pointers to integer 2-Pointers to an array,e.g , int (*a)[10]; Pointer to an array of into3-Function returning a pointer,e.g, float *f( ) ; Function returning a pointer to float4-Pointer to a pointer ,e.g, int **x; Pointer to apointer to int5-pointer to a data type ,e.g, char *p; pointer to char

    9 2 . Differentiate between a constant pointer and pointer to a constant?

  • 8/8/2019 Siva Tcs Technical Questions

    16/93

    Ans: const char *p; //pointer to a const character.char const *p; //pointer to a const character.char * const p; //const pointer to a char variable.const char * const p; // const pointer to a const character.

    9 3 . Is the allocated space within a function automatically deallocated when the functionreturns? Ans: No pointer is different from what it points to .Local variables including local pointersvariables in a function are deallocated automatically when function returns.,But in case of alocal pointer variable ,deallocation means that the pointer is deallocated and not the block of memory allocated to it. Memory dynamically allocated always persists until the allocation isfreedor the program terminates.

    9 4 . Discuss on pointer arithmetic?

    Ans: 1- Assignment of pointers to the same type of pointers.2- Adding or subtracting a pointer and an integer.3-subtracting or comparing two pointer.4-incrementing or decrementing the pointers pointing to the elements of an array. When a po inter to an integer is incremented by one , the address is incremented by two. It is done automatically

    by the compiler.5-Assigning the value 0 to the pointer variable and comparing 0 with the pointer. The pointer having address 0 points to nowhere at all.

    9 5 . What is the invalid pointer arithmetic?

    Ans: i) adding ,multiplying and dividing two pointers.ii) Shifting or masking pointer.iii) Addition of float or double to pointer.iv) Assignment of a pointer of one type to a pointer of another type ?

    9 6 . What are the advantages of using array of pointers to string instead of an array of strings? Ans: i) Efficient use of memory.ii) Easier to exchange the strings by moving their pointers while sorting.

    9 7 . Are the expressions *ptr ++ and ++ *ptr same? Ans: No,*ptr ++ increments pointer and not the value pointed by it. Whereas ++ *ptr increments the value being pointed to by ptr.

    9 8 . What would be the equivalent pointer expression foe referring the same element asa[p][q][r][s] ? Ans : *( * ( * ( * (a+p) + q ) + r ) + s)

  • 8/8/2019 Siva Tcs Technical Questions

    17/93

    99. Are the variables argc and argv are always local to main? Ans: Yes they are local to main.

    100 . Can main () be called recursively? Ans: Yes any function including main () can be called recursively.

    101 . IMP>Can we initialize unions? Ans: ANSI Standard C allows an initializer for the first member of a union. There is no standardwayof initializing any other member (nor, under a pre-ANSI compiler, is there generally any way of initializing a union at all).

    102 . Whats the difference between these two declarations? Ans: struct x1 { };typedef struct { } x2;The first form declares a structure tag; the second declares a typedef. The main difference is that

    the second declaration is of a slightly more abstract type.its users dont necessarily know that itis a structure, and the keyword struct is not used when declaring instances of it.

    103 . Why doesnt this code: a[i] = i++; work? Ans: The subexpression i++ causes a side effect.it modifies is value.which leads to undefined

    behavior since i is also referenced elsewhere in the same expression.

    104 .WHy doesnt struct x { };x thestruct;work? Ans:

    C is not C++. Typedef names are not automatically generated for structure tags.

    105 . Why cant we compare structures? Ans: There is no single, good way for a compiler to implement structure comparison which isconsistent with Cs low-level flavor. A simple byte-by-byte comparison could founder onrandom bits present in unused holes in the structure (such padding is used to keep thealignment of later fields correct). A field-by-field comparison might require unacceptableamounts of repetitive code for large structures.

    106 . How are structure passing and returning implemented? Ans: When structures are passed as arguments to functions, the entire structure is typically

    pushed onthe stack, using as many words as are required. Some compilers merely pass a pointer to thestructure, though they may have to make a local copy to preserve pass-by-value semantics.Structures are often returned from functions in a location pointed to by an extra,compiler-supplied hidden argument to the function. Some older compilers used a special,static locationfor structure returns, although this made structure-valued functions non-reentrant, which ANSI Cdisallows.

  • 8/8/2019 Siva Tcs Technical Questions

    18/93

    C++ Questions

    1.What is a class?2.What is an object?3.What is the difference between an object and a class?4.What is the difference between class and structure?5.Define object based programming language ?6.Define object oriented language ?7.Define OOPs?8.What is public, protected, private?9.What is a scope resolution operator?10.What do you mean by inheritance?11.What is abstraction?12.What is encapsulation?13.How variable declaration in c++ differs that in c ?14.What are the c++ tokens ?15.what do you mean by reference variable in c++ ?16.what do you mean by implicit conversion ?17.what is the difference between method overloading and method overriding?18.What are the defining traits of an object-oriented language?19.What is polymorphism ?20.What do you mean by inline function?21 What is the difference between a NULL pointer and a void pointer?22.What is difference between C++ and Java?23.What do you mean by multiple inheritance in C++ ?24.What do you mean by virtual methods ?25.What do you mean by static methods ?26.How many ways are there to initialize an int with a constant?

  • 8/8/2019 Siva Tcs Technical Questions

    19/93

    27.What is constructors?28.What is destructors?29.What is an explicit constructor?30 What is the Standard Template Library?31.What problem does the namespace feature solve?

    32.What is the use of using declaration ?33.What is a template ?34.Differentiate between a template class and class template ?35.What is the difference between a copy constructor and an overloaded assignment operator?36.What is a virtual destructor?37.What is an incomplete type?38.What do you mean by Stack unwinding?39.What is a container class? What are the types of container classes?40.Name some pure object oriented languages ?41.Name the operators that cannot be overloaded ?42.What is an adaptor class or Wrapper class?

    43.What is a Null object?44.What is class invariant?45.What is a dangling pointer?46.Differentiate between the message and method ?47.How can we access protected and private members of a class ?48.Can you handle exception in C++ ?49.What is virtual function ?50.What do you mean by early binding ?51.What do you mean by late binding ?

    c++ interview questions and answers | Part1 July 24th, 2010

    If you would like to view All C++ language interview questions only, at one place, visit belowlink

    All C++ Language Interview Questions

    1. What is a class? Ans: The objects with the same data structure (attributes) and behavior (operations) are calledclass.

    2. What is an object? Ans: It is an entity which may correspond to real-world entities such as students, employees,

    bank account. It may be concrete such as file system or conceptual such as scheduling policies in

  • 8/8/2019 Siva Tcs Technical Questions

    20/93

    multiprocessor operating system.Every object will have data structures called attributes and behavior called operations.

    3. What is the difference between an object and a class? Ans: All objects possessing similar properties are grouped into class.

    Example : person is a class, ram, hari are objects of person class. All have similar attributes likename, age, sex and similar operations like speak, walk.

    Class person{

    private:char name[20];int age;char sex;

    public: speak();walk();

    };

    4. What is the difference between class and structure? Ans: In class the data members by default are private but in structure they are by default public

    5. Define object based programming language? Ans: Object based programming language support encapsulation and object identity withoutsupporting some important features of OOPs language.Object based language=Encapsulation + object Identity

    6. Define object oriented language?

    Ans: Object-oriented language incorporates all the features of object based programminglanguages along with inheritance and polymorphism.Example: c++, java.

    7. Define OOPs? Ans: OOP is a method of implementation in which programs are organized as co-operativecollection of objects, each of which represents an instance of some class and whose classes areall member of a hierarchy of classes united through the property of inheritance.

    8 . What is public, protected, and private? Ans: These are access specifier or a visibility lebels .The class member that has been declared as

    private can be accessed only from within the class. Public members can be accessed from outsidethe class also. Within the class or from the object of a class protected access limit is same as thatof private but it plays a prominent role in case of inheritance

    9. What is a scope resolution operator? Ans: The scope resolution operator permits a program to reference an identifier in the globalscope that has been hidden by another identifier with the same name in the local scope.

  • 8/8/2019 Siva Tcs Technical Questions

    21/93

    10 . What do you mean by inheritance? Ans: The mechanism of deriving a new class (derived) from an old class (base class) is calledinheritance. It allows the extension and reuse of existing code without having to rewrite the codefrom scratch.

    c++ interview questions and answers | Part2 July 24th, 2010

    If you would like to view All C++ language interview questions only, at one place, visit belowlink

    All C++ Language Interview Questions

    11 . What is abstraction? Ans: The technique of creating user-defined data types, having the properties of built-in datatypes and a set of permitted operators that are well suited to the application to be programmed isknown as data abstraction. Class is a construct for abstract data types (ADT).

    12 . What is encapsulation? Ans: It is the mechanism that wraps the data and function it manipulates into single unit andkeeps it safe from external interference.

    13 . How variable declaration in c++ differs that in c? Ans: C requires all the variables to be declared at the beginning of a scope but in c++ we candeclare variables anywhere in the scope. This makes the programmer easier to understand

    because the variables are declared in the context of their use.

    14 . What are the c++ tokens? Ans: c++ has the following tokensI. keywordsII. IdentifiersIII. ConstantsIV. StringsV. operators

    15 . What do you mean by reference variable in c++? Ans: A reference variable provides an alias to a previously defined variable.Data type & reference-name = variable name

  • 8/8/2019 Siva Tcs Technical Questions

    22/93

    16 . What do you mean by implicit conversion? Ans: Whenever data types are mixed in an expression then c++ performs the conversionautomatically.Here smaller type is converted to wider type.Example- in case of integer and float integer is converted into float type.

    17 . What is the difference between method overloading and method overriding? Ans: Overloading a method (or function) in C++ is the ability for functions of the same name to

    be defined as long as these methods have different signatures (different set of parameters).Method overriding is the ability of the inherited class rewriting the virtual method of the baseclass.

    18 . What are the defining traits of an object-oriented language? The defining traits of an object-oriented language are:encapsulationinheritance

    polymorphismAns:Polymorphism: is a feature of OOPL that at run time depending upon the type of object theappropriate method is called.

    Inheritance: is a feature of OOPL that represents the is a relationship between differentobjects (classes). Say in real life a manager is a employee. So in OOPL manger class is inheritedfrom the employee class.

    Encapsulation: is a feature of OOPL that is used to hide the information.

    19.

    What is polymorphism? Ans: Polymorphism is the idea that a base class can be inherited by several classes. A base class pointer can point to its child class and a base class array can store different child class objects.

    20 . What do you mean by inline function? Ans: An inline function is a function that is expanded inline when invoked.ie. the compiler replaces the function call with the corresponding function code. An inline function is a functionthat is expanded in line when it is invoked. That is the compiler replaces the function call withthe corresponding function code (similar to macro).

    c++ interview questions and answers | Part3 July 24th, 2010

    If you would like to view All C++ language interview questions only, at one place, visit belowlink

  • 8/8/2019 Siva Tcs Technical Questions

    23/93

    All C++ Language Interview Questions

    21 What is the difference between a NULL pointer and a void pointer? Ans: A NULL pointer is a pointer of any type whose value is zero. A void pointer is a pointer toan object of an unknown type, and is guaranteed to have enough bits to hold a pointer to any

    object. A void pointer is not guaranteed to have enough bits to point to a function (though ingeneral practice it does).

    22 . What is difference between C++ and Java? Ans: C++ has pointers Java does not.Java is platform independent C++ is not.Java has garbage collection C++ does not.

    23 . What do you mean by multiple inheritance in C++ ? Ans: Multiple inheritance is a feature in C++ by which one class can be of different types. Sayclass teaching Assistant is inherited from two classes say teacher and Student.

    24 . What do you mean by virtual methods? Ans: virtual methods are used to use the polymorphism feature in C++. Say class A is inheritedfrom class B. If we declare say function f() as virtual in class B and override the same function inclass A then at runtime appropriate method of the class will be called depending upon the type of the object.

    25 . What do you mean by static methods? Ans: By using the static method there is no need creating an object of that class to use thatmethod. We can directly call that method on that class. For example, say class A has staticfunction f(), then we can call f() function as A.f(). There is no need of creating an object of class

    A.

    26 . How many ways are there to initialize an int with a constant? Ans: Two.There are two formats for initializers in C++ as shown in the example that follows. The firstformat uses the traditional C notation. The second format uses constructor notation.int foo = 123;int bar (123);

    27 . What is a constructor? Ans: Constructor is a special member function of a class, which is invoked automaticallywhenever an instance of the class is created. It has the same name as its class.

    28 . What is destructor? Ans: Destructor is a special member function of a class, which is invoked automaticallywhenever an object goes out of the scope. It has the same name as its class with a tilde character

    prefixed.

  • 8/8/2019 Siva Tcs Technical Questions

    24/93

    29. What is an explicit constructor? Ans: A conversion constructor declared with the explicit keyword. The compiler does not use anexplicit constructor to implement an implied conversion of types. Its purpose is reservedexplicitly for construction.

    30 What is the Standard Template Library? Ans: A library of container templates approved by the ANSI committee for inclusion in thestandard C++ specification. A programmer who then launches into a discussion of the generic

    programming model, iterators, allocators, algorithms, and such, has a higher than averageunderstanding of the new technology that STL brings to C++ programming.

    c++ interview questions and answers | Part4 July 25th, 2010

    If you would like to view All C++ language interview questions only, at one place, visit belowlink

    All C++ Language Interview Questions

    31 . What problem does the namespace feature solve? Ans: Multiple providers of libraries might use common global identifiers causing a name

    collision when an application tries to link with two or more such libraries. The namespacefeature surrounds a librarys external declarations with a unique namespace that eliminates the potential for those collisions. This solution assumes that two library vendors dont use the samenamespace identifier, of course.

    32 . What is the use of using declaration? Ans: A using declaration makes it possible to use a name from a namespace

    33 . What is a template? Ans: Templates allow us to create generic functions that admit any data type as parameters andreturn a value without having to overload the function with all the possible data types. Untilcertain point they fulfill the functionality of a macro. Its prototype is any of the two followingones:template function_declaration;template function_declaration;

    34 . Differentiate between a template class and class template? Ans: Template class:

  • 8/8/2019 Siva Tcs Technical Questions

    25/93

  • 8/8/2019 Siva Tcs Technical Questions

    26/93

    c++ interview questions and answers | Part5 July 25th, 2010

    If you would like to view All C++ language interview questions only at one place visit belowlink

    All C++ Language Interview Questions

    41 . Name the operators that cannot be overloaded? Ans: sizeof, ., .*, .->, ::, ?:

    42 . What is an adaptor class or Wrapper class? Ans: 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.

    43 . What is a Null object? Ans: It is an object of some class whose purpose is to indicate that a real object of that class doesnot exist. One common use for a null object is a return value from a member function that issupposed to return an object with some specified properties but cannot find such an object.

    44 . What is class invariant? Ans: A class invariant is a condition that defines all valid states for an object. It is a logicalcondition to ensure the correct working of a class. Class invariants must hold when an object iscreated, 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.

    45 . What is a dangling pointer? Ans: 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 functionor using the address of the memory block after it is freed. Example: The following code snippetshows this:class Sample{

    public:

    int *ptr;Sample(int i){

    ptr = new int(i);}~Sample(){delete ptr;

  • 8/8/2019 Siva Tcs Technical Questions

    27/93

    }void PrintVal(){cout

  • 8/8/2019 Siva Tcs Technical Questions

    28/93

    all information needed to call a function is known at compile time. Examples of early bindinginclude normal function calls, overloaded function calls, and overloaded operators. Theadvantage of early binding is efficiency.

    51 . What do you mean by late binding?

    Ans: Late binding refers to function calls that are not resolved until run time. Virtual functionsare used to achieve late binding. When access is via a base pointer or reference, the virtualfunction actually called is determined by the type of object pointed to by the pointer.

    RDBMS Questions

    1. What is a Database?

    2. What is DBMS?3 What is a Catalog?4. What is data ware housing & OLAP?5. What is real time database technology?6. What is program-data independence?7. What is ORDBMS?8. What is program-operation independence?9. What is a view?10. What is OLTP?11. What is the job of DBA?12. Who are db designer?

    13. What are different types of end users?14. What are the advantages of using a dbms?15. What are the disadvantages of using a dbms?16. What is a data model?17. What are different categories of data models?18. What is schema?19. What are types of schema?20. What is Data independency?

  • 8/8/2019 Siva Tcs Technical Questions

    29/93

    21. What are different DBMS languages?22. What are different types of DBMS?23. What is an entity?24. What are attributes?25. What are diff. types of attributes?

    26. What is difference between entity set and entity type?27. What is domain value or value set of an attribute?28. What is degree of a relationship?29. What is recursive relationship?30. What are relationship constraints?31. What is Cardinality ratio?32. What is a Participation constraint?33. What is a weak entity types?34. What is an ER Diagram?35. What is an EER?36. What is specialization?

    38. What is generalization?38. What are constraints on generalization and specialization?39. What is a ternary relationship?40. What is aggregation and association?41. What is RAID Technology?42. What is Hashing technique?43. What are different types of relational constraints?44. What is difference between a super key, a key, a candidate key and a primary key?45. What is a foreign key?46. What is a transaction?47. What are the properties of transaction?48. What are the basic data base operations?49. What are the disadvantages of not controlling concurrency?50. What are serial, non serial?51. What are conflict serializable schedules?52. What is result equivalent?53. What are conflict equivalent schedules?54. What is a conflict serializable schedule?55. What is view equivalence?56. What is view serializable?57. What are the various methods of controlling concurrency?58. What is a lock?59. What are various types of locking techniques?60. What is a binary lock?61. What is shared or exclusive lock?62. What are different types of two phase lockings(2pl)?63. What is a deadlock?64. What are triggers?

  • 8/8/2019 Siva Tcs Technical Questions

    30/93

    DBMS interview questions and answers |

    Part1 July 20th, 2010

    If you would like to view All All DBMS interview questions only, at one place, visit below link All DBMS Interview Questions

    1.What is a Database? Ans: A database is a collection of related data .A database is a logically coherentcollection of data with some inherent meaning.

    2.

    What is DBMS? Ans: Database Management system is a collection of programs that enables user to create andmaintain a database.Thus a DBMS is a general purposed s/w system that facilitates the process of definingconstructing and manipulating a database for various applications. (Defining a data base involvesspecifying the data types, structures and constraints for the data to be stored in the data database.Constructing a data base is the process of storing data itself on some storage medium that is

  • 8/8/2019 Siva Tcs Technical Questions

    31/93

    controlled by DBMS. Manipulating a database includes such functions as querying the data baseto retrieve specific data, updating the database to reflect the changes in the mini-world.

    3. What is a Catalog? Ans: A catalog is a table that contain the information such as structure of each file ,

    the type and storage format of each data item and various constraints on the data .The information stored in the catalog is called Metadata . Whenever a request ismade to access a particular data, the DBMS s/w refers to the catalog to determinethe structure of the file.

    4. What is data ware housing & OLAP? Ans: Data warehousing and OLAP (online analytical processing ) systems are thetechniques used in many companies to extract and analyze useful informationfrom very large databases for decision making .

    5. What is real time database technology?

    Ans: These are all the techniques used in controlling industrial and manufacturing processes.

    6. What is program-data independence? Ans: Unlike in the traditional file sys. the structure of the data files is stored in theDBMS catalog separately from the access programs . This property is called

    program-data independence.i.e. We neednt to change the code of the DBMS if thestructure of the data is changed .Which is not supported by traditional file sys .

    7. What is ORDBMS? Ans: Object oriented RDBMS is a relational DBMS in which every thing is treated as

    objects. User can define operations on data as a part of the database definition.8 . What is program-operation independence? Ans: An operation is specified in two parts .1. Interface (operation name and data types of its arguments).2. Implementation (the code part)The implementation part can be changed without affecting the interface. This is called

    program-operation independence.

    9. What is a view? Ans: A view may be a subset of the database or it may contain virtual data that isderived from the database files but is not explicitly stored .

    10 . What is OLTP? Ans: Online transaction processing is an application that involve multiple database accessesfrom different parts of the world . OLTP needs a multi-user DBMS s/w to ensure that concurrenttransactions operate correctly.

  • 8/8/2019 Siva Tcs Technical Questions

    32/93

    DBMS interview questions and answers |Part2

    July 20th, 2010

    If you would like to view All All DBMS interview questions only, at one place, visit below link All DBMS Interview Questions

    11 . What is the job of DBA? Ans: A database administrator is a person or a group responsible for authorizing access to thedatabase, for coordinating and monitoring its use, and for acquiring s/w and h/w resources asneeded.

    12 . Who are db designer? Ans: Data base designers are responsible for identifying the data to be stored in the database andfor choosing appropriate structure to represent and store this data .

    13 . What are different types of end users? Ans: 1. Casual end-users2. Naive or parametric end users3. Sophisticated end users4. Stand alone users.

    14 . What are the advantages of using a dbms? Ans: 1. Controlling redundancy.2. Restricting unauthorized access.3. Providing persistent storage for program objects and data structures.4. Permitting inferencing and actions using rules.5. Providing multi-user interfaces.6. Representing complex relationships among data.7. Enforcing integrity constraints.8. Providing backups and recovery.

    15 . What are the disadvantages of using a dbms? Ans:1. High initial investments in h/w, s/w, and training.

  • 8/8/2019 Siva Tcs Technical Questions

    33/93

    2. Generality that a DBMS provides for defining and processing data.3. Overhead for providing security, concurrency control, recovery, and integrity functions.

    16 . What is a data model? Ans: It is a collection of concepts that can be used to describe the structure of a database. It

    provides necessary means to achieve this abstraction. By structure of a database we mean thedata types, relations, and constraints that should hold on the data.

    17 . What are different categories of data models? Ans:1. High-level or conceptual data models.2. Representational data models.3. Low-level or physical data models.High level data models provide the concepts that are close to the way many users perceive data.Representational data models are provide concepts that provide the concepts that may beunderstood by end users but that are not too far removed from organization of data in the

    database.Physical data models describe the details of how data is stored in the computers.

    18 . What is schema? Ans: The description of a data base is called the database schema , which is specified duringdatabase design and is not expected to change frequently . A displayed schema is called schemadiagram .We call each object in the schema as schema construct.

    19. What are types of schema? Ans: 1. internal schema.

    2. Conceptual schema.3. External schemas or user views.

    20 . What is Data independency? Ans: Data independency is defined as the capacity to change the conceptual schema withouthaving to change the schema at the next higher level. We can define two types of dataindependence:1. Logical data independence.2. Physical data independence.LDI is the capacity to change the conceptual schema without having to change external schemasor application programs.PDI is the capacity to change the internal schema without having to change conceptual (or external) schemas.

  • 8/8/2019 Siva Tcs Technical Questions

    34/93

    DBMS interview questions and answers |Part3

    July 20th, 2010

    If you would like to view All All DBMS interview questions only, at one place, visit below link All DBMS Interview Questions

    21 . What are different DBMS languages? Ans: 1. DDL (Data definition language)2. SDL (Storage definition language)3. VDL (View definition language)4. DML (Data manipulation language)

    22 . What are different types of DBMS? Ans:1. DBMS2. RDBMS (Relational)3. ORDBMS (Object Relational)4. DDBMS (Distributed)5. FDBMS (Federated)6. HDDBMS (Homogeneous)7. HDBMS (Hierarchical)8. NDBMS (Networked)

    23 . What is an entity? Ans: An entity is a thing in the real world with an independent existence.

    24 . What are attributes? Ans: These are the particular properties that describe an entity.

    25 . What are diff . types of attributes? Ans:1. Composite Vs simple attributes.2. Single valued Vs multi-valued attributes.3. Stored Vs derived attribute.4. Null valued attributes.5. Complex attributes.

    26. What is difference between entity set and entity type?

    27 . What is domain value or value set of an attribute? Ans: It is the set of values that may be assigned to that attribute for each individual entities .

  • 8/8/2019 Siva Tcs Technical Questions

    35/93

    28 . What is degree of a relationship? Ans: The no of entities participating in that relation .

    29. What is recursive relationship? Ans: It is the relationship where both the participating entities belong to same entity type .

    30 . What are relationship constraints?Ans:1. Cardinality ratio . 2. Participation constraints .

    DBMS interview questions and answers |Part4 July 21st, 2010

    If you would like to view All All DBMS interview questions only, at one place, visit below link All DBMS Interview Questions

    31 . What is Cardinality ratio? Ans: The cardinality ratio for a binary relationship specifies the number of relationship instances

    that an entity can participate in.

    32 . What is a Participation constraint? Ans: The participation constraint specifies whether the existence of an entity depends on its

    being related to another entity via the relationship type. This is of two types:1. Total participation.2. Partial participation.

    33 . What is a weak entity types? Ans: The entity types that do not have key attributes of their own are called weak entity types.Rests are called strong entity types .The entity that gives identity to a weak entity is called owner entity. And the relationship is called identifying relationship. A weak entity type always has atotal participation constraint with respect to its identifying relationship.

    34 . What is an ER Diagram? Ans:This data model is based on real world that consists of basic objects called entities and of relationship among these objects. Entities are described in a database by a set of attributes.

  • 8/8/2019 Siva Tcs Technical Questions

    36/93

    35 . What is an EER? Ans:==

    36 . What is specialization?

    Ans: It is the process of defining a set of subclasses of an entity type where each subclasscontain all the attributes and relationships of the parent entity and may have additional attributesand relationships which are specific to itself.

    37 . What is generalization? Ans: It is the process of finding common attributes and relations of a number of entities anddefining a common super class for them.

    38 . What are constraints on generalization and specialization? Ans: 1. disjoint ness constraints.

    2. Completeness constraints.Disjointness constraint specifies that the subclasses of the specialization must be disjoint .i.e. anentity can be a member of at most one of the subclasses of the specialization. The reverse of it isoverlapping.Completeness constraint is a participation constraint which may be1. Total2. PartialTotal specialization constraint tells that each entity in the super class must be a member of somesubclass in the specialization. And partial specialization constraint allows an entity not to belongto any of the subclasses .Thus we do have the following 4 types of constraints on specialization:1. Disjoint, total

    2. Disjoint, partial3. Overlapping, total4. Overlapping, partial

    39. What is a ternary relationship? Ans: A relationship with a degree 3 is called a ternary relationship.

    40 . What is aggregation and association? Ans: Aggregation is an abstraction concept for building composite objects from their componentobjects. The abstraction of association is used to associate objects from several independentclasses.

  • 8/8/2019 Siva Tcs Technical Questions

    37/93

    DBMS interview questions and answers |Part5

    July 21st, 2010

    If you would like to view All All DBMS interview questions only, at one place, visit below link All DBMS Interview Questions

    41 . What is RAID Technology? Ans: Redundant array of inexpensive (or independent) disks. The main goal of raid technology isto even out the widely different rates of performance improvement of disks against those inmemory and microprocessor. Raid technology employs the technique of data striping to achievehigher transfer rates.

    42.

    What is Hashing technique? Ans: This is a primary file organization technique that provides very fast access to records oncertain search conditions. The search condition must be an equality condition on a single field,called hash field of the file.1. Internal hashing2. External hashing3. Extendible hashing4. Linear hashing5. Partitioned hashing

    43 . What are different types of relational constraints?

    Ans: 1. Domain constraints2. Key constraints3. Entity integrity constraints4. Referential integrity constraintsDomain constraints specify that the value of each attribute must be an atomic value from thedomain of the attributes.Key constraints tell that no two tuples can have the same combination of values for all their attributes.Entity integrity constraint states that no primary key value can be null.Referential integrity constraints states that a tuple in one relation that refers to another relationmust refer to an existing tuple in that relation it is specified between two relations and is used tomaintain the consistency among tuples of the two relations.

    44 . What is difference between a super key, a key, a candidate key and a primary key? Ans: A super key specifies a uniqueness constrain that no two distinct tuples in a statecan have the same value for the super key. Every relation has at least one default super key.A key is a minimal super key or the subset of the super key which is obtained after removing redundancy. A relation schema may have more than one key .In this case

  • 8/8/2019 Siva Tcs Technical Questions

    38/93

    each key is called a candidate key. One of the candidate key with minimum number of attributes is chosen as primary key.

    45 . What is a foreign key? Ans: A key of a relation schema is called as a foreign key if it is the primary key of

    some other relation to which it is related to.

    46 . What is a transaction? Ans: A transaction is a logical unit of database processing that includes one or moredatabase access operations.

    47 . What are the properties of transaction? Ans:1. Atomicity2. Consistency preservation3. Isolation

    4. Durability (permanence)

    48 . What are the basic data base operations? Ans: 1. Write_item(x)2. Read_item(x)

    49. What are the disadvantages of not controlling concurrency? Ans: 1. Lost update problem2. Temporary update(Dirty read) problem

    3. Incorrect summary problem

    50 . What are serial, non serial? Ans: A schedule S is serial if, for every transaction T participating in the schedule, all theoperations of T is executed consecutively in the schedule, otherwise, the schedule is called non-serial schedule.

    DBMS interview questions and answers |Part6

    July 21st, 2010

  • 8/8/2019 Siva Tcs Technical Questions

    39/93

    If you would like to view All All DBMS interview questions only, at one place, visit below link All DBMS Interview Questions

    51 . What are conflict serializable schedules? Ans: A schedule S of n transactions is serializable if it is equivalent to some serial schedule of

    the same n transactions.

    52 . What is result equivalent? Ans: Two schedules are called result equivalent if they produce the same final state of the data

    base.

    53 . What are conflict equivalent schedules? Ans: Two schedules are said to be conflict equivalent if the order of any two conflictingoperations is the same in both schedules.

    54 . What is a conflict serializable schedule?

    Ans: A schedule is called conflict serializable if it is conflict equivalent to some serial schedule.

    55 . What is view equivalence? Ans: Two schedules S and S are said to be view equivalent if the following three conditionshold :1. Both S and S contain same set of transactions with same operations in them.2. If any read operation read(x) reads a value written by a write operation or the original value of x the same conditions must hold in the other schedule for the same read(x) operation.3. If an operation write1(y) is the last operation to write the value of y in schedule S then thesame operation must be the last operation in schedule S.

    56.

    What is view serializable? Ans: A schedule is said to be view serializable if it is view equivalent with some serial schedule.

    57 . What are the various methods of controlling concurrency? Ans:1. Locking2. Time stampLocking data item to prevent multiple transactions from accessing the item concurrently.A time stamp is a unique identifier for each transaction, generated by the system.

    58 . What is a lock?

    Ans: A lock is a variable associated with a data item that describes the status of the item with

    respect to the possible operations that can be applied to it.

    59. What are various types of locking techniques? Ans: 1. a binary lock 2. Shared/Exclusive lock 3. Two phase locking

  • 8/8/2019 Siva Tcs Technical Questions

    40/93

    60 . What is a binary lock? Ans: A binary lock can have two states or values:1. locked (1)2. unlocked(0)If locked it cannot be accessed by any other operations, else can be.

    61 . What is shared or exclusive lock? Ans: It implements multiple-mode lock. Allowing multiple accesses for read operations butexclusive access for write operation.

    62 . Explain two phase locking? Ans: All the locking operations must precede the first unlock operation in the transaction .It doeshave two phases:1. expanding phase (Locks are issued)2. Shrinking phase (Locks are released)

    63.

    What are different types of two phase lockings (2pl)? Ans: 1. Basic2. Conservative3. Strict4. Rigorousthis is the basic technique of 2pl described above.Conservative 2pl requires a transaction to lock all the items it accesses before the transaction

    begins its execution, by pre-declaring its read-set and write-set.Strict 2pl guarantees that a transaction doesnt release any of its exclusive locks until after itcommits or aborts.

    Rigorous guarantees that a transaction doesnt release any of its locks (including shared locks)until after it commits or aborts.

    64 . What is a deadlock? Ans: Dead lock occurs when each transaction T in a set of two or more transactions is waitingfor some item that is locked by some other transaction T in the set. Hence each transaction is ina waiting queue, waiting for one of the other transactions to release the lock on them.

    65 . What are triggers? Ans: Triggers are the PL/SQL blocks definining an act ion the database should take when somedatabase related event occurs. Triggers may be used to supplement declarative referentialintegrity, to enforce complex business rules, or to audit changes to data.

  • 8/8/2019 Siva Tcs Technical Questions

    41/93

    data structure Questions 1.What is data structure?

    2.What are the goals of Data Structure ?3.What does abstract Data Type Mean?4.What is the difference between a Stack and an Array?

    5.What do you mean by recursive definition?6.What is sequential search?7.What actions are performed when a function is called?

    8.What actions are performed when a function returns?9.What is a linked list ?

    10.What are the advantages of linked list over array(static data structure) ?11.Can we apply binary search algorithm to a sorted linked list,why ?12.What do you mean by free pool ?

    13.What do you mean by garbage collection ?14.What do you mean by overflow and underflow ?15.What are the disadvantages array implementation of linked list ?

    16.What is a queue ?17. What is a priority queue ?18.What are the disadvantages of sequential storage?

    19.What are the disadvantages of representing a stack or queue by a linked list ?20.What is dangling pointer and how to avoid it ?21.What are the disadvantages of linear list ?

  • 8/8/2019 Siva Tcs Technical Questions

    42/93

    22.Define circular list ?23. What are the disadvantages of circular list ?

    24.Define double linked list?25.Is it necessary to sort a file before searching a particular item ?26.What are the issues that hampers the efficiency in sorting a file ?

    27.Calculate the efficiency of sequential search ?28. Is any implicit arguments are passed to a function when it is called ?29.Parenthesis is never required in Postfix or Prefix expressions, Why?

    30.List out the areas in which data structures are applied extensively?31.What are the major data structures used in the following areas : network data model & Hierarchicaldata model.

    32.If you are using C language to implement the heterogeneous linked list, what pointer type will youuse?33.Minimum number of queues needed to implement the priority queue?

    34.What is the data structures used to perform recursion?35.What are the notations used in Evaluation of Arithmetic Expressions using prefix and postfix forms?36. Convert the expression ((A + B) * C (D E) ^ (F + G)) to equivalent Prefix and Postfix notations.

    37. Sorting is not possible by using which of the following methods?38. List out few of the Application of tree data-structure?39. List out few of the applications that make use of Multilinked Structures?

    40. In tree construction which is the suitable efficient data structure?41. What is the type of the algorithm used in solving the 8 Queens problem?

    42 .In an AVL tree, at what condition the balancing is to be done?43 .There are 8, 15, 13, 14 nodes were there in 4 different trees. Which of them could have formed a fullbinary tree?

    44.In RDBMS, what is the efficient data structure used in the internal storage representation?45. Of the following tree structure, which is, efficient considering space and time complexities?(a) Incomplete Binary Tree.

    (b) Complete Binary Tree.(c) Full Binary Tree.46.What is a spanning Tree?

    47.Does the minimum spanning tree of a graph give the shortest distance between any 2 specifiednodes?48.Whether Linked List is linear or Non-linear data structure?

    Data Structures Question and Answers |Part1

  • 8/8/2019 Siva Tcs Technical Questions

    43/93

    July 25th, 2010

    If you would like to view All Data Structures interview questions only, at one place, visit belowlink All Data Structures Interview Questions

    1. What is data structure? Ans: The logical and mathematical model of a particular organization of data is called datastructure. There are two types of data structurei) Linear ii) Nonlinear

    2. What are the goals of Data Structure? Ans: It must rich enough in structure to reflect the actual relationship of data in real world.The structure should be simple enough for efficient processing of data.

    3.

    What does abstract Data Type Mean? Ans: Data type is a collection of values and a set of operations on these values. Abstract datatype refer to the mathematical concept that define the data type.It is a useful tool for specifying the logical properties of a data type.ADT consists of two parts1) Values definition2) Operation definitionExample:- The value definition for the ADT RATIONAL states that RATIONAL value consistsof two integers, second doesnt equal to zero.The operator definition for ADT RATIONAL includes the operation of creation (make rational)addition, multiplication and test for equality.

    4. What is the difference between a Stack and an Array? Ans: i) Stack is a ordered collection of itemsii) Stack is a dynamic object whose size is constantly changing as items are pushed and popped .iii) Stack may contain different data typesiv) Stack is declared as a structure containing an array to hold the element of the stack, and aninteger to indicate the current stack top within the array.ARRAYi) Array is an ordered collection of itemsii) Array is a static object i.e. no of item is fixed and is assigned by the declaration of the arrayiii) It contains same data types.iv) Array can be home of a stack i.e. array can be declared large enough for maximum size of thestack.

    5. What do you mean by recursive definition? Ans: The definition which defines an object in terms of simpler cases of itself is called recursivedefinition.

  • 8/8/2019 Siva Tcs Technical Questions

    44/93

    6. What is sequential search? Ans: In sequential search each item in the array is compared with the item being searched until amatch occurs. It is applicable to a table organized either as an array or as a linked list.

    7. What actions are performed when a function is called?

    Ans: When a function is calledi) arguments are passedii) local variables are allocated and initializedii) transferring control to the function

    8 . What actions are performed when a function returns? Ans: i) Return address is retrievedii) Functions data area is freediii) Branch is taken to the return address

    9.What is a linked list? Ans: A linked list is a linear collection of data elements, called nodes, where the linear order is

    given by pointers. Each node has two parts first part contain the information of the elementsecond part contains the address of the next node in the list.

    10 . What are the advantages of linked list over array (static data structure)? Ans:The disadvantages of array arei) unlike linked list it is expensive to insert and delete elements in the arrayii) One cant double or triple the size of array as it occupies block of memory space.

    In linked listi) each element in list contains a field, called a link or pointer which contains the address of thenext elementii) Successive elements need not occupy adjacent space in memory.

    Data Structures Question and Answers |

    Part2 July 25th, 2010

    If you would like to view All Data Structures interview questions only, at one place, visit belowlink All Data Structures Interview Questions

  • 8/8/2019 Siva Tcs Technical Questions

    45/93

    11 . Can we apply binary search algorithm to a sorted linked list, why? Ans: No we cannot apply binary search algorithm to a sorted linked list, since there is no way of indexing the middle element in the list. This is the drawback in using linked list as a datastructure.

    12.

    What do you mean by free pool? Ans: Pool is a list consisting of unused memory cells which has its own pointer.

    13 . What do you mean by garbage collection? Ans: It is a technique in which the operating system periodically collects all the deleted spaceonto the free storage list.It takes place when there is minimum amount of space left in storage list or when CPU is ideal.The alternate method to this is to immediately reinsert the space into free storage list which istime consuming.

    14 . What do you mean by overflow and underflow?

    Ans: When new data is to be inserted into the data structure but there is no available space i.e.free storage list is empty this situation is called overflow.When we want to delete data from a data structure that is empty this situation is calledunderflow.

    15 . What are the disadvantages array implementations of linked list? Ans: i) The no of nodes needed cant be predicted when the program is written.ii) The no of nodes declared must remain allocated throughout its execution

    16 . What is a queue?

    Ans: A queue is an ordered collection of items from which items may be deleted at one end(front end) and items inserted at the other end (rear end).It obeys FIFO rule there is no limit to the number of elements a queue contains.

    17 . What is a priority queue? Ans: The priority queue is a data structure in which the intrinsic ordering of the elements(numeric or alphabetic)Determines the result of its basic operation. It is of two typesi) Ascending priority queue- Here smallest item can be removed (insertion is arbitrary)ii) Descending priority queue- Here largest item can be removed (insertion is arbitrary)

    18 .

    What are the disadvantages of sequential storage? Ans: i) Fixed amount of storage remains allocated to the data structure even if it contains less element.ii) No more than fixed amount of storage is allocated causing overflow

    19. What are the disadvantages of representing a stack or queue by a linked list? Ans: i) A node in a linked list (info and next field) occupies more storage than a corresponding

  • 8/8/2019 Siva Tcs Technical Questions

    46/93

    element in an array.ii) Additional time spent in managing the available list.

    20 . What is dangling pointer and how to avoid it? Ans: After a call to free(p) makes a subsequent reference to *p illegal, i.e. though the storage to

    p is freed but the value of p(address) remain unchanged .so the object at that address may beused as the value of *p (i.e. there is no way to detect the illegality).Here p is called dangling pointer.To avoid this it is better to set p to NULL after executing free(p).The null pointer value doesntreference a storage location it is a pointer that doesnt point to anything.

    Data Structures Question and Answers |Part3 July 25th, 2010

    If you would like to view All Data Structures interview questions only, at one place, visit belowlink All Data Structures Interview Questions

    21 . What are the disadvantages of linear list?

    Ans: i) We cannot reach any of the nodes that precede node (p)ii) If a list is traversed, the external pointer to the list must be persevered in order to reference thelist again

    22 . Define circular list? Ans: In linear list the next field of the last node contain a null pointer, when a next field in thelast node contain a pointer back to the first node it is called circular list.Advantages From any point in the list it is possible to reach at any other point

    23 . What are the disadvantages of circular list? Ans: i) We cant traverse the list backwardii) If a pointer to a node is given we cannot delete the node

    24 . Define double linked list? Ans: It is a collection of data elements called nodes, where each node is divided into three partsi) An info field that contains the information stored in the node

  • 8/8/2019 Siva Tcs Technical Questions

    47/93

    ii) Left field that contain pointer to node on left sideiii) Right field that contain pointer to node on right side

    25 . Is it necessary to sort a file before searching a particular item ? Ans:

    If less work is involved in searching a element than to sort and then extract, then we dont go for sortIf frequent use of the file is required for the purpose of retrieving specific element, it is moreefficient to sort the file.Thus it depends on situation.

    26 . What are the issues that hamper the efficiency in sorting a file? Ans: The issues arei) Length of time required by the programmer in coding a particular sorting programii) Amount of machine time necessary for running the particular programiii)The amount of space necessary for the particular program .

    27 . Calculate the efficiency of sequential search? Ans: The number of comparisons depends on where the record with the argument key appears inthe tableIf it appears at first position then one comparisonIf it appears at last position then n comparisonsAverage=(n+1)/2 comparisonsUnsuccessful search n comparisons

    Number of comparisons in any case is O (n).

    28 . Is any implicit arguments are passed to a function when it is called?

    Ans: Yes there is a set of implicit arguments that contain information necessary for the functionto execute and return correctly. One of them is return address which is stored within thefunctions data area, at the time of returning to calling program the address is retrieved and thefunction branches to that location.

    29. Parenthesis is never required in Postfix or Prefix expressions, why? Ans: Parenthesis is not required because the order of the operators in the postfix /prefixexpressions determines the actual order of operations in evaluating the expression

    30 . List out the areas in which data structures are applied extensively? Ans:Compiler Design,Operating System,Database Management System,Statistical analysis package,

    Numerical Analysis,Graphics,Artificial Intelligence,Simulation

  • 8/8/2019 Siva Tcs Technical Questions

    48/93

    Data Structures Question and Answers |Part4 July 25th, 2010

    If you would like to view All Data Structures interview questions only, at one place, visit belowlink All Data Structures Interview Questions

    31 . What are the major data structures used in the following areas : network data model &

    Hierarchical data model. Ans:

    RDBMS Array (i.e. Array of structures) Network data model GraphHierarchical data model Trees

    32 . If you are using C language to implement the heterogeneous linked list, what pointertype will you use? Ans: The heterogeneous linked list contains different data types in its nodes and we need a link,

    pointer to connect them. It is not possible to use ordinary pointers for this. So we go for void pointer. Void pointer is capable of storing pointer to any type as it is a generic pointer type.

    33 . Minimum number of queues needed to implement the priority queue? Ans: Two. One queue is used for actual storing of data and another for storing priorities.

    34 . What is the data structures used to perform recursion? Ans: Stack. Because of its LIFO (Last In First Out) property it rememb