Pages

Wednesday, June 1, 2011

Basic Technical questions


1)Find the output of the code snippet
   int i ;
   int v = scanf("%d",&i); // Lets say the input is 23
   printf("%d",v);

a)23
b)1
c)Junk

Anwer:
Output  = 1;
This is because, scanf reads and input and returns the number of items read.
 Hence 23 would be stored in i and 1 would be stored in v

2) Find the output of the code snippet
   char *S1 = "ABCD";
   char S2[ ] = "ABC";
   printf("%d,%d",sizeof(S1), sizeof(S2));
a) 3,4
b) 4,4
c) 3,3
Output: 4,4
S1 is a character pointer giving the size of the pointer variable.
 Second one is a character array with size 4. (Including the terminating character '\0' i.e Null Character ).

3) Consider there are two programs written respectively using two algorithms A and B. Say A has a complexity of n^2 and the other has a complexity of n/2. Given the same number of inputs which would take longer time to run.
Ans: 
First program written using algorithm A will take longer time. Higher the order of complexity, longer the time taken for execution.

4)What is the name of the type of constructor used to construct an object from another object where the desired parent class is same ?
ans:
Copy Constructor

5)Tell how function overloading saves programmer's efforts ?
Ans :
Function overloading, where different functions exist with the same name but different signatures plays its part in redundant function names when there more than one function performing logically the same operation but with different number and types of parameters as per the requirement. Hence the readability of the code is significantly improved.

6)Can you say few differences between Unicode character encoding and that of ASCII.
Ans:
Unicode uses 16 bits to encode characters and symbols whereas ASCII uses only 8 bits. Unicode has become a universal standard due to the fact that they can represent far great letters than ASCII. Unicode can be used hassle free to encode several regional languages other than English.

7)Differences between shared and exclusive locks ?
Ans:
Multiple transactions use shared locks during database read operations (SELECT Queries) as no data modification is involved. However if a transaction wants to change value of column/columns in single or multiple rows, it acquires an exclusive lock which will not be open to other transactions simultaneously.

8)In the context of memory management schemes, can you tell a primary difference between swapping and paging?
Ans:
Paging refers to writing and reading individual pages (fixed size) of a program to secondary memory (during program execution). Swapping refers to swap an entire program with another in secondary memory during heavy resource utilization.


9)Can you tell the primary difference between applets and conventional web applications ?
Ans:
Applet is a program that would be downloaded to browser and run on local CPU whereas web applications get executed on server.

No comments:

Post a Comment