Cluster's 08 Infobyte v1.3 - Carings Guide To Software Engineers
Cluster's 08 Infobyte v1.3 - Carings Guide To Software Engineers
Cluster's 08 Infobyte v1.3 - Carings Guide To Software Engineers
2008
1. What is a modifier? A modifier, also called a modifying function is a member function that
changes the value of at least one data member. In other words, an
operation that modifies the state of an object. Modifiers are also
known as ‘mutators’. Example: The function mod is a modifier in the
following code snippet:
2. class test
3. {
4. int x,y;
5. public:
6. test()
7. {
8. x=0; y=0;
9. }
10. void mod()
11. {
12. x=10;
13. y=15;
14. }
15. };
16. What is an accessor? An accessor is a class operation that
does not modify the state of an object. The accessor functions need to
be declared as const operations
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 1
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
23. List out some of the object-oriented methodologies. Object Oriented Development (OOD)
(Booch 1991,1994), Object
Oriented Analysis and Design (OOA/D) (Coad and Yourdon 1991), Object
Modelling Techniques (OMT) (Rumbaugh 1991), Object Oriented Software
Engineering (Objectory) (Jacobson 1992), Object Oriented Analysis (OOA)
(Shlaer and Mellor 1992), The Fusion Method (Coleman 1991).
~Sample()
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 2
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
delete ptr;
void PrintVal()
};
void SomeFunc(Sample x)
int main()
Sample s1 = 10;
SomeFunc(s1);
s1.PrintVal();
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 3
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
Method
41. What are the conditions that have to be met for a condition to be an invariant of the class?
o The condition should hold at the end of every constructor.
o The condition should hold at the end of every mutator (non-const) operation.
42. What are proxy objects? Objects that stand for other objects are called proxy objects or
surrogates.
43. template <class t="">
44. class Array2D
45. {
46. public:
47. class Array1D
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 4
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
48. {
49. public:
50. T& operator[] (int index);
51. const T& operator[] (int index)const;
};
};
Array2D<float>data(10,20);
cout<<data[3][6]; // fine
52. Name some pure object oriented languages. Smalltalk, Java, Eiffel, Sather.
53. Name the operators that cannot be overloaded. sizeof, ., .*, .->, ::, ?: Salam in the comments
notes that -> can be overloaded.
A node class is a class that has added new services or functionality beyond the services inherited
from its base class.
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 5
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
interfere with each other in any way. The same derived class may
inherit such classes with no difficulty.
56. What is a container class? What are the types of container classes?
C interview questions
1. A frequent reader of this site sent this in. No answers, but a nice set of
questions. Consider getting Kernighan and Ritchie title if you find many things
puzzling here.
1. What does static variable mean?
2. What is a pointer?
3. What is a structure?
11. Where does global, static, local, register variables, free memory and C
Program instructions get stored?
14. Describe about storage allocation and scope of global, extern, static, local and
register variables?
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 6
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
15. What are register variables? What are the advantage of using register
variables?
17. Can we specify variable field width in a scanf() format string? If possible how?
18. Out of fgets() and gets() which function is safe to use and why?
21. Differentiate between a for loop and a while loop? What are it uses?
23. Write down the equivalent pointer expression for referring the same element
a[i][j][k][l]?
30. How will you declare an array of three function pointers where each function
receives two ints and
returns a float?
32. What is a NULL Macro? What is the difference between a NULL Pointer and a
NULL Macro?
33. What does the error ‘Null Pointer Assignment’ mean and what causes this
error?
34. What is near, far and huge pointers? How many bytes are occupied by them?
35. How would you obtain segment and offset addresses from a far address of a
memory location?
36. Are the expressions arr and *arr same for an array of integers?
37. Does mentioning the array name gives the base address in all the contexts?
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 7
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
41. How can we check whether the contents of two structure variables are same
or not?
42. How are Structure passing and returning implemented by the complier?
45. What do the ‘c’ and ‘v’ in argc and argv stand for?
46. Are the variables argc and argv are local to main?
47. What is the maximum combined length of command line arguments including
the space between adjacent arguments?
48. If we want that any wildcard characters in the command line arguments
should be appropriately expanded, are we required to make any special
provision? If yes, which?
49. Does there exist any way to make the command line arguments available to
other functions without passing them as arguments to the function?
50. What are bit fields? What is the use of bit fields in a Structure declaration?
52. Which bit wise operator is suitable for checking whether a particular bit is on
or off?
53. Which bit wise operator is suitable for turning off a particular bit in a number?
54. Which bit wise operator is suitable for putting on a particular bit in a number?
55. Which bit wise operator is suitable for checking whether a particular bit is on
or off?
57. Write a program to compare two strings without using the strcmp() function.
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 8
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
59. Write a program to interchange 2 variables without using the third one.
60. Write programs for String Reversal. The same for Palindrome check.
65. Write a program which uses functions like strcmp(), strcpy(), etc.
68. How can you increase the size of a dynamically allocated array?
69. How can you increase the size of a statically allocated array?
70. When reallocating memory if any other pointers point into the same piece of
memory do you have to readjust these other pointers or do they get
readjusted automatically?
71. Which function should be used to free the memory allocated by calloc()?
72. How much maximum can you allocate in a single call to malloc()?
74. What is object file? How can you access object file?
75. Which header file should you include if you are to develop a function which
can accept variable number of arguments?
77. How can a called function determine the number of arguments that have been
passed to it?
78. Can there be at least some solution to determine the number of arguments
passed to a variable argument list function?
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 9
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
81. Does there exist any other function which can be used to convert an integer
or a float to a string?
82. How would you use qsort() function to sort an array of structures?
83. How would you use qsort() function to sort the name stored in an array of
pointers to string?
84. How would you use bsearch() function to search a name stored in array of
pointers to string?
85. How would you use the functions sin(), pow(), sqrt()?
86. How would you use the functions memcpy(), memset(), memmove()?
87. How would you use the functions fseek(), freed(), fwrite() and ftell()?
88. How would you obtain the current time and difference between two times?
89. How would you use the functions randomize() and random()?
90. How would you implement a substr() function that extracts a sub string from
a given string?
91. What is the difference between the functions rand(), random(), srand() and
randomize()?
92. What is the difference between the functions memmove() and memcpy()?
94. Can you use the function fprintf() to display the output on the screen?
95. Gautam Pagedar adds this question: What is a linklist and why do we use it
when we have arrays? - I feel the correct answer should be linklist is used in
cases where you don’t know the memory required to store a data structure
and need to allocate is dynamically on demand.
97. Sunil asks: What is the difference between main() in C and main() in C++?
98. ajz at his interviews asks what will be printed out when the following code is
executed:
main()
{
printf("%x",-1<<4);
}
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 10
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
4. In C, why is the void pointer useful? When would you use it? The void pointer
is useful becuase it is a generic pointer that any pointer can be cast into and back
again without loss of information.
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 11
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
Q. In the derived class, which data member of the base class are visible?
In the public and protected sections.
1. (From Microsoft) Assume I have a linked list contains all of the alphabets
from ‘A’ to ‘Z’. I want to find the letter ‘Q’ in the list, how does you perform
the search to find the ‘Q’?Answer: In a linked list, we only know about the header
and other elements are invisible unless we go through the node one by one. Since
we have go through every single node to find ‘Q’, the search time for a linked list is
linear which is O (N).
(From IBM) What classes you have enjoyed the most during your school
years?
Answer: I like the class I am taking this semester, which involves a group project
that needs great amount of team efforts. I really enjoy work with a group of people
because we can learn new materials mutually.
>
m IBM) According to your group project you just mentioned, what’s the responsibility
for each member in your group?
Answer: We have five people in our group. So far we have two web servers set up;
one will be the back up system and the other will be the main system. Our leader
coordinates the schedule. Two members are working on the database and do the
coding for the connection between database and Java serverlets. One member is
working on the user browser interface. All members will assign some classes to work
on and perform the final test at the end. We have group meeting every Saturday to
ensure our schedule is on track.
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 12
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
2. What is polymorphism?
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.
3. How do you find out if a linked-list has an end? (i.e. the list is not a cycle)
You can find out by using 2 pointers. One of them goes 2 nodes each time. The
second one goes at 1 nodes each time. If there is a cycle, the one that goes 2 nodes
each time will eventually meet the one that goes slower. If that is the case, then you
will know the linked-list is a cycle.
4. How can you tell what shell you are running on UNIX system?
You can do the Echo $RANDOM. It will return a undefined variable if you are from the
C-Shell, just a return prompt if you are from the Bourne shell, and a 5 digit random
numbers if you are from the Korn shell. You could also do a ps -l and look for the
shell with the highest PID.
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 13
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
char *str;
err_num = 2;
return (str);
while(len)
str[i++]=s[–len];
str[i] = NULL;
return (str);
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 14
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
3) Implementation (coding)
4) Testing
6) Obsolescence
A: -Application layer
-Presentation layer
-Session layer
-Transport layer
-Network layer
-Physical layer
1. Q1 What are the advantages and disadvantages of B-star trees over Binary
trees? (Asked by Motorola people)
A1 B-star trees have better data structure and are faster in search than Binary trees,
but it’s harder to write codes for B-start trees.
Q2 Write the psuedo code for the Depth first Search.(Asked by Microsoft)
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 15
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
A2
dfs(G, v) //OUTLINE
Mark v as "discovered"
For each vertex w such that edge vw is in G:
If w is undiscovered:
dfs(G, w); that is, explore vw, visit w, explore from there
as much as possible, and backtrack from w to v.
Otherwise:
"Check" vw without visiting w.
Mark v as "finished".
A3. The simplest rehashing policy is linear probing. Suppose a key K hashes to
location i. Suppose other key occupies H[i]. The following function is used to
generate alternative locations:
rehash(j) = (j + 1) mod h
where j is the location most recently probed. Initially j = i, the hash code for K.
Notice that this version of rehash does not depend on K.
Q4 Describe Stacks and name a couple of places where stacks are useful.
(Asked by Microsoft)
A4 .A Stack is a linear structure in which insertions and deletions are always made at
one end, called the top. This updating policy is called last in, first out (LIFO). It is
useful when we need to check some syntex errors, such as missing parentheses.
A5. If a 3-bit sequence number is used, then it could distinguish 8 different frames.
Since the number of frames that could be transmitted at a time is no greater half the
numner of frames that could be distinguished by the sequence number, so at most 4
frames can be transmitted at a time
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 16
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
Answer: Mergesort always makes recursive calls to sort subarrays that are about half
size of the original array, resulting in O(n log n) time.
Answer: .An internal iterator is implemented with member functions of the class that
has items to step through. .An external iterator is implemented as a separate class
that can be "attach" to the object that has items to step through. .An external
iterator has the advantage that many difference iterators can be active
simultaneously on the same object.
Answer: The real power of arrays comes from their facility of using an index variable
to traverse the array, accessing each element with the same expression a[i]. All the
is needed to make this work is a iterated statement in which the variable i serves as
a counter, incrementing from 0 to a.length -1. That is exactly what a loop does.
class Fruit {
// …
}
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 17
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
// Container of fruit
class BasketOfFruit {
BasketOfFruit() ;
void insert( Fruit & f ) ;
// …
}
// Container of apples
class BasketOfApples /* ??? */ {
// …
}
3. Describe briefly what the following function does. What standard function is it
most like ?
int f( char *p ) {
int n = 0 ;
while ( *p != 0 ) n = 10*n + *p++ - ‘0′ ;
return n ;
}
4. Describe briefly what function ‘a’ does in the following code fragment.
struct s {
struct s *next ;
}
5. What default methods are declared implicitly by the C++ compiler for the class
below:
class Empty
{
};
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 18
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
Disk : This class is a singleton. The read() and write() methods both block on a
simple atomic lock()/unlock() shared between the two. (ie, only one thread can
access the disk, thru either read or write, at any given time). It also has a
waitForData() method, which blocks (without claiming the lock) until either a timeout
elapses, or data is ready. It returns true upon returning due to new data, false upon
returning due to the timeout.
Network : This class is a singleton. The read() and write() methods both block on a
simple atomic lock()/unlock() shared between the two. (ie, only one thread can
access the disk, thru either read or write, at any given time).
Sensor: The Sensor class accesses a number of physical sensors. The first method,
‘waitForData()’, blocks until data has been collected from the sensors. The second
method, ‘processData()’, does a series of long and cpu-intensive calculations on the
data. These calculations often take several minutes. It then returns the processed
data.
Each of the following threads is running concurrently. Assume that the psuedocode in
each thread is looped infinitely (ie, encased in a while(true) { }. It is extremely
important that information buffered to the disk be sent to the network as quickly as
possible, this is why Thread 1 runs at priority 5. The system conditions checked in
thread 3 are not particularly important events (not as important as the calculations
done in thread 2). If the events aren’t transmitted over the network for several
minutes, it’s not a problem at all. They do, however, contain a large amount of
system information. Thread 4 watches for serious system alarms, indicating serious
problems. These are a serious concern and if not quickly buffered to the disk and
sent to the network, can cause serious revenue loss.
Thread 1: (priority: 5)
while(!Disk.waitForData()) { yield(); } /* Wait until someone has
written data to the disk */
Network.write(Disk.read()); /* Write the data buffered on the disk to
the network */
Thread 2: (priority: 2)
while(!Sensor.waitForData()) { yield(); } /* Wait until the sensors
have picked up data */
Disk.write(Sensor.processData()); /* process the data and write it to
the disk. */
Thread 3: (priority: 1)
Thread 4: (priority: 4)
if (checkAlarms()) /* If any serious alarms exist */
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 19
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
A: By using the extern "C" linkage specification around the C function declarations.
A: It 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.
Q: What are the differences between a C++ struct and C++ class?
A: Two.
There are two formats for initializers in C++ as shown in the example that follows.
The first format uses the traditional C notation. The second format uses constructor
notation.
Q: How does throwing and catching exceptions differ from using setjmp and
longjmp?
A: The throw operation calls the destructors for automatic objects instantiated since
entry to the try block.
delete this;
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 20
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
A: A copy constructor constructs a new object by using the content of the argument
object. An overloaded
assignment operator assigns the contents of an existing object to another existing
object of the same class.
A: There are three acceptable answers: "Never," "Rarely," and "When the problem
domain cannot be accurately modeled any other way."
A: The simple answer is that a virtual destructor is one that is declared with the
virtual attribute.
Q: Explain the ISA and HASA class relationships. How would you implement each in a
class design?
A: A specialized class "is" a specialization of another class and, therefore, has the
ISA relationship with the other class. An Employee ISA Person. This relationship is
best implemented with inheritance. Employee is derived from Person. A class may
have an instance of another class. For example, an employee "has" a salary,
therefore the Employee class has the HASA relationship with the Salary class. This
relationship is best implemented by embedding an object of the Salary class in the
Employee class.
A: When you are designing a generic class to contain or otherwise manage objects of
other types, when the format and behavior of those other types are unimportant to
their containment or management, and particularly when those other types are
unknown (thus, the genericity) to the designer of the container or manager class.
A: One that can be modified by the class even when the object of the class or the
member function doing the modification is const.
A: A conversion constructor declared with the explicit keyword. The compiler does
not use an explicit constructor to implement an implied conversion of types. It’s
purpose is reserved explicitly for construction.
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 21
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
A: The ability to determine at run time the type of an object by using the typeid
operator or the dynamic_cast operator.
A: 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
namespace feature surrounds a library’s external declarations with a unique
namespace that eliminates the potential for those collisions.
This solution assumes that two library vendors don’t use the same namespace
identifier, of course.
A: Yes. The ANSI committee added the bool intrinsic type and its true and false value
keywords.
1. What is a Make file?(Fujitsu) Make file is a utility in Unix to help compile large
programs. It helps by only compiling the portion of the program that has been
changed.
5. Name some major differences between C++ and Java. C++ has pointers; Java
does not. Java is platform-independent; C++ is not. Java has garbage collection;
C++ does not.
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 22
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
1. Q1: Could you tell something about the Unix System Kernel? (from ITCO )
A1: The kernel is the heart of the UNIX openrating system, it’s reponsible for
controlling the computer’s resouces and scheduling user jobs so that each one gets
its fair share of resources.
Q2: What are each of the standard files and what are they normally
associated with? (from ITCO )
A2: They are the standard input file, the standard output file and the standard error
file. The first is usually associated with the keyboard, the second and third are
usually associated with the terminal screen.
Q3: Detemine the code below, tell me exectly how many times is the
operation sum++ performed ? (from ITCO )
A5: The "ARP" stands for Address Resolution Protocol. The ARP standard defines two
basic message types: a request and a response. a request message contains an IP
address and requests the corresponding hardware address; a replay contains both
the IP address, sent in the request, and the hardware address.
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 23
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
13. When you inherit a class using private keyword which members of base class are
visible to the derived class?
15. #define cat(x,y) x##y concatenates x to y. But cat(cat(1,2),3) does not expand but
gives preprocessor
warning. Why?
16. Can you have constant volatile variable? Yes, you can have a volatile pointer?
18. Operations involving unsigned and signed – unsigned will be converted to signed
23. Which way of writing infinite loops is more efficient than others? there are 3ways.
26. Who to know wether systemuses big endian or little endian format and how to
convert among them?
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 24
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
29. How is generic list manipulation function written which accepts elements of any kind?
30. What is the difference between hard real-time and soft real-time OS?
32. What is the differnce between embedded systems and the system in which rtos is
running?
33. How can you define a structure with bit field members?
35. How do you write a function which takes 2 arguments - a byte and a field in the byte
and returns the value of
the field in that byte?
38. What are the different BSD and SVR4 communication mechanisms
2. What should the 64-bit integer type on new, 64-bit machines be?
6. I can’t seem to define a linked list node which contains a pointer to itself.
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 25
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
10. What can I safely assume about the initial values of variables which are not
explicitly initialized?
12. What is the difference between char a[] = “string"; and char *p = “string"; ?
main()
{
char *p1=“name”;
char *p2;
p2=(char*)malloc(20);
memset (p2, 0, 20);
while(*p2++ = *p1++);
printf(“%sn”,p2);
Answer:empty string.
main()
{
int x=20,y=35;
x=y++ + x++;
y= ++y + ++x;
printf(“%d%dn”,x,y);
Answer : 5794
main()
{
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 26
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
int x=5;
printf(“%d,%d,%dn”,x,x< <2,x>>2);
Answer: 5,20,1
void main()
{
int x=5, y=10;
swap (x,y);
printf(“%d %dn”,x,y);
swap2(x,y);
printf(“%d %dn”,x,y);
}
Answer: 10, 5
10, 5
main()
{
char *ptr = ” Cisco Systems”;
*ptr++; printf(“%sn”,ptr);
ptr++;
printf(“%sn”,ptr);
Answer:Cisco Systems
isco systems
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 27
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
main()
{
char s1[]=“Cisco”;
char s2[]= “systems”;
printf(“%s”,s1);
}
Answer: Cisco
main()
{
char *p1;
char *p2;
p1=(char *)malloc(25);
p2=(char *)malloc(25);
strcpy(p1,”Cisco”);
strcpy(p2,“systems”);
strcat(p1,p2);
printf(“%s”,p1);
Answer: Ciscosystems
Answer: all the functions in the file1.c can access the variable.
while(TRUE)
{
// some code
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 28
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
int x;
int modifyvalue()
{
return(x+=10);
}
int changevalue(int x)
{
return(x+=1);
}
void main()
{
int x=10;
x++;
changevalue(x);
x++;
modifyvalue();
printf("First output:%dn",x);
x++;
changevalue(x);
printf("Second output:%dn",x);
modifyvalue();
printf("Third output:%dn",x);
Answer: 12 , 13 , 13
main()
{
int x=10, y=15;
x = x++;
y = ++y;
printf(“%d %dn”,x,y);
Answer: 11, 16
main()
{
int a=0;
if(a==0)
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 29
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
printf(“Cisco Systemsn”);
printf(“Cisco Systemsn”);
Q: Write a short code using C++ to print out all odd number from 1 to 100 using a for
loop(Asked by Intacct.com people)
ISO layers and what layer is the IP operated from?( Asked by Cisco system people)cation,
Presentation, Session, Transport, Network, Data link and Physical. The IP is operated in the
Network layer.
3.Q: Write a program that ask for user input from 5 to 9 then calculate the average(
Asked by Cisco system people)
A.int main()
{
int MAX=4;
int total =0;
int average=0;
int numb;
cout<<"Please enter your input from 5 to 9";
cin>>numb;
if((numb <5)&&(numb>9))
cout<<"please re type your input";
else
for(i=0;i<=MAX; i++)
{
total = total + numb;
average= total /MAX;
}
cout<<"The average number is"<<average<<endl; return 0;
}
4.Q: Can you be bale to identify between Straight- through and Cross- over cable
wiring? and in what case do you use Straight- through and Cross-over? (Asked by
Cisco system people)
A. Straight-through is type of wiring that is one to to one connection Cross- over is type of
wiring which those wires are got switched.We use Straight-through cable when we connect
between NIC Adapter and Hub. Using Cross-over cable when connect between two NIC
Adapters or sometime between two hubs.
5.Q: If you hear the CPU fan is running and the monitor power is still on, but you did
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 30
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
not see any thing show up in the monitor screen. What would you do to find out
what is going wrong? (Asked by WNI people)
A. I would use the ping command to check whether the machine is still alive(connect to the
network) or it is dead.
1. This set of questions came from a prominent gaming company. As you can see, the
answers are not given (the interviews are typically conducted by senior developers),
but there’s a set of notes with common mistakes to avoid.
1. Explain which of the following declarations will compile and what will
be constant - a pointer or the value pointed at:
const char *
char const *
char * const
Note: Ask the candidate whether the first declaration is pointing to a string or
a single character. Both explanations are correct, but if he says that it’s a
single character pointer, ask why a whole string is initialized as char* in C++.
If he says this is a string declaration, ask him to declare a pointer to a single
character. Competent candidates should not have problems pointing out why
const char* can be both a character and a string declaration, incompetent
ones will come up with invalid reasons.
2. You’re given a simple code for the class BankCustomer. Write the
following functions:
Copy constructor
= operator overload
== operator overload
+ operator overload (customers’ balances should be added up, as an
example of joint account between husband and wife)
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 31
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
Note: Incorrect replies: “No, everything is correct", “Only the first element of
the array will be deleted", “The entire array will be deleted, but only the first
element destructor will be called".
Note: Typical wrong answer: Yes, the program will crash in an attempt to
delete a null pointer. The candidate does not understand pointers. A very smart
candidate will ask whether delete is overloaded for the class T.
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 32
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
Note: Hint to the candidate about the base platform they’re developing for. If
the person still doesn’t find anything wrong with the code, they are not
experienced with C++.
27. What does the following code do and why would anyone write
something like that?
28. void send (int *to, int * from, int count)
29. {
30. int n = (count + 7) / 8;
31. switch ( count % 8)
32. {
33. case 0: do { *to++ = *from++;
34. case 7: *to++ = *from++;
35. case 6: *to++ = *from++;
36. case 5: *to++ = *from++;
37. case 4: *to++ = *from++;
38. case 3: *to++ = *from++;
39. case 2: *to++ = *from++;
40. case 1: *to++ = *from++;
41. } while ( --n > 0 );
42. }
43. }
44. In the H file you see the following declaration:
45. class Foo {
46. void Bar( void ) const ;
47. };
4. How can would you create an instance of the object in COM? Well, it all
depends on your project. Start your answer from CoCreateInstance or
CoCreateInstanceEx, explain the difference between them. If interviewer is still not
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 33
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
satisfied, you’ll have to explain the whole kitchen behind the scenes, including a
difference between local server and inproc server, meaning and mechanism of class
factory, etc. You may also mention other methods of object creation like
CoGetInstanceFromFile, but discussion will likely turn to discussion of monikers then.
5. What happens when client calls CoCreateInstance? Again, all depends on the
level of detail and expertise of interviewer. Start with simple explanation of class
object and class factory mechanism. Further details would depend on a specific
situation.
10. What’s the difference, if any, between OLE and COM? OLE is build on top of
COM. The question is not strict, because OLE was built over COM for years, while
COM as a technology was presented by Microsoft a few years ago. You may mention
also that COM is a specification, while OLE is a particular implementation of this
specification, which in today’s world is not exactly true as well, because what people
call COM today is likely implementation of COM spec by Microsoft.
11. What’s the difference between COM and DCOM? Again, the question does not
require strict answer. Any DCOM object is yet a COM object (DCOM extends COM)
and any COM object may participate in DCOM transactions. DCOM introduced several
improvements/optimizations for distributed environment, such as MULTI_QI
(multiple QueryInterface()), security contexts etc. DCOM demonstrated importance
of surrogate process (you cannot run in-proc server on a remote machine. You need
a surrogate process to do that.) DCOM introduced a load balancing.
12. What is a dual interface? Dual interface is one that supports both - IDispatch
interface and vtbl-based interface. Therefore, it might be used in scripting
environment like VBScript and yet to use power and speed of vtbl-based interface for
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 34
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
13. Can you have two dual interfaces in one class? Yes. You may have two dual
interfaces in one class, but only one of them may be default. The bottom line is that
you cannot work with two dual interfaces at the same time due to nature of dual
interface! To support two dual interfaces in VB you would write something like:
14. dim d1 as IDualInterface1
15. dim d2 as IDualInterface2
16. set d1 = new MyClassWithTwoDuals
17. set d2 = d1
18. What is marshalling by value? Some objects can essentially be considered static:
regardless of which methods are called, the state of the object does not change.
Instead of accessing such an object remotely, it is possible to copy the static state of
the object and create a new object with the same state information on the caller
side. The caller won’t be able to notice the difference, but calls will be more efficient
because they do not involve network round trips. This is called “marshaling by
value".
20. Let’s assume we have object B and aggregated object C (in-proc server),
created by B. Can you access any interface of B from C? What’s the
difference between aggregated and contained objects? Yes, you can. This is
fundamental postulate of COM: “If you can get there from here, you can get there
from anywhere", i.e. QI’ing for IUnknown you may proceed and to get a pointer to
any other interface, supported by the object. Aggregated object exposes its interface
directly, without visible intervention of the object container. Contained object is
created within the object container and its interfaces might be altered or filtered by
the object container.
21. What is ROT ? GIT ? Count pros and cons of both. By definition, running object
table (ROT) is a globally accessible table on each computer that keeps track of all
COM objects in the running state that can be identified by a moniker. Moniker
providers register an object in the table, which increments the object’s reference
count. Before the object can be destroyed, its moniker must be released from the
table. Global Interface Table (GIT) allows any apartment (either single- or multi-
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 35
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
22. If you have an object with two interfaces, can you custom marshal one of
them? No! The decision to use custom marshaling is an all-or-nothing decision; an
object has to custom marshal all its interfaces or none of them.
23. Is there a way to register in-proc server without regsvr32.exe? Yes. Call
DllRegisterServer() from the client. Do not forget to call DLLUnregisterServer() from
the same client. You may also use Registrar object for the same purpose or use
direct manipulation of the windows registry.
24. What is VARIANT? Why and where would you use it? VARIANT is a huge union
containing automation type. This allows easy conversion of one automation type to
another. The biggest disadvantage of VARIANT is size of the union.
25. How can you guarantee that only remote server is ever created by a client?
Create an object (call CoCreateObjectEx()) with CLSCTX_REMOTE_SERVER flag.
27. What is an IDL? IDL stands for Interface Definition Language. IDL is the language
to describe COM
interfaces.
28. What is In-proc? In-proc is in-process COM object, i.e. COM object that
implemented as DLL and supposed to be hosted by a container. When you have to
instantiate the in-proc object remotely, you may use DLLHost.exe application that
was design specially for this purpose.
29. What is OLE? OLE is an object and embedding first implementation of COM spec
available from MS before COM was officially named COM.
30. Give examples of OLE usage. The most famous examples are probably drag and
drop and structured storage implementations.
31. What are 2 storage types for composite document? Storage and Stream.
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 36
Cluster’s 08… infobyte v1.3 – Carings Guide to Software Engineers. 2008
Hindusthan College of Arts and Science, Coimbatore-641 028 | Department of Computer Applications Page 37