You are on page 1of 287
Computer Science Series RTs elie] MC@s COMPUTER SCIENCE Timothy J Williams Contents Preface to the Second Edition vii Preface to the First Edition viii Acknowledgemenis x 1, Programming with C 1 2. Unix 43 3. Principles of Programming Languages 76 4, Mathematical Foundations of Computer Science 96 5. Operating Systems 131 6. Automata Theory 146 7. Principles of Compiler Design 158 8. Computer Organization 171 9. Data Structures 9. 10. Computer Graphics. 224 11, System Software 235. 12. Database Management Systems 242 13. Object Oriented Programming Using C++ 250 14. Computer Networks 264 15. Software Engineering 272 16. SQL*PLUS, SQL, PL/SQL, Forms and Reports 279 Appendix: Computer Science Question Paper for GATE 2005 315 Suggested Books for Reading 333 Preface to the Second Edition This book is primarily written for undergraduate students of computer science seeking admission to master’s program in computer science through examinations like GATE and GRE (in computer science). It will also be helpful for those taking computer science tests conducted by some compa- nies for recruitment. It cont more than 180 questions from the core areas of computer science. The questions are grouped subject-wise. The overwhelming response to the first edition of this book has inspired me to bring out this second edition which is a thoroughly revised and updated version of the first. ‘The book now has sixteen chapters. The first chapter deals with the programming language C that is still popular in spite of its age. The second chapter contains questions on UNIX, which has become popular due to its simple and easy-to-understand structure, In the third chapter, a variety of problems based on the principles of programming languages are discussed. The fourth chapter, Mathematical Foundations of Computer Science, has been revamped. It has questions based on the mathematical principles that are vital to the better understanding of com- puter science, Numerous problems from operations research, numerical methods, matrices and determinants, permutations and combinations, probability and statistics, discrete math, calculus and theory of equations are included in this chapter. In almost all the other chapters also some revision has been effected and additional questions included. A new chapter on Oracle that covers SQL, PL/SQL, SQL*Plus, FORMS and REPORTS has ‘been added towards the end of the book. Also included is the Computer Science question paper for GATE 2005 as an appendix, This will help the students in the preparation of their GATE examina- tion. Every effort has been made to make this book error-free. I welcome all constructive criticism of the book. Timotiy J Wa 4AMS Preface to the First Edition This book of multiple choice questions has been compiled by taking into account the requirements of undergraduate students of Computer Science and Engineering. It contains more than 1600 questions that are carefully selected from the core subjects included in the curriculum of the major universities imparting computer education in our country. A multipurpose book of this kind would not only serve the purposes of students appearing for various competitive examinations but would also expose professionals to a wide array of questions chosen from areas of contemporary relevance and interest. The questions are grouped subject-wise, keeping in view the needs of individuals with various levels of expertise and background in computers. The book is ideal for students preparing for AGRE test in computer science as well as GATE and other similar exams. It is equally useful for students secking placement in reputed firms as a good number of questions from the screening tests conducted by these organisations are included in the text, ‘The book is divided into fifteen chapters. The first chapter deals with the programming Ian- guage C which is notable for the power and freedom offered to the users, Kernighan and Ritchie have made the language accessible to all by bestowing low-level features in an otherwise, high level language. But, even ace programmers are often encountered with difficulties while operating C language. Hence a large number of questions in this chapter are devoted to make readers aware of the potential problems incurred while tackling C. The second chapter contains questions on UNIX & C, a powerful combination made popular due to the simple and easy-to-understand structure. In third chapter, a variety of problems based on the principles of programming languages with a special emphasis on PASCAL are discussed ‘The fourth chapter dwells on the questions relating to the mathematical principles that are vital to the better understanding of computer science. Numerous problems on operations research, numerical methods, matrices and determinants, permutations and combinations, probability and statistics, discrete maths, calculus. and theory of equations are included in this chapter. Various relevant topics in computer science are covered systematically in rest of the chapters. ‘The process of analysis and organised reasoning is vital to programming. I believe that the questions included in this book will sharpen the logical thinking and reasoning of the readers which would help them a great deal in mastering the art of programming. Every effort has been made to make the book, simple and error-free, | welcome any constructive criticism of the book and will be grateful for any honest appraisal from the readers. TIMOTHY J WILLIAMS: Acknowledgements All praise, laud and honor to Jesus Christ for His amazing grace and guidance. Prof. Kuppuswami of Pondicheery University who unraveled my latent and dormant paten- tial of writing a book of this kind. Special thanks to him. This book is not the outcome of my effort alone. | am indebted to Mr. Selvaradjou, Dr. Antony, Dr. Sukumaran and my ex-colleagues at Pondicherry Engineering College for their contribution and cooperation. Thanks to Ms Vibha Mahajan, Mr Jacob Alexander, Ms Mini Narayanan, Ms Anjali Razdan and others at Tata McGraw-Hill for their efforts and cooperation while working on this revised edition. 1 would have thanked Hannah, had it been an Indian tradition to thank one’s own wife Tiorny J WILLIAMS Chapter 1 Programming with C 1, Choose the correct statement. (a) Use of goto enhances the logical clarity of a code. (b) Use of goto makes the debugging task easier. (c) Use goto when you want to jump out of a nested loop. (d) Never use goto, 2. Which is true of conditional compilation? (a) Itis taken care of by the compiler. (b) It is setting the compiler option conditionally (c) It is compiling a program based on a condition (d) It is taken care of by the pre-processor. 3. C was primarily developed as (a) systems programming language (b) general purpose language (c) data processing language (d) none of the above 4. Cisa (a) high level language (b} low level language (c) high level language with some low level features. (d) low level language with some high level features. 5. Even if a particular implementation doesn't limit the number of characters. in an identifier, it is advisable to be concise because {a} chances of typographic errors are less (b) it may be processed by assembler, loaders, etc., which may have their own rules that may contradict the language rules % 16. *iL. #12. #13, “14, MCQs in Computer Science (c) by being concise, one can be mnemonic (d) none of the above ‘The minimum number of temporary variables needed to swap the contents of two variables is {a} 1 (b) 2 (©) 3 (a 0 ‘The purpose of the following program fragment bes + bj s = b- be b- 5; where =, b are two integers is to (a) transfer the contents of s to b (b) transfer the contents of b to s (c) exchange (swap) the contents of s and b (d) negate the contents of s and b Consider the function find(int x, int y) {return(( x < vy) ? 0: ( x - yhir) Let a, » be two non-negative integers. The call find{a, find(a, )) cam be used to find the (a) maximum of a, (b) positive difference of a, (e) sum ofa, b (d) minimum of a,b Let a,b be two non-negative integers. Which of the following calls, finds the positive difference of a and b? (a) findla,b) + £ind(b,al (b) find(a,£ind(a,b)) (ce) a + findta,b) (d) b + findta,b) If integer needs two bytes of storage, then maximum value of an unsigned integer is (a) 2-1 (b) 25-1 fc) 26 (@ 2° If imeger needs two bytes of storage, then maximum value of a signed integer is (a) 2-1 (by 25-4 fc) 2° (a 2° printf (*8d", printé("tim™)); (a) results in a syntax error {b) outputs tim3 (©) outputs garbage (d) prints tim and terminates abruptly If abe: is the input, then the following program fragment char x. ys z printfi*td*, scanf (*8ctctc*, &x, &y, &z)); results in (a) a syntax error (b) a fatal error {e) segmentation violation (d) printing of 3 Consider the statements putchar (getchar()}; putchar (getchar());

You might also like