Professional Documents
Culture Documents
C Questions by Anudeep
C Questions by Anudeep
2. What is a pointer?
Ans: Pointers are variables which stores the address of another variable.
That variable may be a scalar (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 elements
ii) It is used for dynamic memory allocation.
iii) It is used in Call by reference
iv) 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 a single 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 to hold 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 the largest 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.
Array
1-It is a collection of data items of same data type.
2-It has declaration only
3-.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.
2- It has declaration and definition
3- keyword struct is used
4-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-memory allocated contains garbage values
1-Calloc takes two arguments Calloc(b,c) where b no of object and c
size of object
2-It initializes the contains of block of memory to zerosMalloc takes one
argument, memory allocated contains garbage values.
It allocates contiguous memory locations. Calloc takes two arguments,
memory allocated contains 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 is called the entire code is substituted by a
single line though the macro definition is of several lines.
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 becomes
lengthy if a macro is called several times.
If you would like to view All C language interview questions only at one
place visit below link
All C Language Interview Questions
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 is completely safe, because the compiler cant
prove that programmer wont overflow the buffer he pass to fgets ().
If you would like to view All C language interview questions only at one
place visit below link
All C Language Interview Questions
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 into and
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 to anywhere.
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 location may 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 allocation
II. Dynamic memory allocation
39. What is static memory allocation?
Ans: Compiler allocates memory space for a declared variable. By using
the address of operator, the
reserved 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 memory dynamically. If these functions are used to get
memory dynamically and the values returned by these function are
assigned to pointer variables, such a way of allocating memory at run
time is known as dynamic memory allocation.
c language interview questions | Part5
July 18th, 2010
If you would like to view All C language interview questions only at one
place visit below link
All C Language Interview Questions
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 increased or
decreased. If sufficient space is not available to the old region the
function may create a new region.
If you would like to view All C language interview questions only at one
place visit below link
All C Language Interview Questions
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 is
invoked with and v in argv(argument vector) is a pointer to an array of
character string that contain the arguments.
If you would like to view All C language interview questions only at one
place visit below link
All C Language Interview Questions
71. What are the two forms of #include directive?
Ans:
1.#includefilename
2.#include
the first form is used to search the directory that contains the source
file.If the search fails in the home 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 string
gcvt() 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.
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 types
1-high level files (stream oriented files) :These files are accessed using
library functions
2-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. The destination 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 requires creating
an I/O stream before reading or writing the data.
80. What is FILE?
Ans: FILE is a predefined data type. It is defined in stdio.h file.
If you would like to view All C language interview questions only at one
place visit below link
All C Language Interview Questions
81. 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.
If you would like to view All C language interview questions only at one
place visit below link
All C Language Interview Questions
91. 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 into
3-Function returning a pointer,e.g, float *f( ) ; Function returning a
pointer to float
4-Pointer to a pointer ,e.g, int **x; Pointer to apointer to int
5-pointer to a data type ,e.g, char *p; pointer to char
If you would like to view All C language interview questions only at one
place visit below link
All C Language Interview Questions
101. IMP>Can we initialize unions?
Ans: ANSI Standard C allows an initializer for the first member of a
union. There is no standard way
of initializing any other member (nor, under a pre-ANSI compiler, is
there generally any way of
initializing a union at all).
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?
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 below link
All C++ Language Interview Questions
1. What is a class?
Ans: The objects with the same data structure (attributes) and behavior
(operations) are called class.
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 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 like name, 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 without supporting 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 programming languages 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-operative collection of objects, each of which represents
an instance of some class and whose classes are all 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 outside the class also.
Within the class or from the object of a class protected access limit is
same as that of 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 global scope that has been hidden by another identifier
with the same name in the local scope.
10. What do you mean by inheritance?
Ans: The mechanism of deriving a new class (derived) from an old class
(base class) is called inheritance. It allows the extension and reuse of
existing code without having to rewrite the code from 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 below link
All C++ Language Interview Questions
11. What is abstraction?
Ans: The technique of creating user-defined data types, having the
properties of built-in data types and a set of permitted operators that are
well suited to the application to be programmed is known 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 and keeps 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 can declare 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 tokens
I. keywords
II. Identifiers
III. Constants
IV. Strings
V. 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
16. What do you mean by implicit conversion?
Ans: Whenever data types are mixed in an expression then c++ performs
the conversion automatically.
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 base
class.
18. What are the defining traits of an object-oriented language?
The defining traits of an object-oriented language are:
encapsulation
inheritance
polymorphism
Ans:
Polymorphism: is a feature of OOPL that at run time depending upon
the type of object the appropriate method is called.
Inheritance: is a feature of OOPL that represents the is a relationship
between different objects (classes). Say in real life a manager is a
employee. So in OOPL manger class is inherited from 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 function that is
expanded in line when it is invoked. That is the compiler replaces the
function call with the corresponding function code (similar to macro).
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?
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?
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
coherent
collection of data with some inherent meaning.
2. What is DBMS?
Ans: Database Management system is a collection of programs that
enables user to create and maintain a database.
Thus a DBMS is a general purposed s/w system that facilitates the
process of defining constructing and manipulating a database for various
applications. (Defining a data base involves specifying 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 controlled by DBMS. Manipulating a database
includes such functions as querying the data base to 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 is
made to access a particular data, the DBMS s/w refers to the catalog to
determine
the structure of the file.
4. What is data ware housing & OLAP?
Ans: Data warehousing and OLAP (online analytical processing )
systems are the
techniques used in many companies to extract and analyze useful
information
from 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 the
DBMS 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 the
structure 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 is
derived from the database files but is not explicitly stored .
10. What is OLTP?
Ans: Online transaction processing is an application that involve
multiple database accesses
from different parts of the world . OLTP needs a multi-user DBMS s/w
to ensure that concurrent
transactions operate correctly.
Operating Systems
Following are a few basic questions that cover the essentials of OS:
1. What is thrashing?
It is a phenomenon in virtual memory schemes when the processor spends
most of its time swapping pages, rather than executing instructions. This is due to
an inordinate number of page faults.
1. Define latency, transfer and seek time with respect to disk I/O.
Seek time is the time required to move the disk arm to the required track.
Rotational delay or latency is the time it takes for the beginning of the required
sector to reach the head. Sum of seek time (if any) and latency is the access time.
Time taken to actually transfer a span of data is transfer time.
1. What is time-stamping?
It is a technique proposed by Lamport, used to order events in a distributed
system without the use of clocks. This scheme is intended to order events
consisting of the transmission of messages. Each system 'i' in the network
maintains a counter Ci. Every time a system transmits a message, it increments its
counter by 1 and attaches the time-stamp Ti to the message. When a message is
received, the receiving system 'j' sets its counter Cj to 1 more than the maximum of
its current value and the incoming time-stamp Ti. At each site, the ordering of
messages is determined by the following rules: For messages x from site i and y
from site j, x precedes y if one of the following conditions holds....(a) if Ti<Tj or
(b) if Ti=Tj and i<j.
1. How are the wait/signal operations for monitor different from those for
semaphores?
If a process in a monitor signal and no task is waiting on the condition
variable, the signal is lost. So this allows easier program design. Whereas in
semaphores, every operation affects the value of the semaphore, so the wait and
signal operations should be perfectly balanced in the program.
1. What are the four layers that Windows NT have in order to achieve
independence?
Hardware abstraction layer
Kernel
Subsystems
System Services.
1. What is SMP?
To achieve maximum efficiency and reliability a mode of operation known
as symmetric multiprocessing is used. In essence, with SMP any process or threads
can be assigned to any processor.
1. What are the key object oriented concepts used by Windows NT?
Encapsulation
Object class and instance
1. What is mutant?
In Windows NT a mutant provides kernel mode or user mode mutual
exclusion with the notion of ownership.
1. What is FtDisk?
It is a fault tolerance disk driver for Windows NT.
1. What are DDks? Name an operating system that includes this feature.
DDks are device driver kits, which are equivalent to SDKs for writing
device drivers. Windows NT includes DDks.