# Embedded systems interview questions by yaofenjin

VIEWS: 146 PAGES: 80

• pg 1
									Embedded systems interview questions
1. Can structures be passed to the functions by value?
2. Why cannot arrays be passed by values to functions?
4. What happens when recursion functions are declared inline?
5. Scope of static variables?
6. Difference between object oriented and object based languages?
7. Multiple inheritance - objects contain howmany multiply inherited ancestor?
8. What are the 4 different types of inheritance relationship?
9. How would you find out the no of instance of a class?
10. Is java a pure object oriented language? Why?
11. Order of constructor and destructor call in case of multiple inheritance?
12. Can u have inline virtual functions in a class?
13. When you inherit a class using private keyword which members of base class are
visible to the derived class?
14. What is the output of printf("\nab\bcd\ref"); -> ef
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?
17. ++*ip increments what? it increments what ip points to
18. Operations involving unsigned and signed — unsigned will be converted to
signed
19. a+++b -> (a++)+b
20. malloc(sizeof(0)) will return — valid pointer
21. main() {fork();fork();fork();printf("hello world"); } — will print 8 times.
22. Array of pts to functions — void (*fptr[10])()
23. Which way of writing infinite loops is more efficient than others? there are
3ways.
24. # error — what it does?
25. How is function itoa() written?
26. Who to know wether systemuses big endian or little endian format and how to
convert among them?
27. What is interrupt latency?
28. What is forward reference w.r.t. pointers in c?
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?
31. What is interrupt latency? How can you recuce it?
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?
34. What are the features different in pSOS and vxWorks?
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?
36. What are the different storage classes in C?
37. What are the different qualifiers in C?
38. What are the different BSD and SVR4 communication mechanisms

Posted in: C++, Hardware |

45 Responses to “Embedded systems interview questions”

1. Taran Says:
April 14th, 2004 at 3:00 am

Q1. No they are always passed by reference. Think. Size of structure can be
arbitrarily large.
Q2. Same as above.
Q9. Declare a static variable, class variable, and increment(decrement) for every
constructor (destructor) called.
Q11. Constructor. Base to current. Destructor. current to base. Both are done
recursuively.
Q13. NONE
Q14. $> acd ef ->ef is wrong, what happened to acd? Q16. You can have a constant pointer to a volatile variable but not a constant volatile variable. Q26. Write a union of int and 2 chars. Store as int retrieve as chars. Q 27. Time taken between INT req and INT service. Q33. Study Let us C, Yeshwant Kanetkar 2. Sumeet Says: June 21st, 2004 at 3:52 am Q. 13 Answer posted is wrong. Public & protected members of base class will be visible to derived class, but not its objects. 3. Bhaskar Says: October 21st, 2004 at 9:26 am Q1 - YES, a complete structure can be passed. Regarding the size, it is true that they can be very large and hence it is not a good practice to do so. In any case, one can do if one wants to. 4. VijayaKumar Says: November 6th, 2004 at 2:16 am Q3. When using macro you can‘t use data type while passing it. But in Inline function you can have data types so that it can be checked. e.g MACRO : ADD(a,b) INLINE : inline void Add(int a,int b ); 5. Pawan Kumar Says: December 4th, 2004 at 2:44 am Q1. Yes structure can be passed by value but the overhead of copying large values will be there. hence not usable. We should pass it by pointer. Q2. Individual element can be passed by value of course. But not whole array. Q5. It is alive lifetime of process, and its scope is limited to function in which it is defined. file1.c ********** static int i; void main() { …….. } file2.c ********** extern int i; //error If declared global then it is visible in that file only. Q6. Object oriented language have Inheritance, polymorphism etc. But object based language only deal with object. Q7. If class D:public A,B,C {} then three ancestors Q8. public ,private, protected, virtual Q30. Hard RTS is having deadline defined and it is life critical ,should be reliable. late answer is wrong answer. in Soft RTS,process time should be predictable and reliable. 6. MKS Says: March 22nd, 2005 at 12:38 pm Q36.What are the different storage classes in C? A:Auto,Register,Static,Extern 7. Satish Parande Says: May 6th, 2005 at 2:01 am Q5 Scope of static variables is only within the block where it is declared. But the lifetime is till the process is running 8. Midhun V Says: May 13th, 2005 at 5:39 am Questin??? How can we dynamically allocate memory without using malloc() or calloc() or realloc()?Explain in Breif. Can any one help in finding this answer to this question…… 9. vsvraju Says: May 20th, 2005 at 4:33 pm In Java, we place even the Main() function inside a CLASS. But it is not the case with C++. So, i think this is one of the answers you can say, JAVA is Fully Obejct Oriented. 10. vsvraju Says: May 20th, 2005 at 4:43 pm Q11 : Base-class constructors are called in the order in which inheritance is specified in the derived-class definition. The order in which the Base-class constructors are specified in the derived-class member initializer list does not effect the order of construction. 11. vsvraju Says: May 20th, 2005 at 5:36 pm Q 12: Yes we can have. you are never guaranteed that a routine is inlined. It is only a suggestion to the compiler. If the routine is either too complicated or a virtual function,then a static copy of the routine will be placed in the compiled module. Thus, a routine that was coded as inline may cause a performance degradation because it may consume much more space when it is not physically inlined. With a virtual function, a copy of that routine will be created for every module that has at least one instantiation of that class. Q 13: NONE. None of the Public, Protected and Private data members are visible. Q 16: YES. We can have a const volatile variable. a volatile variable is a variable which can be changed by the extrenal events (like an interrput timers will increment the voltile varible. If you dont want you volatile varibale to be changed then declare them as ―const volatile‖. Q 17. I will explain this with an example: int a = 10; int *p = &a; // suppose &a = 4010 (address of a) Because both ++ and * are unary operators, the are calculated from right to left –> ++ (*p) ++*p will inrement 4010 by 4 (int size) -> ++*p will have the value 4014. Q 21: It will print 8 times. Because, each fork will print twice. if u flush, (using ―fflush‖), then it will be printed only once. thats is you need to flush the iostreams. Q 30: In Hard RTOS the latency should be less the 20ns (nano sec) in Soft RTOS the latency range 3ns - 20ns is also acceptable. 12. SANDRA Says: May 25th, 2005 at 11:15 am I THINK A BALOON CAN HAVE TO MUCH ELECTRICITY 13. Karan Says: August 5th, 2005 at 2:56 am Java is not a pure object oriented language as ―everything‖ in java is not an object. It still has primitive data types such as int, char, etc. which are NOT objects. Ruby is an example of a pure object oriented language, where ―everything‖ is an object, even int. 14. deepak Says: November 19th, 2005 at 12:37 am 16. It is possible to have ―const volatile‖ declaration. This indicates that the variable defined like this is not possible to change within that context. It can be changed by an external event. const declaraion just says that it will be readonly within the context, that area can be modified by an interrupt routine or another process. 18. Operations involving unsigned and signed - The signed data will be converted to unsigned - Refer arithemetic conversion rules in K&R 24. #error is used for displaying an error while compilation. for eg. #ifdef ABC printf(‖ABC‖); #else #ifdef DEF printf(DEF); #else #error ―Declaration not done‖ #endif 30. Hard RTOS is system which will be having major problems if the specified time limit is crossed. For eg. missiles Soft RTOS is systems which will not be having major problems if the specified limit is crossed. For eg. real time audio steaming. But for both exceeding the time limit is concidered as error. 31. Interrupt latency is the time period between interrupt on the pin to the execution of 1st instuction in the interrupt routine. THis will depend upon the processor. If the execution time for the instruction is less (like in RISC) this time will also be less. If register storage is required the time will be less in the processors in which remapping of registers is present as this can be done in a single instruction. 32. RTOS systems are embedded systems with time criticality. 33. 15. Ramesh K.B. Says: November 29th, 2005 at 2:30 am What is interrupt latency? It is the time interval between an interrupt has occured till the time it has been serviced. Mathematically: Int(lat)= rt+pt+dt where rt=recognition time pt=process time dt=dispatch time 16. Ramesh K.B. Says: November 29th, 2005 at 2:34 am Q. Write a function to reverse contents in a single linked list without reversing the links? Can anyone pls help me out? 17. Ramesh K.B. Says: December 8th, 2005 at 11:33 pm Q.Can we have a constant volatile variable? Soln: YES.We can have a const volatile variable. Volatile variable is one which can be changed by user,ie programmer as well as by the external events.If we declare it as const volatile,then user cannot change but can be changed by the hardware. 18. Ramesh.V Says: January 27th, 2006 at 1:04 am 20. malloc(sizeof(0)) will return — valid pointer yes. sizeof(0) –> int size and it is 4 25. itoa(…) itoa(pointer to storage buffer,int to convert, base(eg.binary,oct,hex,dec)) 33. typedef struct regset{ unsigned char onebit:1; unsigned char twobit:2; …. }regset; 19. Sushil Rana Says: February 9th, 2006 at 8:21 am i have an query regarding , interupts in Embedded systems can we use the interrupt function call same as ordinary function,i.e. can we pass arguments and return values from an ISR routine. 20. Sushil Rana Says: February 9th, 2006 at 8:24 am what happens when we put an infinite loop using for for(;;) what is the condition expression value by default. 21. Hetal Says: February 21st, 2006 at 7:24 am Write a function to reverse contents in a single linked list without reversing the links? Can anyone pls help me out? Count number of nodes in the linear linked list. Let say cnt is the number of nodes and index = 0. You can swap content of index th node and cnt-index th node, each time increment index by 1. All the contents will be reversed. 22. Guneet Says: March 26th, 2006 at 10:10 pm Scope of static variables? scope of static variables is limited to the local function in which it is defined and to the functions calling the stattic variable. 23. Satish Parande Says: June 5th, 2006 at 5:32 am How virtual tables are created in case of abstract classes? Is it the same as in non- abstract classes? Virtual tables r created on stack or Heap? 24. Satish Parande Says: June 5th, 2006 at 5:39 am why only reference is passed as a parameter in Copy constructor? why not address? 25. Mrinmay Biswas Says: July 5th, 2006 at 7:03 am is it possible to call delete from the class member function ? 26. Praveen Says: July 19th, 2006 at 2:23 am q.3. —- Inline is only a request that may be rejected also based on optimization policies,while macro is immediately replaced before compilation. —- type checking is not possible in Macros, but in inline its possible. 27. kaushik chakraborty Says: November 14th, 2006 at 12:42 am 30 . With all the new things going on in embedded device software and support, we thought now would be a good time to pour the RTOS chaos out on a big table, sort out the pieces, and see how the whole thing fits together (or doesn‘t) for the average system designer. After all, confusion abounds in the RTOS realm. With hard- and soft-RTOS, device software, embedded OS, open-source, commercial, commercial open-source, commercial-grade open-source, royalty-free… there is a confluence of ambiguous labels and categorizations constantly conspiring to confuse us as we seek to select the best OS for our embedded system. Wind River‘s announcements may help to tame some modicum of the mayhem. With the company‘s recently revised direction now coming into solid focus, the leading RTOS vendor is telling us that they‘ll be doing two major announcements and releases per year now, one in the fall, and one in the spring. They further break down their RTOS offering into two major categories – Commercial Linux and Commercial RTOS. A few weeks ago, in ―The People‘s RTOS‖, we took an in-depth look at Wind River‘s Linux offering, but that‘s only half of the story. In their most recent announcement, Wind River points out that they also lay claim to a full 42% of the 50% of the RTOS market that makes up commercial RTOS, while their commercial embedded Linux offering has skyrocketed to a full 39% of the 26% of the market that‘s using commercial Linux. Competitor Green Hills is happy to help our understanding with the further observation that their market share is growing faster than any other vendor, and analysts chime in that the entire market is now growing at an annual rate of 16-20%. Confused yet? Just whip out a PO and buy one already. The pain won‘t stop until you do. However, if we want to delve deeper than market share estimates in making one of our most critical embedded system design decisions, perhaps we should look at the RTOS question from a more technical point of view. Let‘s pocket that PO for awhile and do a bit more research. RTOS is one of the most over-applied and misused terms floating through the embedded technology space, and it pays to pause and take technical stock of what we‘re all talking about. ―RTOS‖ stands for Real Time Operating System, of course, but current common usage has expanded to include pretty much any operating system that isn‘t running on a traditional, general-purpose computer. Some have migrated to the more general ―embedded‖ operating system terminology, but even the ―embedded‖ concept has fallen out of favor in some circles, in favor of ―device‖ software or OS. Speaking of circles (and maybe in circles), just about every OS runs on a ―device‖ (hey, a supercomputer is a device, right?) so we‘ll probably just continue to abuse the ―RTOS‖ term until someone comes up with something clearly better. You can slice and dice the RTOS world several ways, and it‘s important to understand a few of these. First is the concept of ―hard‖ versus ―soft‖ RTOS. Hard RTOS is where the ―Real Time‖ components are in all capitals. If your application requires a predictable latency (always, really, no kidding, no matter what), and the consequences of missing an event deadline are catastrophic, you‘re probably in the market for a hard RTOS. If you don‘t mind if the RTOS you‘re using takes an occasional brief vacation to manage memory or do some other housekeeping task (as long as it‘s pretty snappy in interrupts most of the time), you‘re probably more on the soft RTOS side of things. Hard RTOS, such as VxWorks (from Wind River), QNX, pSOS, eCos, OSE and LynxOS (which offer a hard RTOS overlay/extension for real-time operation of Linux applications), INTEGRITY (From Green Hills Software), ThreadX (From both Express Logic and Green Hills Software), Microware OS-9 (from RadiSys), Windows CE, and Nucleus (from Mentor Graphics‘s/Accelerated Technology), go to great lengths to provide 100% predictable response to interrupts. Soft RTOS, such as embedded versions of Windows (except CE), Linux, and other modified or ported versions of general-purpose operating systems may have excellent response to interrupts, but do not guarantee that there will never be a longer than expected interrupt latency. It is important to remember the difference between performance and predictability in this case. A hard RTOS may not always have the best performance in terms of interrupt latency, but it will have predictable response so you can reliably plan your system design around it. A soft RTOS, even though it may sometimes have a shorter average interrupt latency, does not absolutely guarantee the timing. In addition to interrupt latency, it is also important to consider context switch time in evaluating RTOS performance. Context switch time is the amount of time your RTOS takes to save state for one task, load the context for another task, and begin execution. Measurement techniques for context switch time vary significantly, however, as there is no clear standard on what to measure, and also a large variation in performance depending on what amount of state information must be saved. It also pays to understand the difference between a static and a dynamic RTOS. In a dynamic RTOS, the system can change on-the-fly without stopping and reloading. A dynamic RTOS has a dynamic scheduler that can re-compute task priorities while running depending on the criticality of the task. Scheduling algorithms used in RTOS vary widely, and a detailed discussion is beyond the scope of this article. However, the selection of the most appropriate scheduling approach depends on the particular requirements of your application. For example, do some tasks have more flexibility in latency than others? Are some tasks regular while others happen very infrequently or irregularly? Are the consequences for missing a deadline dramatically different for different tasks that are being scheduled? All of these considerations come into play in picking the best scheduling scheme, which may affect your choice of RTOS. Next, we need to look at memory footprint, because embedded OS and RTOS sizes can vary dramatically. Some systems are designed for use in very low-cost, space-constrained portable devices with miserly memory allocations. Others are designed for very large and complex systems, rivaling (and sometimes exceeding) even the complexity of many general-purpose computers. A few are scalable depending on the complexity of your application and the size of the footprint you can tolerate. You can decide which OS components you need and custom- configure an OS that meets your needs (or is the best compromise) in space, speed, and capability. One final consideration is the choice of an open-source, commercial-grade open- source, or commercial OS. Open source RTOS (like embedded Linux) exploded in popularity a few years ago due to the lack of licensing and royalty fees, the unlimited customizability, and the easy access to expert developers. Unfortunately, many design teams discovered the ugly side of this tradeoff as well – proliferation of many disparate versions, unlimited customizability, and complete lack of support. These deficiencies led to the creation of ―commercial‖ and ―commercial grade‖ open source RTOS. Wind River tells us that these commercialized versions of Linux are rapidly gaining acceptance and market share, primarily at the expense of in-house development (based mostly on non-commercial open-source RTOS). Many teams see the best of both worlds in the commercially supported and tested open-source segment. Interestingly, the commercial RTOS market has largely held its own lately against the open-source incursion. For many companies, the additional level and single point of accountability has high value. For companies involved in high-security or defense-related design, there may be additional requirements (such as mandatory domestic content) that cannot be served by any open-source system. Commercial RTOS are also available on royalty-based and royalty-free variants, and the licensing business model may affect our engineering decision as well. Speaking of security, all forms of protection are increasing in importance these days. Consumer electronics companies want to protect their valuable IP from unscrupulous copycats. Companies developing networked applications want solid security strategies to reassure customers that their data is safe in the hands of their embedded devices, and military and government applications still see system security as highest priority. Wind River‘s recent announcement, for example, prominently mentions a number of security-related enhancements. Security can‘t be an afterthought in a new system design, so we should always make a careful assessment of our system‘s particular security requirements before we start locking ourselves into a particular system architecture. So what RTOS will your embedded design be wearing this fall? With the fantastic array of available options, the hardest part is sometimes just choosing one. If nothing grabs your attention, though, don‘t despair. Spring is just around the corner and we‘re sure to see a whole new lineup of device software wonderment just in time for the change of season. 28. kaushik chakraborty Says: November 14th, 2006 at 12:45 am 30. Hard and Soft Real-Time Systems A classification can be made into hard and soft real-time systems based on their properties. The properties of a hard real-time system are: No lateness is accepted under any circumstances Useless results if late Catastrophic failure if deadline missed Cost of missing deadline is infinitely high A good example of a hard real-time system is the fly-by wire control system of an aircraft. A soft real-time system is characterised by: Rising cost for lateness of results Acceptance of lower performance for lateness Examples are a vending machine and a network interface subsystem. In the latter you can recover from a missed packet by using one or another network protocol asking to resend the missed packet. Of course, by doing so, you accept system performance degradation. Other real-time systems examples are nuclear power plant control, industrial manufacturing control, me-dical monitoring, weapon delivery systems, space na- vigation and guidance, reconnaissance systems, laboratory experiments control, automobile engines control, robotics, telemetry control systems, printer controllers, anti-lock breaking, burglar alarms — the list is endless. The difference between a hard and a soft real-time system depends on the system requirements: it is called hard if the requirement is ―the system shall not miss a deadline‖ and soft if ―the system should not miss a deadline‖. There are a lot of discussions going on about the exact meaning of a hard and soft real-time system. One could even argue that a soft real-time system is not a real- time system, as the first requirement: meet deadlines, is not met. Indeed, the term ―real-time‖ is often misused to indicate a fast system. And fast can then be seen as ―should meet timing deadlines‖, thus meaning a soft real-time system. Therefore, we define a RTOS as an OS that can be used to build a hard real-time system. Hard or Soft RTOS do not exist! People often confuse the notion of real-time systems with real-time operating systems (RTOS). From time to time people, even misuse hard and soft attributes. They say this RTOS is a hard RTOS or this one is a soft one. There is no hard RTOS or soft RTOS. A specific RTOS can only allow you to develop a hard real- time system. But having such an RTOS will not prevent you from developing a system that does not meet deadlines. If, for example, you decide to build a real-time system that should respond to an Ethernet TCP/IP connection, it will never be a hard real-time system as the Ethernet itself is never predictable. Of course, if you decide to build an application on top of an OS like ―Windows 3.11‖, your system will never be a hard real-time system as the behaviour of the ―OS‖ software is by no means predictable. 29. kaushik chakraborty Says: November 14th, 2006 at 12:57 am Difference between Semaphore & Mutex ==================================== by default mutex is full(1) but by default semaphore is empty(0). semaphore can be 2 types. 1) binary semaphore 2) counting semaphore The binary semaphore can have the value of 1 or 0 but counting semaphore can have any numaric values. mutex is similar to binary semaphore, but the difference between both of them is as exaplain above and the following one. If a resource is locked by a thread using mutex, then that particular thread only can unlock that resource, but in the case of semaphore, if any resource is locked by semaphore then that lock can be released or the resource can be unlocked by any thread according to the algorithm used for developing the code for that. 30. Anand Says: November 24th, 2006 at 4:22 am /* Function to reverse singly link list */ void reverse(NODE *head) { NODE *prev, *nxt, *current; prev = NULL; current = head; while(current != NULL) { nxt = current->next; current->next = prev; prev = current; current = nxt; } return(prev); } 31. Anand Says: November 24th, 2006 at 4:36 am void reverse(NODE *head) should be NODE *reverse(NODE *head) 32. Anand Says: November 24th, 2006 at 4:39 am void fun_atoi() { char *p=‖128″; int n=0; while(*p != ‖) n = n * 10 + *p++ - ‗0′; printf(‖\n %d\n‖, n); } 33. Anand Says: November 24th, 2006 at 4:45 am write a program to find whether no is power of two or not? ANS: when no is power of two then only one bit will be set to 1. Normally we check all the bits and if count = 1 then we say no is power of two. Now its worst and best case time comlexity will be O(n) = n where n is the total no of bits. even we can write same program with constant time complexity O(n) = 1 as follows if ((n &(n-1)) == 0) printf(‖Power of two!‖); it takes constant time complexity. 34. Anand Says: November 24th, 2006 at 4:52 am Ramesh K.B. said, Q. Write a function to reverse contents in a single linked list without reversing the links? Can anyone pls help me out? ANS: void print_reverse(NODE *head) { NODE *stored, *list; stored = NULL; while (head != stored) { for(list = head; list->next != stored; list=list->next); stored = list; printf(‖%d‖, list->data); } } 35. srinivas Says: January 24th, 2007 at 3:47 am HI to everybody can any body tell me wht make the scheduler to invoke the blocked task when the other task releases semaphore is it done by a interrupt or some thing else this was the question asked by interviewer to me and i said its interrupt i think i am correct, if not just mail me thanks in advance for ur asnwer thanku 36. srinivas Says: January 24th, 2007 at 3:49 am Q. how to find the header(first node) if the pointer to tail(last node )is given in a single linked list? anyone please help me 37. divya Says: February 9th, 2007 at 12:08 am hi, plzzzzzzzzz help me in this following Qestions 1)What is Memory MEMLOC ? How do express, where do use it? 2)What is data structure? How do you write data structure in ―C‖ cod ? 3)What is the Function call, where do you? 4) How do you express binary to hex or hex to binay conversion in‖C‖ code? 5) Write sort algoritham dn prepare ―C‖ code 38. Sathiyanarayanan Says: May 24th, 2007 at 1:47 am Q15: Macro expanding becomes illegal if done recursively 39. vaishali Says: June 9th, 2007 at 2:25 am What is the output of printf(‖\nab\bcd\ref‖); -> ef wrong!! the answer comes out to be efd 40. Neeraj Says: June 19th, 2007 at 2:45 am Q1. Can structures be passed to the functions by value? A1. Yes, by default they are passed by value Q2. Why cannot arrays be passed by values to functions? A2 array name is itself a pointer to zero element in array Q4. Scope of static variables? A4. If defined inside function, scope is limited in the function. If defined inside the file outside the function than they r global variable but scope limited to the file in which its defined Q11. What is the output of printf(‖\nab\bcd\ref‖); A. efd Q12. #define cat(x,y) x##y concatenates x to y. But cat(cat(1,2),3) does not expand but gives preprocessor warning. Why? A. lvalue required Q13. Can you have constant volatile variable? Yes, you can have a volatile pointer? A. Yes in both case Q14. ++*ip increments what? A. increment what ip points to Q15. Operations involving unsigned and signed A. signed will be prmoted to unsigned Q16. a+++b A. a++ + b Q17. malloc(sizeof(0)) will return A. Valid pointer Q18.main() {fork();fork();fork();printf(‖hello world‖); } A. will print 8 times. Q19. Array of pts to functions A. void (*fptr[10])() Q20.Which way of writing infinite loops is more efficient than others? A. there are 3ways. while(1) {;} for(;;) {;} label: goto label; Q21. # error ? what it does? A. preprocessor will generate error message and causes the compilation to fail Q23. Who to know wether systemuses big endian or little endian format and how to convert among them? A. main() { int a=0×1; if(*(char *)&a == 1) printf(‖little endian‖); else printf(‖big endian‖); } Q30. How can you define a structure with bit field members? A. struct abc { unsigned int a:1; unisgned int b:2; }; Q33. What are the different storage classes in C? A. automatic & static Q34. What are the different qualifiers in C? A. const & volatile 41. Neeraj Says: June 19th, 2007 at 2:50 am Q32. 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? A. int func(char a, int n) {return a & (1 42. dunbi Says: September 30th, 2007 at 12:19 am 14. What is the output of printf(‖\nab\bcd\ref‖); Answer: new line and then will print ‗efd‘ Now why is that: ‗\n‘ will do a new line then print ‗ab‘ then ‗\b‘ will delete the ‗b‘ in ‗ab‘ so we left with ‗a‘ then will print ‗cd‘ so now we have ‗\nacd‘ ‗\r‘ is carriage return, which will go back to the start of the line So now the cursor is on the ‗a‘ letter in the start of the line. Now we print ‗ef‘ but and its GREAT BUT, the ‗ef‘ letters start to write in the start of the line, so ‗ef‘ is written on ‗ac‘, but we had ‗acd‘ written, so now we have ‗efd‘. Now you understand why the ‗\n‘ in the start, its there to make sure the ‗a‘ will print in the start of the line, else the output will not be predictable. 43. Prasanth Says: November 6th, 2007 at 4:17 am 33A. extern, static, auto and Register comes under storage classes 44. Khan Says: November 19th, 2007 at 11:48 am How can we dynamically allocate memory without using malloc() or calloc() or realloc()?Explain in Breif. using arrays such as int int_array[10] //10*4 = 40 bytes , char ch_array[10] // 10 bytes 45. shailesh Says: April 26th, 2008 at 12:47 am 4.What happens when recursion functions are declared inline? Since the number of recursions is unknown until run time, the compiler cannot generate the inline code at compile time. Most compilers inline only the first call, if any. Avoid inlining recursive functions and watch out for infinite recursion (where a function calls itself forever, analogous to infinite loops with constructs). DAC interview questions 1. What is the IC numbers for DAC that you have used in the lab? 2. Define resolution. What is the resolution of DAC that you have used in the lab? 3. How many pins does DAC IC have? 4. What are the types of DAC? 5. Which technique you have used for DAC interfacing 6. Which type of DAC you have used in the lab? 7. Define all the specifications of DAC. 8. What are the advantages of binary ladder type DAC over weighted resistance type DAC? 9. What are the applications of DAC? 10. Explain block diagram IC 0808? 11. Explain the logic of DAC program. 12. Explain the interfacing of DAC with 8086. Posted in: Hardware | 4 Responses to “DAC interview questions” 1. mruali krishnan Says: April 19th, 2007 at 6:14 am question no:2 Resolution: This is the number of possible output levels the DAC is designed to reproduce. This is usually stated as the number of bits it uses, which is the base two logarithm of the number of levels. For instance a 1 bit DAC is designed to reproduce 2 (21) levels while an 8 bit DAC is designed for 256 (28) levels. Resolution is related to the Effective Number of Bits (ENOB) which is a measurement of the actual resolution attained by the DAC. I used a 8-bit resolution DAC chip in my lab 2. mruali krishnan Says: April 19th, 2007 at 6:51 am Question no:4 1.PWM DAc 2.Oversampling comonly known as Delta sigma DAC 3.Binary Weighted DAC 4.R-2R Ladder DAC 5.Thermometer Coded DAC 6.Segmented DAC 7.Hybrid DAC 3. mruali krishnan Says: April 19th, 2007 at 6:57 am Question no:8 The Binary Weighted DAC, which contains one resistor or current source for each bit of the DAC connected to a summing point. This is one of the fastest conversion methods but suffers from poor accuracy because of the high precision required for each individual voltage or current. The R-2R Ladder DAC, which is a binary weighted DAC that uses a repeating cascaded structure of resistor values R and 2R. This improves the precision due to the relative ease of producing equal valued matched resistors (or current sources). 4. mruali krishnan Says: April 19th, 2007 at 7:01 am Question no:9 DAC have a wide application on Audio and Video devices were the out is converted to digital to analog signal. 8251 USART interview questions 1. What is IC 8251? 2. How many pins does IC 8251 have? 3. What is USART? 4. Why 8251 is called a USART? 5. What is simplex half & full duplex modes of communication? 6. What is the difference between asynchronous & synchronous mode of communication? 7. Explain control word format of 8251? 8. Define frame in asynchronous communication and draw it. 9. Define baud rate. 10. Define bit rate. 11. Define mode word register of 8251 for asynchronous mode.. 12. Define mode word register of 8251 for sync mode.. 13. What is the significance of SYNC DETECT signal in 8251? 14. What is the significance of BREAK DETECT signal in 8251? 15. Define command word register of 8251. 16. Define status word register of 8251. 17. What are the applications of 8251? 18. Whether write operation is possible with status word register? 19. Whether operation read is possible with command word register? 20. What is parity error in 8251? 21. What is over run error in 8251? 22. What is frame error in 8251? 23. What is hunt mode in 8251? 24. Explain block diagram IC 8251? 25. Explain the logic of 8251 program. 26. Explain the interfacing of 8251 with 8086. Posted in: Hardware | 12 Responses to “8251 USART interview questions” 1. athulya Says: July 19th, 2007 at 6:19 am frame error: indicates a missing stop bit. This error can only happen when the communication settings of transmitter and receiver (e.g. baud-rate) don‘t match, when the connection was lost, or the transmitter is faulty 2. athulya Says: July 19th, 2007 at 6:20 am ans 22: frame error: indicates a missing stop bit. This error can only happen when the communication settings of transmitter and receiver (e.g. baud-rate) don‘t match, when the connection was lost, or the transmitter is faulty 3. athulya Says: July 19th, 2007 at 6:22 am ans 21: overrun error: indicates that a new data character was received before the previously character was read by the host microprocessor. A data loss occured 4. linu Says: July 19th, 2007 at 6:24 am ans 20: parity error: set when the parity of an incoming data character does not match the expected value. 5. athulya Says: July 19th, 2007 at 6:50 am ans 10:In telecommunications and computing, bitrate (sometimes written bit rate, data rate or as a variable R or fb) is the number of bits that are conveyed or processed per unit of time. Bit rate is synonymous to data rate and digital bandwidth. 6. athulya Says: July 25th, 2007 at 1:54 am ans 1:The 8251 is a USART (Universal Synchronous Asynchronous Receiver Transmitter) for serial data communication. As a peripheral device of a microcomputer system, the 8251 receives parallel data from the CPU and transmits serial data after conversion. This device also receives serial data from the outside and transmits parallel data to the CPU after conversion 7. athulya Says: July 25th, 2007 at 1:55 am USART (Universal Synchronous Asynchronous Receiver Transmitter) for serial data communication. As a peripheral device of a microcomputer system, it receives parallel data from the CPU and transmits serial data after conversion. This device also receives serial data from the outside and transmits parallel data to the CPU after conversion 8. shruti Says: July 25th, 2007 at 1:56 am ans 3:USART (Universal Synchronous Asynchronous Receiver Transmitter) for serial data communication. As a peripheral device of a microcomputer system, it receives parallel data from the CPU and transmits serial data after conversion. This device also receives serial data from the outside and transmits parallel data to the CPU after conversion 9. shruti Says: July 25th, 2007 at 3:15 am ans 5: A simplex mode of communication is one where all signals can flow in only one direction. A half-duplex system provides for communication in both directions, but only one direction at a time (not simultaneously). Typically, once a party begins receiving a signal, it must wait for the transmitter to stop transmitting, before replying. A full-duplex system allows communication in both directions, and unlike half- duplex, allows this to happen simultaneously. Land-line telephone networks are full-duplex since they allow both callers to speak and be heard at the same time. 10. shruti Says: July 25th, 2007 at 3:47 am ans 6: In synchronous communications the transmitter and receiver clock have to be exactly synchronized. Synchronous communications has constant bit rate. In asynchronous communications the transmitter and receiver clock do not have to be exactly synchronized. Asynchronous communications is variable bit rate. 11. logamurthy Says: September 4th, 2007 at 12:37 am Ans 9: number of samples transmitted or processed per second is baud rate. for example at particular time number of cars(samples) passed on the road is baud rate. 12. bharathkumar.s Says: December 18th, 2007 at 5:42 am q-2 40 pins IC 8253 and IC 8259 interview questions 1. What is IC 8253? 2. How many pins does IC 8253 have? 3. How many counters are there in 8253? 4. What is the size of counters in 8253? 5. With binary & BCD counters, what is the range of count? 6. Explain control word format of 8253? 7. Define & explain mode ‗0′ of 8253? 8. Define & explain mode ‗1′ of 8253? 9. Define & explain mode ‗2′ of 8253? 10. Define & explain mode ‗3′ of 8253? 11. Define & explain mode ‗4′ of 8253? 12. Define & explain mode ‗5′ of 8253? 13. What is the difference between software and hardware triggered modesof 8253? 14. What is the difference between 8253 and 8254? 15. What is read back command in 8254? 16. What are the applications of 8253? 17. Explain block diagram IC 8253? 18. Explain the logic of 8253 program. 19. Explain the interfacing of 8253 with 8086. 20. What is IC 8259? 21. How many pins does IC 8259 have? 22. Explain all initialization and operational command word format of 8259? 23. With single 8259 how many interrupts are possible? 24. With cascading mode of 8259 how many interrupts are possible? 25. How many 8259 ICs will be required for cascading mode? 26. What is the difference between polled command mode and vectored (interrupt driven) command mode of 8259? 27. What are the applications of 8259? Posted in: Hardware | 2 Responses to “IC 8253 and IC 8259 interview questions” 1. ram Says: April 10th, 2008 at 1:34 am ans 1: it s a timer/counter IC. 2. ram Says: April 10th, 2008 at 1:35 am ans 3: 3 coutes counter 0,1,2 Interview questions for a low-level programmer 1. What is assembler? 2. What is linker? 3. What is debugger? 4. What is compiler? 5. What is locator? 6. What is emulator? 7. When divide overflow error occurs? 8. What does .startup stand for? 9. Explain the logic of array addition program. 10. Explain the logic of finding out negative numbers from an array of signed numbers. 11. Explain the logic of code conversion (BCD to hex and hex to BCD) program. 12. Explain the logic of multiplication (by successive addition and shift and add method) program. 13. Explain the logic of non overlap and overlap block transfer program. 14. Explain the logic of string-related programs. 15. Which assembler directives are used with near procedure? 16. Which assembler directives are used with far procedure? 8086 interview questions 1. How many bits does 8086 microprocessor have? 2. What is the size of data bus in 8086? 3. What is the size of address bus in 8086? 4. What is the max memory addressing capacity of 8086? 5. Which are the basic parts of 8086? 6. What are the functions of BIU? 7. What are the functions of EU? 8. How many pin IC 8086 is? 9. What IC8086 is? 10. What is the size of instruction queue in 8086? 11. What is the size of instruction queue in 8088? 12. Which are the registers present in 8086? 13. What is pipelining in 8086? 14. How many 16 bit registers are available in 8086? 15. Specify addressing modes for any instruction? 16. What is assembler directives? 17. What .model small stands for? 18. What is the supply requirement of 8086? 19. What is the relation between 8086 processor frequency & crystal frequency? 20. Functions of Accumulator or AX register? 21. Functions of BX register? 22. Functions of CX register? 23. Functions of DX register? 24. How Physical address is generated? 25. Which are pointers present in this 8086? 26. Which is by default pointer for CS/ES? 27. How many segments present in it? 28. What is the size of each segment? 29. Basic difference between 8085 and 8086? 30. Which operations are not available in 8085? 31. What is the difference between min mode and max mode of 8086? 32. What is the difference between near and far procedure? 33. What is the difference between Macro and procedure? 34. What is the difference between instructions RET & IRET? 35. What is the difference between instructions MUL & IMUL? 36. What is the difference between instructions DIV & IDIV? 37. What is difference between shifts and rotate instructions? 38. Which are strings related instructions? 39. Which are addressing modes and their examples in 8086? 40. What does u mean by directives? 41. What does u mean by Prefix? 42. What .model small means? 43. Difference between small, medium, tiny, huge? 44. What is dd, dw, db? 45. Interrupts in 8086 and there function. 46. What is the function of 01h of Int 21h? 47. What is the function of 02h of Int 21h? 48. What is the function of 09h of Int 21h? 49. What is the function of 0Ah of Int 21h? 50. What is the function of 4ch of Int 21h? 51. What is the reset address of 8086? 52. What is the size of flag register in 8086? Explain all. 53. What is the difference between 08H and 01H functions of INT 21H? 54. Which is faster- Reading word size data whose starting address is at even or at odd address of memory in 8086? 55. Which are the default segment base: offset pairs? 56. Can we use SP as offset address holder with CS? 57. Which are the base registers in 8086? 58. Which is the index registers in 8086? 59. What is segment override prefix? 60. Whether micro reduces memory requirements? 61. What is macro? 62. What is diff between macro and procedure? 63. Types of procedure? 64. What TASM is? 65. What TLINK is? 66. What TD is? 67. What do u mean by assembler? 68. What do u mean by linker? 69. What do u mean by loader? 70. What do u mean by compiler? 71. What do u mean by emulator? 72. Stack related instruction? 73. .stack 100 means? 74. What is 20 dup (0)? 75. Which flags of 8086 are not present in 8085? 76. What is the size of flag register? 77. Can you perform 32 bit operation with 8086? How? 78. Whether 8086 is compatible with Pentium processor? 79. What is 8087? How it is different from 8086? 80. While accepting no. from user why u need to subtract 30 from that? 81. While displaying no. from user why u need to add 30 to that? 82. What are ASCII codes for nos. 0 to F? 83. How does U differentiate between positive and negative numbers? 84. What is range for these numbers? 85. Which no. representation system you have used? 86. What is LEA? 87. What is @data indicates in instruction- MOV ax, @data? 88. What is maximum size of the instruction in 8086? 89. Why we indicate FF as 0FF in program? 90. What is mul BX and div BX? Where result goes? 91. Where queue is present? 92. What is the advantage of using internal registers? 93. What is SI, DI and their functions? 94. Which are the pointers used in 8086 and their functions? 95. What is a type of queue in 8086? 96. What is minimum mode of 8086? 97. What is maximum mode of 8086? 98. Which are string instructions? 99. In string operations which is by default string source pointer? 100. In string operations which is by default string destination pointer? C++ object-oriented questions 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 17. Differentiate between a template class and class template. Template class: A generic definition or a parameterized class not instantiated until the client provides the needed information. It‘s jargon for plain templates. Class template: A class template specifies how individual classes can be constructed much like the way a class specifies how individual objects can be constructed. It‘s jargon for plain classes. 18. When does a name clash occur? A name clash occurs when a name is defined in more than one place. For example., two different class libraries could give two different classes the same name. If you try to use many class libraries at the same time, there is a fair chance that you will be unable to compile or link the program because of name clashes. 19. Define namespace. It is a feature in C++ to minimize name collisions in the global name space. This namespace keyword assigns a distinct name to a library that allows other libraries to use the same identifier names without creating any name collisions. Furthermore, the compiler uses the namespace signature for differentiating the definitions. 20. What is the use of „using‟ declaration. A using declaration makes it possible to use a name from a namespace without the scope operator. 21. What is an Iterator class? A class that is used to traverse through the objects maintained by a container class. There are five categories of iterators: input iterators, output iterators, forward iterators, bidirectional iterators, random access. An iterator is an entity that gives access to the contents of a container object without violating encapsulation constraints. Access to the contents is granted on a one-at-a-time basis in order. The order can be storage order (as in lists and queues) or some arbitrary order (as in array indices) or according to some ordering relation (as in an ordered binary tree). The iterator is a construct, which provides an interface that, when called, yields either the next element in the container, or some value denoting the fact that there are no more elements to examine. Iterators hide the details of access to and update of the elements of a container class. The simplest and safest iterators are those that permit read-only access to the contents of a container class. 22. List out some of the OODBMS available. GEMSTONE/OPAL of Gemstone systems, ONTOS of Ontos, Objectivity of Objectivity Inc, Versant of Versant object technology, Object store of Object Design, ARDENT of ARDENT software, POET of POET software. 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). 24. What is an incomplete type? Incomplete types refers to pointers in which there is non availability of the implementation of the referenced location or it points to some location whose value is not available for modification. 25. int *i=0x400 // i points to address 400 26. *i=0; //set the value of memory location pointed by i. Incomplete types are otherwise called uninitialized pointers. 27. What is a dangling pointer? 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 function or using the address of the memory block after it is freed. The following code snippet shows this: 28. class Sample 29. { 30. public: 31. int *ptr; 32. Sample(int i) 33. { 34. ptr = new int(i); 35. } 36. 37. ~Sample() 38. { 39. delete ptr; 40. } 41. void PrintVal() 42. { 43. cout << "The value is " << *ptr; 44. } 45. }; 46. 47. void SomeFunc(Sample x) 48. { 49. cout << "Say i am in someFunc " << endl; 50. } 51. 52. int main() 53. { 54. Sample s1 = 10; 55. SomeFunc(s1); 56. s1.PrintVal(); 57. } In the above example when PrintVal() function is called it is called by the pointer that has been freed by the destructor in SomeFunc. 58. Differentiate between the message and method. Message: o Objects communicate by sending messages to each other. o A message is sent to invoke a method. Method o Provides response to a message. o It is an implementation of an operation. 59. What is an adaptor class or Wrapper class? 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. 60. What is a Null object? It is an object of some class whose purpose is to indicate that a real object of that class does not exist. One common use for a null object is a return value from a member function that is supposed to return an object with some specified properties but cannot find such an object. 61. What is class invariant? A class invariant is a condition that defines all valid states for an object. It is a logical condition to ensure the correct working of a class. Class invariants must hold when an object is created, 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. 62. What do you mean by Stack unwinding? It is a process during exception handling when the destructor is called for all local objects between the place where the exception was thrown and where it is caught. 63. Define precondition and post-condition to a member function. Precondition: A precondition is a condition that must be true on entry to a member function. A class is used correctly if preconditions are never false. An operation is not responsible for doing anything sensible if its precondition fails to hold. For example, the interface invariants of stack class say nothing about pushing yet another element on a stack that is already full. We say that isful() is a precondition of the push operation. Post-condition: A post-condition is a condition that must be true on exit from a member function if the precondition was valid on entry to that function. A class is implemented correctly if post-conditions are never false. For example, after pushing an element on the stack, we know that isempty() must necessarily hold. This is a post-condition of the push operation. 64. 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. 65. What are proxy objects? Objects that stand for other objects are called proxy objects or surrogates. 66. template <class t=""> 67. class Array2D 68. { 69. public: 70. class Array1D 71. { 72. public: 73. T& operator[] (int index); 74. const T& operator[] (int index)const; 75. }; 76. 77. Array1D operator[] (int index); 78. const Array1D operator[] (int index) const; 79. }; The following then becomes legal: Array2D<float>data(10,20); cout<<data[3][6]; // fine Here data[3] yields an Array1D object and the operator [] invocation on that object yields the float in position(3,6) of the original two dimensional array. Clients of the Array2D class need not be aware of the presence of the Array1D class. Objects of this latter class stand for one-dimensional array objects that, conceptually, do not exist for clients of Array2D. Such clients program as if they were using real, live, two-dimensional arrays. Each Array1D object stands for a one-dimensional array that is absent from a conceptual model used by the clients of Array2D. In the above example, Array1D is a proxy class. Its instances stand for one-dimensional arrays that, conceptually, do not exist. 80. Name some pure object oriented languages. Smalltalk, Java, Eiffel, Sather. 81. Name the operators that cannot be overloaded. sizeof, ., .*, .->, ::, ?: Salam in the comments notes that -> can be overloaded. 82. What is a node class? A node class is a class that, o relies on the base class for services and implementation, o provides a wider interface to the users than its base class, o relies primarily on virtual functions in its public interface o depends on all its direct and indirect base class o can be understood only in the context of the base class o can be used as base for further derivation o can be used to create objects. A node class is a class that has added new services or functionality beyond the services inherited from its base class. 83. What is an orthogonal base class? If two base classes have no overlapping methods or data they are said to be independent of, or orthogonal to each other. Orthogonal in the sense means that two classes operate in different dimensions and do not interfere with each other in any way. The same derived class may inherit such classes with no difficulty. 84. What is a container class? What are the types of container classes? A container class is a class that is used to hold objects in memory or external storage. A container class acts as a generic holder. A container class has a predefined behavior and a well-known interface. A container class is a supporting class whose purpose is to hide the topology used for maintaining the list of objects in memory. When a container class contains a group of mixed objects, the container is called a heterogeneous container; when the container is holding a group of objects that are all the same, the container is called a homogeneous container. Basic programming questions 1. Design a data structure such that given a stream of numbers, you can find the maximum of the numbers at any point and also all the numbers. 2. Given an array of 1s and 0s arrange the 1s together and 0s together in a single scan of the array. Optimize the boundary conditions. 3. Find the common ancestor of two given nodes in a binary tree, how do you exploit the properties of a given BST for the same problem. 4. You‘re given a function getsort(data) that sorts the data given. The function sorts in place and does not use any extra memory. How do you validate the function with respect to 1) it sorts 2) it does not use extra memory 5. Explain the Traveling Salesman problem? What is an NP-complete problem? What is the Hamiltonian cycle problem? 6. Find out the least common ancestor in a binary tree. Simple C++ interview questions 1. What is the most efficient way to reverse a linklist? 2. How to sort & search a single linklist? 3. Which is more convenient - single or double-linked linklist? Discuss the trade- offs? What about XOR-linked linklist? 4. How does indexing work? 5. char s[10]; s=”Hello”; printf(s); What will be the output? Is there any error with this code? 6. What is the difference between char s[]=”Hello”; char *s=”Hello”; Please give a clear idea on this? 7. Why do we pass a reference for copy constructors? If it does shallow copy for pass by value (user defined object), how will it do the deep copy? 8. What is the difference between shallow copy & deep copy? 9. What is the difference between strcpy and memcpy? What rule should we follow when choosing between these two? 10. If we declare two variable and two applications are using the same variable, then what will its value be, will it be the same? 11. What is a void return type? 12. How is it possible for two String objects with identical values not to be equal under the == operator? 13. What is the difference between a while statement and a do statement? 14. Can a for statement loop indefinitely? 15. How do you link a C++ program to C functions? 16. How can you tell what shell you are running on UNIX system? 17. How do you find out if a linked-list has an end? (i.e. the list is not a cycle) 18. How do you write a function that can reverse a linked-list? 19. Can a copy constructor accept an object of the same class as parameter, instead of reference of the object? 20. What is a local class? 21. What is a nested class? 22. What are the access privileges in C++? What is the default access level? 23. What is multiple inheritance(virtual inheritance)? What are its advantages and disadvantages? 24. How do you access the static member of a class? 25. What does extern int func(int *, Foo) accomplish? This set of C++ interview questions was sent to TechInterviews from Australia: 1. What is the difference between an ARRAY and a LIST? 2. What is faster : access the element in an ARRAY or in a LIST? 3. Define a constructor - what it is and how it might be called (2 methods). 4. Describe PRIVATE, PROTECTED and PUBLIC – the differences and give examples. 5. What is a COPY CONSTRUCTOR and when is it called (this is a frequent question !)? 6. Explain term POLIMORPHISM and give an example using eg. SHAPE object: If I have a base class SHAPE, how would I define DRAW methods for two objects CIRCLE and SQUARE. 7. What is the word you will use when defining a function in base class to allow this function to be a polimorphic function? 8. What are 2 ways of exporting a function from a DLL? 9. You have two pairs: new() and delete() and another pair : alloc() and free(). Explain differences between eg. new() and malloc() 10. What is a callback function. Explain in C and C++ and WIN API environment. 11. (From WINDOWS API area): what is LPARAM and WPARAM? C++ developer interview 1. Will the following program execute?void main() { void *vptr = (void *) malloc(sizeof(void)); vptr++; } 2. How about this one? void main() { char *cptr = 0?2000; long *lptr = 0?2000; cptr++; lptr++; printf(” %x %x”, cptr, lptr); }Will it execute or not? 3. When the processor wakes up after power on, it goes to a particular memory location. What is that memory location called? 4. What is the difference between Mutex and Binary semaphore? 5. Write a program to set 2nd bit in a 32 bit register with memory location 0×2000? C questions for a hardware engineer 1. What are the total number of lines written in C/C++? What is the most complicated/valuable program written in C/C++? 2. What compiler was used? 3. Have you studied buses? What types? 4. Have you studied pipelining? List the 5 stages of a 5 stage pipeline. Assuming 1 clock per stage, what is the latency of an instruction in a 5 stage machine? What is the throughput of this machine ? 5. How many bit combinations are there in a byte? 6. What is the difference between = and == in C? 7. Are you familiar with VHDL and/or Verilog? Tricky C questions 1. How do you write a program which produces its own source code as its output? 2. How can I find the day of the week given the date? 3. Why doesn‘t C have nested functions? 4. What is the most efficient way to count the number of bits which are set in a value? 5. How can I convert integers to binary or hexadecimal? 6. How can I call a function, given its name as a string? 7. How do I access command-line arguments? 8. How can I return multiple values from a function? 9. How can I invoke another program from within a C program? 10. How can I access memory located at a certain address? 11. How can I allocate arrays or structures bigger than 64K? 12. How can I find out how much memory is available? 13. How can I read a directory in a C program? 14. How can I increase the allowable number of simultaneously open files? 15. What‘s wrong with the call fopen(”c:\newdir\file.dat”, “r”)? C++ notes for discussion This is not really a set of interview questions, a reader sent TechInterviews.com what looks like a copy of his notes from C++ class that describes various tricks and code for C++. 1. What is the output of printf(“%d”)? 1. %d helps to read integer data type of a given variable 2. when we write (―%d‖, X) compiler will print the value of x assumed in the main 3. but nothing after (―%d‖) so the output will be garbage 4. printf is an overload function doesnt check consistency of the arg list – segmentation fault 2. What will happen if I say delete this? - destructor executed, but memory will not be freed (other than work done by destructor). If we have class Test and method Destroy { delete this } the destructor for Test will execute, if we have Test *var = new Test() 1. pointer var will still be valid 2. object created by new exists until explicitly destroyed by delete 3. space it occupied can be reused by new 4. delete may only be applied to a pointer by new or zero, applying delete to zero = no FX 5. delete = delete objects 6. delete[] – delete array 7. delete operator destroys the object created with new by deallocating the memory assoc. with the object 8. if a destructor has been defined fir a class delete invokes that desructor 3. Difference between C structure and C++ structure - C++ places greater emphasis on type checking, compiler can diagnose every diff between C and C++ 1. structures are a way of storing many different values in variables of potentially diff types under under the same name 2. classes and structures make program modular, easier to modify make things compact 3. useful when a lot of data needs to be grouped together 4. struct Tag {…}struct example {Int x;}example ex; ex.x = 33; //accessing variable of structure 5. members of a struct in C are by default public, in C++ private 6. unions like structs except they share memory – allocates largest data type in memory - like a giant storage: store one small OR one large but never both @ the same time 7. pointers can point to struct: 8. C++ can use class instead of struct (almost the same thing) - difference: C++ classes can include functions as members 9. members can be declared as: private: members of a class are accessible only from other members of their same class; protected: members are accessible from members of their same class and friend classes and also members of their derived classes; public: members are accessible from anywhere the class is visible 10. structs usually used for data only structures, classes for classes that have procedures and member functions 11. use private because in large projects important that values not be modified in an unexpected way from the POV of the object 12. advantage of class declare several diff objects from it, each object of Rect has its own variable x, y AND its own functions 13. concept of OO programming: data and functions are properties of the object instead of the usual view of objects as function parameters in structured programming 4. Difference between assignment operator and copy constructor - -assignment operator = assigning a variable to a value - copy constructor 1. constructor with only one parameter of its same type that assigns to every nonstatic class member variable of the object a copy of the passed object 2. copy assignment operator must correctly deal with a well constructed object - but copy constructor initializes uninitialized memory 3. copy constructor takes care of initialization by an object of the same type x 4. for a class for which the copy assignment and copy constructor not explicitly declared missing operation will be generated by the compiler. Copy operations are not inherited - copy of a class object is a copy of each member 5. memberwise assignment: each member of the right hand object is assigned to the corresponding member of the left hand object 6. if a class needs a copy constructor it will also need an assignment operator 7. copy constructor creates a new object, assignment operator has to deal w/ existing data in the object 8. assignment is like deconstruction followed by construction 9. assignment operator assigns a value to a already existing object 10. copy constructor creates a new object by copying an existing one 11. copy constructor initializes a freshly created object using data from an existing one. It must allocate memory if necessary then copy the data 12. the assignment operator makes an already existing object into a copy of an existing one. 13. copy constructor always creates a new object, assignment never does 5. Difference between overloading and overriding? 1. Overload - two functions that appear in the same scope are overloaded if they have the same name but have different parameter list 2. main() cannot be overloaded 3. notational convenience - compiler invokes the functions that is the best match on the args – found by finding the best match between the type of arg expr and parameter 4. if declare a function locally, that function hides rather than overload the same function declared in an outer scope 5. Overriding - the ability of the inherited class rewriting the virtual method of a base class - a method which completely replaces base class FUNCTIONALITY in subclass 6. the overriding method in the subclass must have exactly the same signature as the function of the base class it is replacing - replacement of a method in a child class 7. writing a different body in a derived class for a function defined in a base class, ONLY if the function in the base class is virtual and ONLY if the function in the derived class has the same signature 8. all functions in the derived class hide the base class functions with the same name except in the case of a virtual functions which override the base class functions with the same signature 6. Virtual 1. single most important feature of C++ BUT virtual costs 2. allows derived classes to replace the implementation provided by the base class 3. without virtual functions C++ wouldnt be object oriented 4. Programming with classes but w/o dynamic binding == object based not OO 5. dynamic binding can improve reuse by letting old code call new code 6. functions defined as virtual are ones that the base expects its derived classes to redefine 7. virtual precedes return type of a function 8. virtual keyword appears only on the member function declaration inside the class 9. virtual keyword may not be used on a function definition that appears outside the class body 10. default member functions are nonvirtual 7. Dynamic Binding 1. delaying until runtime the selection of which function to run 2. refers to the runtime choice of which virtual function to run based on the underlying type of the object to which a reference or a pointer is based 3. applies only to functions declared as virtual when called thru reference or ptr 4. in C++ dynamic binding happens when a virtual function is called through a reference (|| ptr) to a base class. The face that ref or ptr might refer to either a base or a derived class object is the key to dynamic binding. Calls to virtual functions made thru a reference or ptr are resolved at run time: the function that is called is the one defined by the actual type of the object to which the reference or pointer refers 8. Explain the need for a virtual destructor 1. destructor for the base parts are invoked automatically 2. we might delete a ptr to the base type that actually points to a derived object 3. if we delete a ptr to base then the base class destructor is run and the members of the base class are cleared up. If the objectis a derived type then the behavior is undefined 4. to ensure that the proper destructor is run the destructor must be virtual in the base class 5. virtual destructor needed if base pointer that points to a derived object is ever deleted (even if it doesnt do any work) 9. Rule of 3 1. if a class needs a destructor, it will also need an assignment operator and copy constructor 2. compiler always synthesizes a destructor for us 3. destroys each nonstatic member in the reverse order from that in which the object was created 4. it destroys the members in reverse order from which they are declared in the class1. if someone will derive from your class2. and if someone will say new derived where derived is derived from your class3. and if someone will say delete p, where the actual objects type is derived but the pointer ps type is your class 5. make destructor virtual if your class has any virtual functions 10. Why do you need a virtual destructor when someone says delete using a Base ptr thats pointing @ a derived object? - when you say delete p and the class of p has a virtual destructor the destructor that gets invoked is the one assoc with the type of the object*p not necessarily the one assoc with the type of the pointer == GOOD 11. Different types of polymorphism 1. types related by inheritance as polymorphic types because we can use many forms of a derived or base type interchangeably 2. only applies to ref or ptr to types related by inheritance. 3. Inheritance - lets us define classes that model relationships among types, sharing what is common and specializing only that which is inherently different 4. derived classes 1. can use w/o change those operations that dont depend on the specifics of the derived type 2. redefine those member functions that do depend on its type 3. derived class may define additional members beyond those it inherits from its base class. 5. Dynamic Binding - lets us write programs that use objects of any type in an inheritance hierarchy w/o caring about the objects specific types 6. happens when a virtual function is called through a reference || ptr to a base class 7. The fact that a reference or ptr might refer to either a base or derived class object is the key to dynamic binding 8. calls to virtual functions made though a reference/ptr resolved @ runtime 9. the function that is called is the one defined by the actual type of the object to which ref/ptr refers 12. How to implement virtual functions in C - keep function pointers in function and use those function ptrs to perform the operation 13. What are the different type of Storage classes? 1. automatic storage: stack memory - static storage: for namespace scope objects and local statics 2. free store: or heap for dynamically allocated objects == design patterns 14. What is a namespace? 1. every name defined in a global scope must be unique w/in that scope 2. name collisions: same name used in our own code or code supplied to us by indie producers == namespace pollution 3. name clashing - namespace provides controlled mechanism for preventing name collisions 4. allows us to group a set of global classes/obj/funcs 5. in order to access variables from outside namespace have to use scope :: operator 6. using namespace serves to assoc the present nesting level with a certain namespace so that objectand funcs of that namespace can be accessible directly as if they were defined in the global scope 15. Types of STL containers - containers are objects that store other objects and that has methods for accessing its elements - has iterator - vector 16. Difference between vector and array - -array: data structure used dto store a group of objects of the same type sequentially in memory - vector: container class from STL - holds objects of various types - resize, shrinks grows as elements added - bugs such as accessing out of bounds of an array are avoided 17. Write a program that will delete itself after execution. Int main(int argc, char **argv) { remove(argv[0]);return 0;} 18. What are inline functions? 1. treated like macro definitions by C++ compiler 2. meant to be used if there‘s a need to repetitively execute a small block if code which is smaller 3. always evaluates every argument once 4. defined in header file 5. avoids function call overload because calling a function is slower than evaluating the equivalent expression 6. it‘s a request to the compiler, the compiler can ignore the request 19. What is strstream? defines classes that support iostreams, array of char obj 20. Passing by ptr/val/refArg? 1. passing by val/refvoid c::f(int arg) – by value arg is a new int existing only in function. Its initial value is copied from i. modifications to arg wont affect the I in the main function 2. void c::f(const int arg) – by value (i.e. copied) the const keyword means that arg cant be changed, but even if it could it wouldnt affect the I in the main function 3. void c::f(int& arg) - -by reference, arg is an alias for I. no copying is done. More efficient than methods that use copy. Change in arg == change in I in the calling function 4. void c::f(const int& arg) - -by reference, int provided in main call cant be changed, read only. Combines safety with efficacy. 5. void c::f(const int& arg) const – like previous but final const that in addition the function f cant change member variables of cArg passing using pointers 6. void c::f(int *arg) – by reference changing *arg will change the I in the calling function 7. void c::f(const int *arg) – by reference but this time the I int in the main function cant be changed – read only 8. void c::f(int * const arg) – by reference the pointer arg cant be changed but what it points to (namely I of the calling function) can 9. void c::f(const int * const arg) by reference the pointer arg cant be changed neither can what it points to 21. Mutable keyword? 1. keyword is the key to make exceptions to const 2. mutable data member is allowed to change during a const member function 3. mutable data member is never const even when it is a member of a const object 4. a const member function may change a mutable member 22. Something you can do in C but not in C++? C++ applications generally slower at runtime and compilation - input/output 23. Difference between calloc and malloc? 1. malloc: allocate s bytes 2. calloc: allocate n times s bytes initialized to 0 24. What will happen if I allocate memory using new & free memory using free? WRONG 25. Difference between printf and sprintf? 1. sprintf: a function that puts together a string, output goes to an array of char instead of stdout 2. printf: prints to stdout 26. map in STL? 1. used to store key - value pairs, value retrieved using the key 2. store data indexed by keys of any type desire instead of integers as with arrays 3. maps are fast 0(log(n)) insertion and lookup time 4. std::map<key_type, data_type>EX:Std::map<string, char> grade_list //grade_list[―john‖] = b 27. When will we use multiple inheritance? 1. use it judiciously class 2. when MI enters the design scope it becomes possible to inherit the same name (function/typedef) from more than one base class == ambiguity 3. C++ first identifies the function thats the best match for the call 4. C++ resolves calls to overload before accessibility, therefore the accessibility of Elec_Gadget() checkout is never evaluated because both are good matches == ERROR 5. resolve ambiguity mp.Borrowable_Item::checkOut(); mp.Elec_Gadget::checkOut(); //error because trying to access private 6. deadly MI diamond: anytime you have an inheritance hierarchy w/ more than one path between a base class and a derived classEX:FileInput File Output FileIOFile//File and IOFile both have paths through InputFile and OutputFile 28. Multithreading - C++ does not have a notion of multithreading, no notion of concurrency 29. Why is the pre-increment operator faster than the post-increment operator? pre is more efficient that post because for post the object must increment itself and then return a temporary containing its old value. True for even built in types 30. What is a hash and what would you use it for? 31. What is a dot product and what is a cross product - what would you use them for? 32. What is 2 ^ 101? C and C++ questions for the interview 1. What is the output of printf(‖%d‖) 2. What will happen if I say delete this 3. Difference between ―C structure‖ and ―C++ structure‖. 4. Diffrence between a ―assignment operator‖ and a ―copy constructor‖ 5. What is the difference between ―overloading‖ and ―overridding‖? 6. Explain the need for ―Virtual Destructor‖. 7. Can we have ―Virtual Constructors‖? 8. What are the different types of polymorphism? 9. What are Virtual Functions? How to implement virtual functions in ―C‖ 10. What are the different types of Storage classes? 11. What is Namespace? 12. What are the types of STL containers?. 13. Difference between ―vector‖ and ―array‖? 14. How to write a program such that it will delete itself after exectution? 15. Can we generate a C++ source code from the binary file? 16. What are inline functions? 17. What is ―strstream‖ ? 18. Explain ―passing by value‖, ―passing by pointer‖ and ―passing by reference‖ 19. Have you heard of ―mutable‖ keyword? 20. What is a ―RTTI‖? 21. Is there something that I can do in C and not in C++? 22. What is the difference between ―calloc‖ and ―malloc‖? 23. What will happen if I allocate memory using ―new‖ and free it using ―free‖ or allocate sing ―calloc‖ and free it using ―delete‖? 24. Difference between ―printf‖ and ―sprintf‖. 25. What is ―map‖ in STL? 26. When shall I use Multiple Inheritance? 27. Explain working of printf. 28. Talk sometiming about profiling? 29. How many lines of code you have written for a single program? 30. How to write Multithreaded applications using C++? 31. Write any small program that will compile in ―C‖ but not in ―C++‖ 32. What is Memory Alignment? 33. Why preincrement operator is faster than postincrement? 34. What are the techniques you use for debugging? 35. How to reduce a final size of executable? 36. Give 2 examples of a code optimization. C++ code examples for job interviews 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) for( unsigned int i = 1; i < = 100; i++ ) if( i & 0x00000001 ) cout << i<<","; 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 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. Good C++ Interview questions Some good C++ questions to ask a job applicant. 1. How do you decide which integer type to use? 2. What should the 64-bit integer type on new, 64-bit machines be? 3. What‘s the best way to declare and define global variables? 4. What does extern mean in a function declaration? 5. What‘s the auto keyword good for? 6. I can‘t seem to define a linked list node which contains a pointer to itself. 7. How do I declare an array of N pointers to functions returning pointers to functions returning pointers to characters? 8. How can I declare a function that returns a pointer to a function of its own type? 9. My compiler is complaining about an invalid redeclaration of a function, but I only define it once and call it once. What‘s happening? 10. What can I safely assume about the initial values of variables which are not explicitly initialized? 11. Why can‘t I initialize a local array with a string? 12. What is the difference between char a[] = ―string‖; and char *p = ―string‖; ? 13. How do I initialize a pointer to a function? C++ gamedev interview questions 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: o const char * o char const * o 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: o Copy constructor o = operator overload o == operator overload o + operator overload (customers‘ balances should be added up, as an example of joint account between husband and wife) Note:Anyone confusing assignment and equality operators should be dismissed from the interview. The applicant might make a mistake of passing by value, not by reference. The candidate might also want to return a pointer, not a new object, from the addition operator. Slightly hint that you‘d like the value to be changed outside the function, too, in the first case. Ask him whether the statement customer3 = customer1 + customer2 would work in the second case. 3. What problems might the following macro bring to the application? #define sq(x) x*x 4. Consider the following struct declarations: 5. struct A { A(){ cout << "A"; } }; 6. struct B { B(){ cout << "B"; } }; 7. struct C { C(){ cout << "C"; } }; 8. struct D { D(){ cout << "D"; } }; 9. struct E : D { E(){ cout << "E"; } }; 10. struct F : A, B 11. { 12. C c; 13. D d; 14. E e; 15. F() : B(), A(),d(),c(),e() { cout << "F"; } }; What constructors will be called when an instance of F is initialized? Produce the program output when this happens. 16. Anything wrong with this code? 17. T *p = new T[10]; 18. delete p; 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‖. 19. Anything wrong with this code? 20. T *p = 0; 21. delete p; 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. 22. Explain virtual inheritance. Draw the diagram explaining the initialization of the base class when virtual inheritance is used. Note: Typical mistake for applicant is to draw an inheritance diagram, where a single base class is inherited with virtual methods. Explain to the candidate that this is not virtual inheritance. Ask them for the classic definition of virtual inheritance. Such question might be too complex for a beginning or even intermediate developer, but any applicant with advanced C++ experience should be somewhat familiar with the concept, even though he‘ll probably say he‘d avoid using it in a real project. Moreover, even the experienced developers, who know about virtual inheritance, cannot coherently explain the initialization process. If you find a candidate that knows both the concept and the initialization process well, he‘s hired. 23. What‟s potentially wrong with the following code? 24. long value; 25. //some stuff 26. value &= 0xFFFF; 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. }; Tell me all you know about the Bar() function. Basic Java interview questions 1. What is a Marker Interface? - An interface with no methods. Example: Serializable, Remote, Cloneable 2. What interface do you implement to do the sorting? - Comparable 3. What is the eligibility for a object to get cloned? - It must implement the Cloneable interface 4. What is the purpose of abstract class? - It is not an instantiable class. It provides the concrete implementation for some/all the methods. So that they can reuse the concrete functionality by inheriting the abstract class. 5. What is the difference between interface and abstract class? - Abstract class defined with methods. Interface will declare only the methods. Abstract classes are very much useful when there is a some functionality across various classes. Interfaces are well suited for the classes which varies in functionality but with the same method signatures. 6. What do you mean by RMI and how it is useful? - RMI is a remote method invocation. Using RMI, you can work with remote object. The function calls are as though you are invoking a local variable. So it gives you a impression that you are working really with a object that resides within your own JVM though it is somewhere. 7. What is the protocol used by RMI? - RMI-IIOP 8. What is a hashCode? - hash code value for this object which is unique for every object. 9. What is a thread? - Thread is a block of code which can execute concurrently with other threads in the JVM. 10. What is the algorithm used in Thread scheduling? - Fixed priority scheduling. 11. What is hash-collision in Hashtable and how it is handled in Java? - Two different keys with the same hash value. Two different entries will be kept in a single hash bucket to avoid the collision. 12. What are the different driver types available in JDBC? - 1. A JDBC-ODBC bridge 2. A native-API partly Java technology-enabled driver 3. A net-protocol fully Java technology-enabled driver 4. A native-protocol fully Java technology- enabled driver For more information: Driver Description 13. Is JDBC-ODBC bridge multi-threaded? - No 14. Does the JDBC-ODBC Bridge support multiple concurrent open statements per connection? - No 15. What is the use of serializable? - To persist the state of an object into any perminant storage device. 16. What is the use of transient? - It is an indicator to the JVM that those variables should not be persisted. It is the users responsibility to initialize the value when read back from the storage. 17. What are the different level lockings using the synchronization keyword? - Class level lock Object level lock Method level lock Block level lock 18. What is the use of preparedstatement? - Preparedstatements are precompiled statements. It is mainly used to speed up the process of inserting/updating/deleting especially when there is a bulk processing. 19. What is callable statement? Tell me the way to get the callable statement? - Callablestatements are used to invoke the stored procedures. You can obtain the callablestatement from Connection using the following methods prepareCall(String sql) prepareCall(String sql, int resultSetType, int resultSetConcurrency) 20. In a statement, I am executing a batch. What is the result of the execution? - It returns the int array. The array contains the affected row count in the corresponding index of the SQL. 21. Can a abstract method have the static qualifier? - No 22. What are the different types of qualifier and what is the default qualifier? - public, protected, private, package (default) 23. What is the super class of Hashtable? - Dictionary 24. What is a lightweight component? - Lightweight components are the one which doesn‘t go with the native call to obtain the graphical units. They share their parent component graphical units to render them. Example, Swing components 25. What is a heavyweight component? - For every paint call, there will be a native call to get the graphical units. Example, AWT. 26. What is an applet? - Applet is a program which can get downloaded into a client environment and start executing there. 27. What do you mean by a Classloader? - Classloader is the one which loads the classes into the JVM. 28. What are the implicit packages that need not get imported into a class file? - java.lang 29. What is the difference between lightweight and heavyweight component? - Lightweight components reuses its parents graphical units. Heavyweight components goes with the native graphical unit for every component. Lightweight components are faster than the heavyweight components. 30. What are the ways in which you can instantiate a thread? - Using Thread class By implementing the Runnable interface and giving that handle to the Thread class. 31. What are the states of a thread? - 1. New 2. Runnable 3. Not Runnable 4. Dead 32. What is a socket? - A socket is an endpoint for communication between two machines. 33. How will you establish the connection between the servlet and an applet? - Using the URL, I will create the connection URL. Then by openConnection method of the URL, I will establish the connection, through which I can be able to exchange data. 34. What are the threads will start, when you start the java program? - Finalizer, Main, Reference Handler, Signal Dispatcher Java interview questions 1. What is garbage collection? What is the process that is responsible for doing that in java? - Reclaiming the unused memory by the invalid objects. Garbage collector is responsible for this process 2. What kind of thread is the Garbage collector thread? - It is a daemon thread. 3. What is a daemon thread? - These are the threads which can run without user intervention. The JVM can exit when there are daemon thread by killing them abruptly. 4. How will you invoke any external process in Java? - Runtime.getRuntime().exec(….) 5. What is the finalize method do? - Before the invalid objects get garbage collected, the JVM give the user a chance to clean up some resources before it got garbage collected. 6. What is mutable object and immutable object? - If a object value is changeable then we can call it as Mutable object. (Ex., StringBuffer, …) If you are not allowed to change the value of an object, it is immutable object. (Ex., String, Integer, Float, …) 7. What is the basic difference between string and stringbuffer object? - String is an immutable object. StringBuffer is a mutable object. 8. What is the purpose of Void class? - The Void class is an uninstantiable placeholder class to hold a reference to the Class object representing the primitive Java type void. 9. What is reflection? - Reflection allows programmatic access to information about the fields, methods and constructors of loaded classes, and the use reflected fields, methods, and constructors to operate on their underlying counterparts on objects, within security restrictions. 10. What is the base class for Error and Exception? - Throwable 11. What is the byte range? -128 to 127 12. What is the implementation of destroy method in java.. is it native or java code? - This method is not implemented. 13. What is a package? - To group set of classes into a single unit is known as packaging. Packages provides wide namespace ability. 14. What are the approaches that you will follow for making a program very efficient? - By avoiding too much of static methods avoiding the excessive and unnecessary use of synchronized methods Selection of related classes based on the application (meaning synchronized classes for multiuser and non- synchronized classes for single user) Usage of appropriate design patterns Using cache methodologies for remote invocations Avoiding creation of variables within a loop and lot more. 15. What is a DatabaseMetaData? - Comprehensive information about the database as a whole. 16. What is Locale? - A Locale object represents a specific geographical, political, or cultural region 17. How will you load a specific locale? - Using ResourceBundle.getBundle(…); 18. What is JIT and its use? - Really, just a very fast compiler… In this incarnation, pretty much a one-pass compiler — no offline computations. So you can‘t look at the whole method, rank the expressions according to which ones are re-used the most, and then generate code. In theory terms, it‘s an on-line problem. 19. Is JVM a compiler or an interpreter? - Interpreter 20. When you think about optimization, what is the best way to findout the time/memory consuming process? - Using profiler 21. What is the purpose of assert keyword used in JDK1.4.x? - In order to validate certain expressions. It effectively replaces the if block and automatically throws the AssertionError on failure. This keyword should be used for the critical arguments. Meaning, without that the method does nothing. 22. How will you get the platform dependent values like line separator, path separator, etc., ? - Using Sytem.getProperty(…) (line.separator, path.separator, …) 23. What is skeleton and stub? what is the purpose of those? - Stub is a client side representation of the server, which takes care of communicating with the remote server. Skeleton is the server side representation. But that is no more in use… it is deprecated long before in JDK. 24. What is the final keyword denotes? - final keyword denotes that it is the final implementation for that method or variable or class. You can‘t override that method/variable/class any more. 25. What is the significance of ListIterator? - You can iterate back and forth. 26. What is the major difference between LinkedList and ArrayList? - LinkedList are meant for sequential accessing. ArrayList are meant for random accessing. 27. What is nested class? - If all the methods of a inner class is static then it is a nested class. 28. What is inner class? - If the methods of the inner class can only be accessed via the instance of the inner class, then it is called inner class. 29. What is composition? - Holding the reference of the other class within some other class is known as composition. 30. What is aggregation? - It is a special type of composition. If you expose all the methods of a composite class and route the method call to the composite method through its reference, then it is called aggregation. 31. What are the methods in Object? - clone, equals, wait, finalize, getClass, hashCode, notify, notifyAll, toString 32. Can you instantiate the Math class? - You can‘t instantiate the math class. All the methods in this class are static. And the constructor is not public. 33. What is singleton? - It is one of the design pattern. This falls in the creational pattern of the design pattern. There will be only one instance for that entire JVM. You can achieve this by having the private constructor in the class. For eg., public class Singleton { private static final Singleton s = new Singleton(); private Singleton() { } public static Singleton getInstance() { return s; } // all non static methods … } 34. What is DriverManager? - The basic service to manage set of JDBC drivers. 35. What is Class.forName() does and how it is useful? - It loads the class into the ClassLoader. It returns the Class. Using that you can get the instance ( ―class- instance‖.newInstance() ). 36. Inq adds a question: Expain the reason for each keyword of public static void main(String args[]) Core Java interview questions 1. Can there be an abstract class with no abstract methods in it? - Yes 2. Can an Interface be final? - No 3. Can an Interface have an inner class? - Yes. 4. public interface abc 5. { 6. static int i=0; void dd(); 7. class a1 8. { 9. a1() 10. { 11. int j; 12. System.out.println("inside"); 13. }; 14. public static void main(String a1[]) 15. { 16. System.out.println("in interfia"); 17. } 18. } 19. } 20. Can we define private and protected modifiers for variables in interfaces? - No 21. What is Externalizable? - Externalizable is an Interface that extends Serializable Interface. And sends data into Streams in Compressed Format. It has two methods, writeExternal(ObjectOuput out) and readExternal(ObjectInput in) 22. What modifiers are allowed for methods in an Interface? - Only public and abstract modifiers are allowed for methods in interfaces. 23. What is a local, member and a class variable? - Variables declared within a method are ―local‖ variables. Variables declared within the class i.e not within any methods are ―member‖ variables (global variables). Variables declared within the class i.e not within any methods and are defined as ―static‖ are class variables 24. What are the different identifier states of a Thread? - The different identifiers of a Thread are: R - Running or runnable thread, S - Suspended thread, CW - Thread waiting on a condition variable, MW - Thread waiting on a monitor lock, MS - Thread suspended waiting on a monitor lock 25. What are some alternatives to inheritance? - Delegation is an alternative to inheritance. Delegation means that you include an instance of another class as an instance variable, and forward messages to the instance. It is often safer than inheritance because it forces you to think about each message you forward, because the instance is of a known class, rather than a new class, and because it doesn‘t force you to accept all the methods of the super class: you can provide only the methods that really make sense. On the other hand, it makes you write more code, and it is harder to re-use (because it is not a subclass). 26. Why isn‟t there operator overloading? - Because C++ has proven by example that operator overloading makes code almost impossible to maintain. In fact there very nearly wasn‘t even method overloading in Java, but it was thought that this was too useful for some very basic methods like print(). Note that some of the classes like DataOutputStream have unoverloaded methods like writeInt() and writeByte(). 27. What does it mean that a method or field is “static”? - Static variables and methods are instantiated only once per class. In other words they are class variables, not instance variables. If you change the value of a static variable in a particular object, the value of that variable changes for all instances of that class. Static methods can be referenced with the name of the class rather than the name of a particular object of the class (though that works too). That‘s how library methods like System.out.println() work. out is a static field in the java.lang.System class. 28. How do I convert a numeric IP address like 192.18.97.39 into a hostname like java.sun.com? 29. String hostname = InetAddress.getByName("192.18.97.39").getHostName(); 30. Difference between JRE/JVM/JDK? 31. Why do threads block on I/O? - Threads block on i/o (that is enters the waiting state) so that other threads may execute while the I/O operation is performed. 32. What is synchronization and why is it important? - With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources. Without synchronization, it is possible for one thread to modify a shared object while another thread is in the process of using or updating that object‘s value. This often leads to significant errors. 33. Is null a keyword? - The null value is not a keyword. 34. Which characters may be used as the second character of an identifier,but not as the first character of an identifier? - The digits 0 through 9 may not be used as the first character of an identifier but they may be used after the first character of an identifier. 35. What modifiers may be used with an inner class that is a member of an outer class? - A (non-local) inner class may be declared as public, protected, private, static, final, or abstract. 36. How many bits are used to represent Unicode, ASCII, UTF-16, and UTF-8 characters? - Unicode requires 16 bits and ASCII require 7 bits. Although the ASCII character set uses only 7 bits, it is usually represented as 8 bits. UTF-8 represents characters using 8, 16, and 18 bit patterns. UTF-16 uses 16-bit and larger bit patterns. 37. What are wrapped classes? - Wrapped classes are classes that allow primitive types to be accessed as objects. 38. What restrictions are placed on the location of a package statement within a source code file? - A package statement must appear as the first line in a source code file (excluding blank lines and comments). 39. What is the difference between preemptive scheduling and time slicing? - Under preemptive scheduling, the highest priority task executes until it enters the waiting or dead states or a higher priority task comes into existence. Under time slicing, a task executes for a predefined slice of time and then reenters the pool of ready tasks. The scheduler then determines which task should execute next, based on priority and other factors. 40. What is a native method? - A native method is a method that is implemented in a language other than Java. 41. What are order of precedence and associativity, and how are they used? - Order of precedence determines the order in which operators are evaluated in expressions. Associatity determines whether an expression is evaluated left-to- right or right-to-left 42. What is the catch or declare rule for method declarations? - If a checked exception may be thrown within the body of a method, the method must either catch the exception or declare it in its throws clause. 43. Can an anonymous class be declared as implementing an interface and extending a class? - An anonymous class may implement an interface or extend a superclass, but may not be declared to do both. 44. What is the range of the char type? - The range of the char type is 0 to 2^16 - 1. C interview questions 1. What will print out? main() { char *p1=―name‖; char *p2; p2=(char*)malloc(20); memset (p2, 0, 20); while(*p2++ = *p1++); printf(―%s\n‖,p2); } Answer:empty string. 2. What will be printed as the result of the operation below: main() { int x=20,y=35; x=y++ + x++; y= ++y + ++x; printf(―%d%d\n‖,x,y); } Answer : 5794 3. What will be printed as the result of the operation below: main() { int x=5; printf(―%d,%d,%d\n‖,x,x< <2,x>>2); } Answer: 5,20,1 4. What will be printed as the result of the operation below: #define swap(a,b) a=a+b;b=a-b;a=a-b; void main() { int x=5, y=10; swap (x,y); printf(―%d %d\n‖,x,y); swap2(x,y); printf(―%d %d\n‖,x,y); } int swap2(int a, int b) { int temp; temp=a; b=a; a=temp; return 0; } Answer: 10, 5 10, 5 5. What will be printed as the result of the operation below: main() { char *ptr = ‖ Cisco Systems‖; *ptr++; printf(―%s\n‖,ptr); ptr++; printf(―%s\n‖,ptr); } Answer:Cisco Systems isco systems 6. What will be printed as the result of the operation below: main() { char s1[]=―Cisco‖; char s2[]= ―systems‖; printf(―%s‖,s1); } Answer: Cisco 7. What will be printed as the result of the operation below: 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 8. The following variable is available in file1.c, who can access it?: 9. static int average; Answer: all the functions in the file1.c can access the variable. 10. WHat will be the result of the following code? #define TRUE 0 // some code while(TRUE) { // some code } Answer: This will not go into the loop as TRUE is defined as 0. 11. What will be printed as the result of the operation below: 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:%d\n",x); x++; changevalue(x); printf("Second output:%d\n",x); modifyvalue(); printf("Third output:%d\n",x); } Answer: 12 , 13 , 13 12. What will be printed as the result of the operation below: main() { int x=10, y=15; x = x++; y = ++y; printf(―%d %d\n‖,x,y); } Answer: 11, 16 13. What will be printed as the result of the operation below: main() { int a=0; if(a==0) printf(―Cisco Systems\n‖); printf(―Cisco Systems\n‖); } Answer: Two lines with ―Cisco Systems‖ will be printed. Labview 1. How long have you been programming LV? 2. What is the largest project you worked with in LV? 3. Do you use state machines in your code? If so what kind? 4. Do you Document your code. If so what methods do you use? 5. Do you use Ques or Notifiers in your code? If so how and when? 6. Are you familiar with the event structure? How and where do you use the event structure? .What is 'Software Quality Assurance'? Software QA involves the entire software development Process - monitoring and improving the process, making sure that any agreed-upon standards and procedures are followed, and ensuring that problems are found and dealt with. It is oriented to 'prevention'. (See the Books section for a list of useful books on Software Quality Assurance.) 2.What is 'Software Testing'? Testing involves operation of a system or application under controlled conditions and evaluating the results (eg, 'if the user is in interface A of the application while using hardware B, and does C, then D should happen'). The controlled conditions should include both normal and abnormal conditions. Testing should intentionally attempt to make things go wrong to determine if things happen when they shouldn't or things don't happen when they should. It is oriented to 'detection'. Organizations vary considerably in how they assign responsibility for QA and testing. Sometimes they're the combined responsibility of one group or individual. Also common are project teams that include a mix of testers and developers who work closely together, with overall QA processes monitored by project managers. It will depend on what best fits an organization's size and business structure. 3. What are some recent major computer system failures caused by software bugs? * Media reports in January of 2005 detailed severe problems with a$170 million high-profile U.S. government IT

systems project. Software testing was one of the five major problem areas according to a report of the

commission reviewing the project. Studies were under way to determine which, if any, portions of the project

could                                                                 be                                                               salvaged.

* In July 2004 newspapers reported that a new government welfare management system in Canada costing

several hundred million dollars was unable to handle a simple benefits rate increase after being put into live

operation. Reportedly the original contract allowed for only 6 weeks of acceptance testing and the system was

never           tested         for              its         ability           to             handle            a         rate              increase.

* Millions of bank accounts were impacted by errors due to installation of inadequately tested software code in

the transaction processing system of a major North American bank, according to mid-2004 news reports. Articles

about the incident stated that it took two weeks to fix all the resulting errors, that additional problems resulted

when the incident drew a large number of e-mail phishing attacks against the bank's customers, and that the

total           cost          of           the               incident              could              exceed             $100 million. * A bug in site management software utilized by companies with a significant percentage of worldwide web traffic was reported in May of 2004. The bug resulted in performance problems for many of the sites simultaneously and required disabling of the software until the bug was fixed. * According to news reports in April of 2004, a software bug was determined to be a major contributor to the 2003 Northeast blackout, the worst power system failure in North American history. The failure involved loss of electrical power to 50 million customers, forced shutdown of 100 power plants, and economic losses estimated at$6 billion. The bug was reportedly in one utility company's vendor-supplied power monitoring and management

system, which was unable to correctly handle and report on an unusual confluence of initially localized events.

The     error      was    found           and          corrected      after        examining          millions      of   lines        of      code.
* In early 2004, news reports revealed the intentional use of a software bug as a counter-espionage tool.

According to the report, in the early 1980's one nation surreptitiously allowed a hostile nation's espionage service

to steal a version of sophisticated industrial software that had intentionally-added flaws. This eventually resulted

in     major     industrial      disruption           in     the     country      that         used      the     stolen        flawed       software.

* A major U.S. retailer was reportedly hit with a large government fine in October of 2003 due to web site errors

that           enabled          customers                   to          view           one              anothers'          online             orders.

* News stories in the fall of 2003 stated that a manufacturing company recalled all their transportation products

in order to fix a software problem causing instability in certain circumstances. The company found and reported

the bug itself and initiated the recall procedure in which a software upgrade fixed the problems.

* In January of 2001 newspapers reported that a major European railroad was hit by the aftereffects of the Y2K

bug. The company found that many of their newer trains would not run due to their inability to recognize the date

'31/12/2000';       the       trains     were         started        by     altering          the    control     system's        date       settings.

* News reports in September of 2000 told of a software vendor settling a lawsuit with a large mortgage lender;

the vendor had reportedly delivered an online mortgage processing system that did not meet specifications, was

delivered                              late,                               and                               didn't                            work.

* In early 2000, major problems were reported with a new computer system in a large suburban U.S. public

school district with 100,000+ students; problems included 10,000 erroneous report cards and students left

stranded by failed class registration systems; the district's CIO was fired. The school district decided to reinstate

it's original 25-year old system for at least a year until the bugs were worked out of the new system by the

software                                                                                                                                    vendors.

* In October of 1999 the \$125 million NASA Mars Climate Orbiter spacecraft was believed to be lost in space due

to a simple data conversion error. It was determined that spacecraft software used certain data in English units

that should have been in metric units. Among other tasks, the orbiter was to serve as a communications relay for

the Mars Polar Lander mission, which failed for unknown reasons in December 1999. Several investigating panels

were    convened         to   determine         the        process   failures     that        allowed      the   error    to     go     undetected.

* Bugs in software supporting a large commercial high-speed data network affected 70,000 business customers

over a period of 8 days in August of 1999. Among those affected was the electronic trading system of the largest

U.S.   futures    exchange,      which         was    shut       down     for   most     of    a    week    as   a    result    of    the   outages.
* January 1998 news reports told of software problems at a major U.S. telecommunications company that

resulted in no charges for long distance calls for a month for 400,000 customers. The problem went undetected

until customers called up with questions about their bills.

4.Why is it often hard for management to get serious about quality assurance?

* Solving problems is a high-visibility process; preventing problems is low-visibility. This is illustrated by an old

parable: In ancient China there was a family of healers, one of whom was known throughout the land and

employed                as             a             physician                 to           a          great            lord.

5.Why                           does                     software                            have                     bugs?

* Miscommunication or no communication - as to specifics of what an application should or shouldn't do (the

application's                                                                                                  requirements).

* Software complexity - the complexity of current software applications can be difficult to comprehend for anyone

without experience in modern-day software development. Multi-tiered applications, client-server and distributed

applications, data communications, enormous relational databases, and sheer size of applications have all

contributed        to           the        exponential           growth             in    software/system         complexity.

*     Programming            errors    -    programmers,          like    anyone         else,   can    make       mistakes.

* Changing requirements (whether documented or undocumented) - the end-user may not understand the

effects of changes, or may understand and request them anyway - redesign, rescheduling of engineers, effects

on other projects, work already completed that may have to be redone or thrown out, hardware requirements

that may be affected, etc. If there are many minor changes or any major changes, known and unknown

dependencies among parts of the project are likely to interact and cause problems, and the complexity of

coordinating changes may result in errors. Enthusiasm of engineering staff may be affected. In some fast-

changing business environments, continuously modified requirements may be a fact of life. In this case,

management must understand the resulting risks, and QA and test engineers must adapt and plan for continuous

extensive testing to keep the inevitable bugs from running out of control - see 'What can be done if requirements

are changing continuously?' in Part 2 of the FAQ. Also see information about 'agile' approaches such as XP, also

in                      Part                     2                        of                     the                    FAQ.
* Time pressures - scheduling of software projects is difficult at best, often requiring a lot of guesswork. When

*                 egos                -                  people                    prefer                    to                say                 things                    like:

*                                                    *                                                       'no                                                     problem'

*                                     *                                            'piece                                       of                                           cake'

*            *              'I             can              whip                    that               out               in             a             few                hours'

*            *            'it             should                be             easy               to               update               that              old            code'

*    *    'that      adds        a     lot      of       complexity           and      we       could        end     up        making          a    lot     of       mistakes'

*        *         'we           have             no        idea              if          we           can          do          that;            we'll           wing           it'

*    *       'I     can't        estimate            how        long     it        will     take,        until       I        take      a        close     look         at      it'

*    *       'we         can't       figure       out       what         that         old         spaghetti         code         did        in      the      first       place'

If       there           are         too          many               unrealistic            'no         problem's',              the             result         is       bugs.

* Poorly documented code - it's tough to maintain and modify code that is badly written or poorly documented;

the result is bugs. In many organizations management provides no incentive for programmers to document their

code or write clear, understandable, maintainable code. In fact, it's usually the opposite: they get points mostly

for quickly turning out code, and there's job security if nobody else can understand it ('if it was hard to write, it

* Software development tools - visual tools, class libraries, compilers, scripting tools, etc. often introduce their

own bugs or are poorly documented, resulting in added bugs.
6.How can new Software QA processes be introduced in an existing organization?

* A lot depends on the size of the organization and the risks involved. For large organizations with high-risk (in

terms of lives or property) projects, serious management buy-in is required and a formalized QA process is

necessary.

* Where the risk is lower, management and organizational buy-in and QA implementation may be a slower, step-

at-a-time process. QA processes should be balanced with productivity so as to keep bureaucracy from getting out

of                                                                                                          hand.

* For small groups or projects, a more ad-hoc process may be appropriate, depending on the type of customers

and projects. A lot will depend on team leads or managers, feedback to developers, and ensuring adequate

communications         among          customers,         managers,         developers,        and         testers.

* The most value for effort will often be in (a) requirements management processes, with a goal of clear,

complete, testable requirement specifications embodied in requirements or design documentation, or in 'agile'-

type environments extensive continuous coordination with end-users, (b) design inspections and code

inspections, and (c) post-mortems/retrospectives.

7.What is verification? validation?

* Verification typically involves reviews and meetings to evaluate documents, plans, code, requirements, and

specifications. This can be done with checklists, issues lists, walkthroughs, and inspection meetings. Validation

typically involves actual testing and takes place after verifications are completed. The term 'IV & V' refers to

Independent                          Verification                         and                          Validation.

8.What is a 'walkthrough'?

* A 'walkthrough' is an informal meeting for evaluation or informational purposes. Little or no preparation is

usually required.
9.What's an 'inspection'?

* An inspection is more formalized than a 'walkthrough', typically with 3-8 people including a moderator, reader,

and a recorder to take notes. The subject of the inspection is typically a document such as a requirements spec

or a test plan, and the purpose is to find problems and see what's missing, not to fix anything. Attendees should

prepare for this type of meeting by reading thru the document; most problems will be found during this

preparation. The result of the inspection meeting should be a written report.

10.What kinds of testing should be considered?

* Black box testing - not based on any knowledge of internal design or code. Tests are based on requirements

and functionality.

* White box testing - based on knowledge of the internal logic of an application's code. Tests are based on

coverage of code statements, branches, paths, conditions.

* Unit testing - the most 'micro' scale of testing; to test particular functions or code modules. Typically done by

the programmer and not by testers, as it requires detailed knowledge of the internal program design and code.

Not always easily done unless the application has a well-designed architecture with tight code; may require

developing test driver modules or test harnesses.
* Incremental integration testing - continuous testing of an application as new functionality is added; requires

that various aspects of an application's functionality be independent enough to work separately before all parts of

the program are completed, or that test drivers be developed as needed; done by programmers or by testers.

* Integration testing - testing of combined parts of an application to determine if they function together correctly.

The 'parts' can be code modules, individual applications, client and server applications on a network, etc. This

type of testing is especially relevant to client/server and distributed systems.

* Functional testing - black-box type testing geared to functional requirements of an application; this type of

testing should be done by testers. This doesn't mean that the programmers shouldn't check that their code works

before releasing it (which of course applies to any stage of testing.)

* System testing - black-box type testing that is based on overall requirements specifications; covers all

combined parts of a system.

* End-to-end testing - similar to system testing; the 'macro' end of the test scale; involves testing of a complete

application environment in a situation that mimics real-world use, such as interacting with a database, using

network communications, or interacting with other hardware, applications, or systems if appropriate.

* Sanity testing or smoke testing - typically an initial testing effort to determine if a new software version is

performing well enough to accept it for a major testing effort. For example, if the new software is crashing

systems every 5 minutes, bogging down systems to a crawl, or corrupting databases, the software may not be in

a 'sane' enough condition to warrant further testing in its current state.
* Regression testing - re-testing after fixes or modifications of the software or its environment. It can be difficult

to determine how much re-testing is needed, especially near the end of the development cycle. Automated

testing tools can be especially useful for this type of testing.

* Acceptance testing - final testing based on specifications of the end-user or customer, or based on use by end-

users/customers over some limited period of time.

* Load testing - testing an application under heavy loads, such as testing of a web site under a range of loads to

determine at what point the system's response time degrades or fails.

* Stress testing - term often used interchangeably with 'load' and 'performance' testing. Also used to describe

such tests as system functional testing while under unusually heavy loads, heavy repetition of certain actions or

inputs, input of large numerical values, large complex queries to a database system, etc.

* Performance testing - term often used interchangeably with 'stress' and 'load' testing. Ideally 'performance'

testing (and any other 'type' of testing) is defined in requirements documentation or QA or Test Plans.

* Usability testing - testing for 'user-friendliness'. Clearly this is subjective, and will depend on the targeted end-

user or customer. User interviews, surveys, video recording of user sessions, and other techniques can be used.

Programmers and testers are usually not appropriate as usability testers.

* Install/uninstall testing - testing of full, partial, or upgrade install/uninstall processes.

* Recovery testing - testing how well a system recovers from crashes, hardware failures, or other catastrophic

problems.
* Failover testing - typically used interchangeably with 'recovery testing'

* Security testing - testing how well the system protects against unauthorized internal or external access, willful

damage, etc; may require sophisticated testing techniques.

* Compatability testing - testing how well software performs in a particular hardware/software/operating

system/network/etc. environment.

* Exploratory testing - often taken to mean a creative, informal software test that is not based on formal test

plans or test cases; testers may be learning the software as they test it.

* Ad-hoc testing - similar to exploratory testing, but often taken to mean that the testers have significant

understanding of the software before testing it.

* Context-driven testing - testing driven by an understanding of the environment, culture, and intended use of

software. For example, the testing approach for life-critical medical equipment software would be completely

different than that for a low-cost computer game.

* User acceptance testing - determining if software is satisfactory to an end-user or customer.

* Comparison testing - comparing software weaknesses and strengths to competing products.
* Alpha testing - testing of an application when development is nearing completion; minor design changes may

still be made as a result of such testing. Typically done by end-users or others, not by programmers or testers.

* Beta testing - testing when development and testing are essentially completed and final bugs and problems

need to be found before final release. Typically done by end-users or others, not by programmers or testers.

* Mutation testing - a method for determining if a set of test data or test cases is useful, by deliberately

introducing various code changes ('bugs') and retesting with the original test data/cases to determine if the

'bugs' are detected. Proper implementation requires large computational resources.

11.What are 5 common problems in the software development process?

* Solid requirements - clear, complete, detailed, cohesive, attainable, testable requirements that are agreed to

by all players. Use prototypes to help nail down requirements. In 'agile'-type environments, continuous

coordination with customers/end-users is necessary.

* Realistic schedules - allow adequate time for planning, design, testing, bug fixing, re-testing, changes, and

documentation; personnel should be able to complete the project without burning out.

* Adequate testing - start testing early on, re-test after fixes or changes, plan for adequate time for testing and

bug-fixing. 'Early' testing ideally includes unit testing by developers and built-in testing and diagnostic

capabilities.

* Stick to initial requirements as much as possible - be prepared to defend against excessive changes and

additions once development has begun, and be prepared to explain consequences. If changes are necessary, they

should be adequately reflected in related schedule changes. If possible, work closely with customers/end-users to
manage expectations. This will provide them a higher comfort level with their requirements decisions and

minimize excessive changes later on.

* Communication - require walkthroughs and inspections when appropriate; make extensive use of group

communication tools - e-mail, groupware, networked bug-tracking tools and change management tools, intranet

capabilities, etc.; insure that information/documentation is available and up-to-date - preferably electronic, not

paper; promote teamwork and cooperation; use protoypes if possible to clarify customers' expectations.

12.What is software 'quality'?

* Quality software is reasonably bug-free, delivered on time and within budget, meets requirements and/or

expectations, and is maintainable. However, quality is obviously a subjective term. It will depend on who the

'customer' is and their overall influence in the scheme of things. A wide-angle view of the 'customers' of a

software development project might include end-users, customer acceptance testers, customer contract officers,

customer management, the development organization's.

* Management/accountants/testers/salespeople, future software maintenance engineers, stockholders, magazine

columnists, etc. Each type of 'customer' will have their own slant on 'quality' - the accounting department might

define quality in terms of profits while an end-user might define quality as user-friendly and bug-free.

13.What is 'good code'?

* 'Good code' is code that works, is bug free, and is readable and maintainable. Some organizations have coding

'standards' that all developers are supposed to adhere to, but everyone has different ideas about what's best, or

what is too many or too few rules. There are also various theories and metrics, such as McCabe Complexity

metrics. It should be kept in mind that excessive use of standards and rules can stifle productivity and creativity.

'Peer reviews', 'buddy checks' code analysis tools, etc. can be used to check for problems and enforce standards.

For C and C++ coding, here are some typical ideas to consider in setting rules/standards; these may or may not

apply to a particular situation:
* Minimize or eliminate use of global variables.

* Use descriptive function and method names - use both upper and lower case, avoid abbreviations, use as many

characters as necessary to be adequately descriptive (use of more than 20 characters is not out of line); be

consistent in naming conventions.

* Use descriptive variable names - use both upper and lower case, avoid abbreviations, use as many characters

as necessary to be adequately descriptive (use of more than 20 characters is not out of line); be consistent in

naming conventions.

* Function and method sizes should be minimized; less than 100 lines of code is good, less than 50 lines is

preferable.

* Function descriptions should be clearly spelled out in comments preceding a function's code.

* Use whitespace generously - vertically and horizontally.

* Each line of code should contain 70 characters max.

* One code statement per line.
* Coding style should be consistent throught a program (eg, use of brackets, indentations, naming conventions,

etc.)

* In adding comments, err on the side of too many rather than too few comments; a common rule of thumb is

that there should be at least as many lines of comments (including header blocks) as lines of code.

* No matter how small, an application should include documentaion of the overall program function and flow

(even a few paragraphs is better than nothing); or if possible a separate flow chart and detailed program

documentation.

* Make extensive use of error handling procedures and status and error logging.

* For C++, to minimize complexity and increase maintainability, avoid too many levels of inheritance in class

heirarchies (relative to the size and complexity of the application). Minimize use of multiple inheritance, and

minimize use of operator overloading (note that the Java programming language eliminates multiple inheritance

* For C++, keep class methods small, less than 50 lines of code per method is preferable.

* For C++, make liberal use of exception handlers.

14.What is 'good design'?
* 'Design' could refer to many things, but often refers to 'functional design' or 'internal design'. Good internal

design is indicated by software code whose overall structure is clear, understandable, easily modifiable, and

maintainable; is robust with sufficient error-handling and status logging capability; and works correctly when

implemented. Good functional design is indicated by an application whose functionality can be traced back to

customer and end-user requirements.For programs that have a user interface, it's often a good idea to assume

that the end user will have little computer knowledge and may not read a user manual or even the on-line help;

some common rules-of-thumb include:

* The program should act in a way that least surprises the user

* It should always be evident to the user what can be done next and how to exit

* The program shouldn't let the users do something stupid without warning them.

15.What is SEI? CMM? CMMI? ISO? IEEE? ANSI? Will it help?

* SEI = 'Software Engineering Institute' at Carnegie-Mellon University; initiated by the U.S. Defense Department

to help improve software development processes.

* CMM = 'Capability Maturity Model', now called the CMMI ('Capability Maturity Model Integration'), developed by

the SEI. It's a model of 5 levels of process 'maturity' that determine effectiveness in delivering quality software.

It is geared to large organizations such as large U.S. Defense Department contractors. However, many of the QA

processes involved are appropriate to any organization, and if reasonably applied can be helpful. Organizations

can receive CMMI ratings by undergoing assessments by qualified auditors.
* Level 1 - characterized by chaos, periodic panics, and heroic efforts required by individuals to successfully

complete projects. Few if any processes in place; successes may not be repeatable.

* Level 2 - software project tracking, requirements management, realistic planning, and configuration

management processes are in place; successful practices can be repeated.

* Level 3 - standard software development and maintenance processes are integrated throughout an

organization; a Software Engineering Process Group is is in place to oversee software processes, and training

programs are used to ensure understanding and compliance.

* Level 4 - metrics are used to track productivity, processes, and products. Project performance is predictable,

and quality is consistently high.

* Level 5 - the focus is on continouous process improvement. The impact of new processes and technologies can

be predicted and effectively implemented when required.

* Perspective on CMM ratings: During 1997-2001, 1018 organizations were assessed. Of those, 27% were rated

at Level 1, 39% at 2, 23% at 3, 6% at 4, and 5% at 5. (For ratings during the period 1992-96, 62% were at

Level 1, 23% at 2, 13% at 3, 2% at 4, and 0.4% at 5.) The median size of organizations was 100 software

engineering/maintenance personnel; 32% of organizations were U.S. federal contractors or agencies. For those

rated at Level 1, the most problematical key process area was in Software Quality Assurance.

* ISO = 'International Organisation for Standardization' - The ISO 9001:2000 standard (which replaces the

previous standard of 1994) concerns quality systems that are assessed by outside auditors, and it applies to

many kinds of production and manufacturing organizations, not just software. It covers documentation, design,

development, production, testing, installation, servicing, and other processes. The full set of standards consists

of: (a)Q9001-2000 - Quality Management Systems: Requirements; (b)Q9000-2000 - Quality Management

Systems: Fundamentals and Vocabulary; (c)Q9004-2000 - Quality Management Systems: Guidelines for
Performance Improvements. To be ISO 9001 certified, a third-party auditor assesses an organization, and

certification is typically good for about 3 years, after which a complete reassessment is required. Note that ISO

certification does not necessarily indicate quality products - it indicates only that documented processes are

followed. Also see http://www.iso.ch/ for the latest information. In the U.S. the standards can be purchased via

the ASQ web site at http://e-standards.asq.org/

* IEEE = 'Institute of Electrical and Electronics Engineers' - among other things, creates standards such as 'IEEE

Standard for Software Test Documentation' (IEEE/ANSI Standard 829), 'IEEE Standard of Software Unit Testing

(IEEE/ANSI Standard 1008), 'IEEE Standard for Software Quality Assurance Plans' (IEEE/ANSI Standard 730),

and others.

* ANSI = 'American National Standards Institute', the primary industrial standards body in the U.S.; publishes

some software-related standards in conjunction with the IEEE and ASQ (American Society for Quality).

* Other software development/IT management process assessment methods besides CMMI and ISO 9000 include

SPICE, Trillium, TickIT, Bootstrap, ITIL, MOF, and CobiT.

16.What is the 'software life cycle'?

* The life cycle begins when an application is first conceived and ends when it is no longer in use. It includes

aspects such as initial concept, requirements analysis, functional design, internal design, documentation

planning, test planning, coding, document preparation, integration, testing, maintenance, updates, retesting,

phase-out, and other aspects.

17.Will automated testing tools make testing easier?

* Possibly For small projects, the time needed to learn and implement them may not be worth it. For larger

projects, or on-going long-term projects they can be valuable.
* A common type of automated tool is the 'record/playback' type. For example, a tester could click through all

combinations of menu choices, dialog box choices, buttons, etc. in an application GUI and have them 'recorded'

and the results logged by a tool. The 'recording' is typically in the form of text based on a scripting language that

is interpretable by the testing tool. If new buttons are added, or some underlying code in the application is

changed, etc. the application might then be retested by just 'playing back' the 'recorded' actions, and comparing

the logging results to check effects of the changes. The problem with such tools is that if there are continual

changes to the system being tested, the 'recordings' may have to be changed so much that it becomes very

time-consuming to continuously update the scripts. Additionally, interpretation and analysis of results (screens,

data, logs, etc.) can be a difficult task. Note that there are record/playback tools for text-based interfaces also,

and for all types of platforms.

* Another common type of approach for automation of functional testing is 'data-driven' or 'keyword-driven'

automated testing, in which the test drivers are separated from the data and/or actions utilized in testing (an

'action' would be something like 'enter a value in a text box'). Test drivers can be in the form of automated test

tools or custom-written testing software. The data and actions can be more easily maintained - such as via a

spreadsheet - since they are separate from the test drivers. The test drivers 'read' the data/action information to

perform specified tests. This approach can enable more efficient control, development, documentation, and

maintenance of automated tests/test cases.

* Other automated tools can include:

* Code analyzers - monitor code complexity, adherence to standards, etc.

* Coverage analyzers - these tools check which parts of the code have been exercised by a test, and may be

oriented to code statement coverage, condition coverage, path coverage, etc.
* Memory analyzers - such as bounds-checkers and leak detectors.

* Load/performance test tools - for testing client/server and web applications under various load levels.

* Web test tools - to check that links are valid, HTML code usage is correct, client-side and server-side programs

work, a web site's interactions are secure.

* Other tools - for test case management, documentation management, bug reporting, and configuration

management.

What's OPERATING SYSTEM?
An Operating System, or OS, is a software program that enables the computer hardware to
communicate and operate with the computer software. Without a computer Operating System,
a computer would be useless.

OPERATING SYSTEM TYPES
As computers have progressed and developed so have the types of operating systems. Below
is a basic list of the different types of operating systems and a few examples of Operating
Systems that fall into each of the categories. Many computer Operating Systems will fall into
more than one of the below categories.

GUI - Short for Graphical User Interface, a GUI Operating System contains graphics and icons
and is commonly navigated by using a computer mouse. See our GUI dictionary definition for
a complete definition. Below are some examples of GUI Operating Systems.

System 7.x
Windows 98
Windows CE

Multi-user - A multi-user Operating System allows for multiple users to use the same
computer at the same time and/or different times. See our multi-user dictionary definition for
a complete definition for a complete definition. Below are some examples of multi-user
Operating Systems.

Linux
Unix
Windows 2000
Windows XP
Mac OS X
Multiprocessing - An Operating System capable of supporting and utilizing more than one
computer processor. Below are some examples of multiprocessing Operating Systems.

Linux
Unix
Windows 2000
Windows XP
Mac OS X

Multitasking - An Operating system that is capable of allowing multiple software processes to
run at the same time. Below are some examples of multitasking Operating Systems.

Unix
Windows 2000
Windows XP
Mac OS X

Multithreading - Operating systems that allow different parts of a software program to run
concurrently. Operating systems that would fall into this category are:

Linux
Unix
Windows 2000
Windows XP
Mac OS X

What are the basic functions of an operating system?

- Operating system controls and coordinates the use of the hardware among the various
applications programs for various uses. Operating system acts as resource allocator and
manager. Since there are many possibly conflicting requests for resources the operating
system must decide which requests are allocated resources to operating the computer system
efficiently and fairly. Also operating system is control program which controls the user
programs to prevent errors and improper use of the computer. It is especially concerned with
the operation and control of I/O devices.

Why paging is used?
-Paging is solution to external fragmentation problem which is to permit the logical address
space of a process to be noncontiguous, thus allowing a process to be allocating physical
memory wherever the latter is available.

While running DOS on a PC, which command would be used to duplicate the entire
diskette?
diskcopy

What resources are used when a thread created? How do they differ from those
when a process is created?
When a thread is created the threads does not require any new resources to execute the
thread shares the resources like memory of the process to which they belong to. The benefit
of code sharing is that it allows an application to have several different threads of activity all
within the same address space. Whereas if a new process creation is very heavyweight
because it always requires new address space to be created and even if they share the
memory then the inter process communication is expensive when compared to the

What is virtual memory?
Virtual memory is hardware technique where the system appears to have more memory that it
actually does. This is done by time-sharing, the physical memory and storage parts of the
memory one disk when they are not actively being used.
What is Throughput, Turnaround time, waiting time and Response time?
Throughput – number of processes that complete their execution per time unit. Turnaround
time – amount of time to execute a particular process. Waiting time – amount of time a
process has been waiting in the ready queue. Response time – amount of time it takes from
when a request was submitted until the first response is produced, not output (for time-
sharing environment).

What is the state of the processor, when a process is waiting for some event to occur?
Waiting state

What is the important aspect of a real-time system or Mission Critical Systems?
A real time operating system has well defined fixed time constraints. Process must be
done within the defined constraints or the system will fail. An example is the operating
system for a flight control computer or an advanced jet airplane. Often used as a control
device in a dedicated application such as controlling scientific experiments, medical
imaging systems, industrial control systems, and some display systems. Real-Time
systems may be either hard or soft real-time. Hard real-time: Secondary storage limited or
absent, data stored in short term memory, or read-only memory (ROM), Conflicts with
time-sharing systems, not supported by general-purpose operating systems. Soft real-
time: Limited utility in industrial control of robotics, Useful in applications (multimedia,
virtual reality) requiring advanced operating-system features.

What is the difference between Hard and Soft real-time systems?
- A hard real-time system guarantees that critical tasks complete on time. This goal
requires that all delays in the system be bounded from the retrieval of the stored data to
the time that it takes the operating system to finish any request made of it. A soft real
time system where a critical real-time task gets priority over other tasks and retains that
priority until it completes. As in hard real time systems kernel delays need to be bounded

What is the cause of thrashing? How does the system detect thrashing?
Once it detects thrashing, what can the system do to eliminate this problem? - Thrashing
is caused by under allocation of the minimum number of pages required by a process,
forcing it to continuously page fault. The system can detect thrashing by evaluating the
level of CPU utilization as compared to the level of multiprogramming. It can be
eliminated by reducing the level of multiprogramming.

Multi programming: Multiprogramming is the technique of running several programs at a
time using timesharing. It allows a computer to do several things at the same time.
Multiprogramming creates logical parallelism. The concept of multiprogramming is that
the operating system keeps several jobs in memory simultaneously. The operating system
selects a job from the job pool and starts executing a job, when that job needs to wait for
any i/o operations the CPU is switched to another job. So the main idea here is that the
CPU is never idle. Multi tasking: Multitasking is the logical extension of
multiprogramming .The concept of multitasking is quite similar to multiprogramming but
difference is that the switching between jobs occurs so frequently that the users can
interact with each program while it is running. This concept is also known as time-
sharing systems. A time-shared operating system uses CPU scheduling and
multiprogramming to provide each user with a small portion of time-shared system. Multi
threading: An application typically is implemented as a separate process with several
threads of control. In some situations a single application may be required to perform
several similar tasks for example a web server accepts client requests for web pages,
images, sound, and so forth. A busy web server may have several of clients concurrently
accessing it. If the web server ran as a traditional single-threaded process, it would be
able to service only one client at a time. The amount of time that a client might have to
wait for its request to be serviced could be enormous. So it is efficient to have one
process that contains multiple threads to serve the same purpose. This approach would
multithread the web-server process, the server would create a separate thread that would
listen for client requests when a request was made rather than creating another process it
would create another thread to service the request. To get the advantages like
responsiveness, Resource sharing economy and utilization of multiprocessor architectures

What is hard disk and what is its purpose?
Hard disk is the secondary storage device, which holds the data in bulk, and it holds the
data on the magnetic medium of the disk. Hard disks have a hard platter that holds the
magnetic medium, the magnetic medium can be easily erased and rewritten, and a typical
desktop machine will have a hard disk with a capacity of between 10 and 40 gigabytes.
Data is stored onto the disk in the form of files.

What is fragmentation? Different types of fragmentation?

- Fragmentation occurs in a dynamic memory allocation system when many of the free
blocks are too small to satisfy any request. External Fragmentation: External
Fragmentation happens when a dynamic memory allocation algorithm allocates some
memory and a small piece is left over that cannot be effectively used. If too much
external fragmentation occurs, the amount of usable memory is drastically reduced. Total
memory space exists to satisfy a request, but it is not contiguous. Internal Fragmentation:
Internal fragmentation is the space wasted inside of allocated memory blocks because of
restriction on the allowed sizes of allocated blocks. Allocated memory may be slightly
larger than requested memory; this size difference is memory internal to a partition, but
not being used

What is DRAM? In which form does it store data?
- DRAM is not the best, but it‘s cheap, does the job, and is available almost everywhere
you look. DRAM data resides in a cell made of a capacitor and a transistor. The capacitor
tends to lose data unless it‘s recharged every couple of milliseconds, and this recharging
tends to slow down the performance of DRAM compared to speedier RAM types.

What is Dispatcher?
- Dispatcher module gives control of the CPU to the process selected by the short-term
scheduler; this involves: Switching context, Switching to user mode, Jumping to the
proper location in the user program to restart that program, dispatch latency – time it
takes for the dispatcher to stop one process and start another running.

What is CPU Scheduler?
- Selects from among the processes in memory that are ready to execute, and allocates the
CPU to one of them. CPU scheduling decisions may take place when a process:
1.Switches from running to waiting state. 2.Switches from running to ready state.
3.Switches from waiting to ready. 4.Terminates. Scheduling under 1 and 4 is non-
preemptive. All other scheduling is preemptive.

What is Context Switch?
- Switching the CPU to another process requires saving the state of the old process and
Context-switch time is pure overhead, because the system does no useful work while
switching. Its speed varies from machine to machine, depending on the memory speed,
the number of registers which must be copied, the existed of special instructions(such as
a single instruction to load or store all registers).

What is cache memory?
- Cache memory is random access memory (RAM) that a computer microprocessor can
access more quickly than it can access regular RAM. As the microprocessor processes
data, it looks first in the cache memory and if it finds the data there (from a previous
reading of data), it does not have to do the more time-consuming reading of data from
larger memory.

What is a Safe State and what is its use in deadlock avoidance?
- When a process requests an available resource, system must decide if immediate
allocation leaves the system in a safe state. System is in safe state if there exists a safe
sequence of all processes. Deadlock Avoidance: ensure that a system will never enter an
unsafe state.

What is a Real-Time System?
- A real time process is a process that must respond to the events within a certain time
period. A real time operating system is an operating system that can run real time
processes successfully


To top