Section - Computer Science 1. What will be the output of the following piece of code? int! int a=10,b=20;! printf("a:%d B:%d\n",a,b);! a=(a+b)-(b=a);! printf("a:%d B:%d\n",a,b);! return 1; (i) A: 10, B: 20 (ii) A: 20, B: 10 (iii) A: 30, B: 20 (iv) A: 20, B: 30 2. What will be the result of the following C language program?! int a = 0; int b = 20; char x = 1; char y = 10; if(a,b,x,y)! printf("welcome"); (i) Welcome (ii) Blank (iii) Compiler error (iv) Linker error 3. What will be the result of the following C language program? void!! int const *p = 5;! printf("%d",++(*p)); (i) 6 (ii) 5 (iii) Linker error (iv) Compiler error
4. Given any initial natural number, consider the sequence of numbers generated by repeatedly following the rule: divide by two if the number is even or multiply by 3 and add 1 if the number is odd. Suppose that the initial number is 23. Which of the following numbers appear in the resulting string of numbers? (i) 1 (ii) 12 (iii) 36 (iv) 150 5. What will be the result of the following C language program? struct date;! struct student! char name[30];! struct date dob; stud; struct date int day, month, year; ; scanf("%s%d%d%d", stud.rollno, &student.dob.day, &student.dob.month); (i) Compiler error: Undefined structure dob (ii) Compiler error: Undefined structure name (iii) Compiler error: Undefined structure date (iv) Linker error 6. What does the following C language declaration mean?!! int (*decl)[30] (i) array[30] of pointer to int (ii) function returning pointer to int 30 (iii) pointer to array[30] of int (iv) None of the above 7. With respect to the C++ programming language, which is the parameter that is added to every non-static member function when it is called? (i) this pointer (ii) that pointer (iii) datatype (iv) return value
8. The following piece of code will be allowed to execute by the compiler? struct A int a; int f() const return a++; ; 9. In C++, pass by value always invokes the function or returns a value that is based on the value. This value is passed as a constant or a variable with value. (i) Yes, always (ii) Only sometimes (iii) No, never (iv) None of the above 10. In following C language program, which statement would you add in the function fun so that the address of a gets stored in j?! int *j;! void fun(int **);! fun(&j); void fun(int **k)! int a = 0;! /* Add the statement here*/ (i) **k = &a (ii) *j = &a (iii) *k = &a (iv) *a = &k 11. What will be the result of the following C language program?!!! int i = 258;! int *iptr = &i;!! printf("%d %d", *((char*)iptr), *((char*)iptr+1) ); (i) 258 0 (ii) 1 0 (iii) 2 1 (iv) 1 2
12. Which of the following statements is not true? (i) A message provides response to a method (ii) Objects communicate by sending messages to each other (iii) A dangling pointer arises when you use the address of an object after its lifetime is over. (iv) An wrapper class is a class with no functionality of its own. 13. Which of the following statements is not true? (i) A memory leak occurs when a program loses the ability to free a block of dynamically allocated memory. (ii) Objects that point to other objects are called null objects. (iii) A handle class is a class that maintains a pointer to an object that is programmatically accessible through the public interface of the handle class. (iv) A common form of an action class is a simple class containing just one virtual function. 14. Which of the following statements is not true? (i) NULL can be a value for pointer type variables. (ii) VOID is type identifier which has no size. (iii) null *ptr = VOID (iv) void *ptr = NULL 15. How many different trees are possible with 10 nodes? (i) 1024 (ii) 1014 (iii) 1000 (iv) 1034 16. For the following tree, the pre-order traversal can be represented by (i) F, G, H, I, A, B, C, D, E, (ii) F, B, G, A, D, I, C, E, H (iii) A, B, E, D, C, F, G, H, I (iv) A, B, C, D, E, F, G, H, I 17. Which of the following statements are incorrect? (i) Spatial locality, refers to the reuse of specific data, and/or resources, within a relatively small time duration. (ii) Temporal locality, refers to the use of data elements within relatively close storage locations. (iii) Both are incorrect. (iv) Neither one is incorrect.
18. You can search the data in a linked list by using (i) Binary search (ii) Hash search (iii) Self-organizing search (iv) Linear search 19. The following piece of code will be allowed by the C++ compiler? class A class B; public: class B ; ; 20. Context switching can occur only in the kernel mode. 21. What will be the output of the following lines of program code?! fork(); printf("hello World!"); (i) Hello World! (ii) Hello World!Hello World! (iii) Blank (iv) None of the above 22. The stack is where the malloc() gets memory. 23. When a process creates a new process using the fork() operation, which of the following is shared between the parent process and the child process? (i) Shared memory segments (ii) Stack (iii) Heap (iv) All of the above
24. Consider the following piece of code. class A /*... */ ; class B /*... */ ; class C /*... */ ; class Z : A class Y : B class X : C int f(); /*... */ ; ; ; int Z::Y::X f() char j; return 0; Here, the search for the name j in the definition of function f follows the order: (i) In body of f --> In X and C --> In Y and B --> In Z and A --> Global Scope (ii) In body of f --> In X and C --> In Y and B --> In Z and A (iii) In body of f --> In Z and A --> In Y and B --> In X and C (iv) In body of f --> In Z and A --> In Y and B --> In X and C --> Global Scope 25. Which of the following statements is not true? (i) Kernel threads need not be associated with a process whereas every user thread belongs to a process (ii) User level threads are unknown to the kernel whereas the kernel is aware of the kernel threads (iii) Kernel threads are less expensive to maintain that user threads (iv) Thread creation typically uses less resources than process creation