symantec intern 2012
TRANSCRIPT
-
8/13/2019 Symantec Intern 2012
1/7
Question No 1
What is the output of the following program? #include int foo(int a[]) { returnsizeof(a)/sizeof(int); } int main(void) { int arr[5]; printf("%d ",foo(arr)); return 0; }
5
Compiler Error
RUNTIME Error
none of these
Clear Selected Answer
Question No 2
A connect() from a client will succeed after a server has called the following socket call -
socket()
bind()
listen()
accept()
Clear Selected Answer
Question No 3
A given graph G is an Euler graph iff all vertices of G are of
Same degree
Even degree
Odd degree
Different degree
Clear Selected Answer
Question No 4
A TCP/IP session is setup between two machines and the the initial seqnumber that thesender will use is 1. The sender sends 256 bytes and the receiver recevies all 256 bytesin one shot and sends back an acknowledgment packet (ACK) which also contains aacknowledgement number field to acknowledge the bytes received. Given standard TCPsemantics what would be the ack number contained in this ACK packet.
1
2
-
8/13/2019 Symantec Intern 2012
2/7
256
257
Clear Selected Answer
Question No 5
Consider the following SQL query: select * from EMPLOYEES E where E.AGE = 24 orderby E.SALARY; This is intended to find all records in the employees table whose AGE is24 and list them ordered by their salary. There is no index on any attribute of theEMPLOYEES table. Now consider the following two statements. Statement 1. Building anindex on EMPLOYEES.AGE can improve the performance of the query in some casesStatement 2. Building an index on EMPLOYEES.SALARY can improve the performanceof the query in some cases Which of these statements are true?
Only statement 1 is true
Only statement 2 is true
Both statements are true
Both statements are false
Clear Selected Answer
Question No 6
Which of the following is a reason why somebody might prefer a RISC-based computerarchitecture over a CISC-based computer architecture
It is difficult to debug programs on CISC computers
It is much more difficult to write compilers that make good use of CISC CPUs
It is possible to have to pipelined execution in RISC machines
RISC is more suitable for scientific applications
Clear Selected Answer
Question No 7
Given two binary heaps, each containing ' n' elements The heaps have the property thateach parent node has a value greater than or equal to each of its child nodes. What is the
complexity of merging these two binary heaps.
O(n)
O(n^2)
O(log n)
-
8/13/2019 Symantec Intern 2012
3/7
O(nlogn)
Clear Selected Answer
Question No 8
A multithreaded process is running under unix/linux. A signal is generated and sent tothis process. In general the signal
Can be handled by any thread of the process.
Will be handled by the parent thread only. (Parent thread is the one which created all otherthreads)
Only a pre-designated thread handles the signal.
Signals are not handled in a multithreaded process.
Clear Selected Answer
Question No 9
Consider the following table: Schema 1: COURSE_ID PROFESSOR TEXTBOOK PHY_101Ranade Intro to Physics PHY_101 Ranade Basic Physics PHY_101 Nambiar Intro toPhysics PHY_101 Nambiar Basic Physics CHEM_101 Abhyankar Intro to PhysicalChemistry CHEM_101 Abhyankar Intro to Organic Chemistry MECH_101 Ranade BasicPhysics MECH_101 Ranade Basic Mechanics Note that the set of professors who teach acourse is independent of the set of textbooks used for that course - i.e. the same set of
books is used irrespective of who is teaching that course. Question 1: What is theprimary key for this table?
COURSE_ID
COURSE_ID, PROFESSOR
COURSE_ID, TEXTBOOK
COURSE_ID, PROFESSOR, TEXTBOOK
Clear Selected Answer
Question No 10
What is the output of the following program? #include int main(void) { unsignedint i=10; if( i>-5 && ++i>5 ) printf("TRUE, i=%d ",i); else printf("FALSE, i=%d ",i); return 0;}
TRUE, i=10
-
8/13/2019 Symantec Intern 2012
4/7
TRUE, i=11
FALSE, i=10
FALSE, i=11
Clear Selected Answer
Question No 11
What is the output of the following program? #include int main(void) { int i=10;while() { if(! --i) break; } printf("%d ",i); return 0; }
0
10
Compiler Error
none of these
Clear Selected Answer
Question No 12
If a host machine (not a router) with an IP of 192.168.42.2 gets a packet destined toanother host 192.168.42.3, What does it do?
Discards the packet
Forwards the packet to 192.168.42.3
Sends the packet back to the router with a flag set.
None of the above.
Clear Selected Answer
Question No 13
Given the legend for semaphores: init_sem(Semaphore s, integer v) initialises the valueof semaphore s with v P(semaphore s): standard P() operation on semaphoreV(semaphore s): standard V() operation on semaphore A multithreaded process has 1master thread and 10 worker threads. All the threads share a global semaphore SEM. Atstartup the master thread spawns of 10 worker threads and then has to wait till all the 10threads complete their job. Question: The master thread executes two statements aftersqawning the threads init_sem(SEM, X) P(SEM) Each worker thread executes V(SEM)before it exits after completing its job What is the value of X?
10
-10
-
8/13/2019 Symantec Intern 2012
5/7
-9
9
Clear Selected Answer
Question No 14
Which one of the statements is false? mmap() system call under unix/linux
can be used to map a regular file of a disk based filesystem
cannot be used to map a directory
can be used to map a socket
cannot be used to map a socket
Clear Selected AnswerQuestion No 15
A process has a set of signal handlers and a signal mask. When this process createsnew threads
the signal handlers and the signal masks are copied over to individual threads' state
the signal handlers are shared among all the threads and the signal mask is copied over toindviduals thread's state
All the threads share the same signal handlers and the signal mask.
The signal handlers and the signal masks are not shared at all. They are only handled bythe parent thread.
Clear Selected Answer
Question No 16
A and B are two computer programs. Given a two by two grid represented by 1 2 3 4 Aand B share the grid structure. In other words the grid structure is a global. A starts atposition 1 and has to reach 4 and B starts at position 2 and has to reach position 3. Theprograms cannot move diagonally. A program cannot move to a position occupied byanother program. Here is the logic of the program running on A and B status = FAIL;while(1) { if position == destination position then status = SUCCESS; return status; else
move to the adjacent free location } return status; Both programs run uninterrupted ondifferent processors. Both programs start exactly at the same time t=0 and start toexecute the above logic. All conditions of processor speed/type/make, OS, memory andenvironmental factors are same for both programs Under the above conditions andassumptions:
the programs individually come to completion with SUCCESS status
the programs are in a state of deadlock
-
8/13/2019 Symantec Intern 2012
6/7
The programs are in a state of livelock
the programs individually come to completion but with FAIL status
Clear Selected Answer
Question No 17
Most databases these days allow users to build B-Tree indexes. Very few allow hash-table based indexes. Which of the following in your opinion is the most likely reason forthis:
A B-Tree index lookup is always faster than a hash-table based index lookup
A B-Tree index is much easier to implement than a hash-table based index
A hash-table based index cannot be used for answering range queries (i.e. queries of theform "x < CONSTANT")
A hash-table based index wastes a lot of disk-space and memory on empty buckets toreduce collisions
Clear Selected Answer
Question No 18
Multiplying a complex number (x + iy) by i, the square root of -1, is analogous to:
rotating point (x, y) about the origin clockwise by 90 degrees.
rotating point (x, y) about the origin counter-clockwise by 90 degrees.
rotating point (x, y) about the origin clockwise by 45 degrees.
rotating point (x, y) about the origin counter-clockwise by 45 degrees.
Clear Selected Answer
Question No 19
What is the ouput of the following function? void fn(void); main() { printf ("In Main ");atexit(fn); return 0; } void fn(void) { main; main(); }
This program will not compile.
This program will not link.
This program will print "In Main" once.
This program will print "In Main" forever.
Clear Selected Answer
Question No 20
-
8/13/2019 Symantec Intern 2012
7/7
What is the output of the following program? main() { const int x=get(); printf("%d",x); }get() { return(20); }
error
20
garbage value
0
Clear Selected Answer