Quick Google Search

SOME MIND QUESTION FRM DATA BASE

Database MCQ Questions :

1.Which of the following isolation levels will lock all rows scanned to build a result data set?
·         A. Uncommitted Read
·         B. Cursor Stability
·         C. Read Stability
·         D. Repeatable Read

2. Application A holds an Exclusive lock on table TAB1 and needs to acquire an Exclusive lock on table TAB2. Application B holds an Exclusive lock on table TAB2 and needs to acquire an Exclusive lock on table TAB1. If lock timeout is set to -1 and both applications are using the Read Stability isolation level, which of the following will occur?
·         A. Applications A and B will cause a deadlock situation
·         B. Application B will read the copy of table TAB1 that was loaded into memory when Application A first read it
·         C. Application B will read the data in table TAB1 and see uncommitted changes made by Application A
·         D. Application B will be placed in a lock-wait state until Application A releases its lock

3. A transaction using the Read Stability isolation level scans the same table multiple times before it terminates. Which of the following can occur within this transaction's processing?
·         A. Uncommitted changes made by other transactions can be seen from one scan to the next.
·         B. Rows removed by other transactions that appeared in one scan will no longer appear in subsequent scans.
·         C. Rows added by other transactions that did not appear in one scan can be seen in subsequent scans.
·         D. Rows that have been updated can be changed by other transactions from one scan to the next.

4.Two applications have created a deadlock cycle in the locking subsystem. If lock timeout is set to 30 and both applications were started at the same time, what action will the deadlock detector take when it "wakes up" and discovers the deadlock?
·         A. It will randomly pick an application and rollback its current transaction
·         B. It will rollback the current transactions of both applications
·         C. It will wait 30 seconds, then rollback the current transactions of both applications if the deadlock has not been resolved
·         D. It will go back to sleep for 30 seconds, then if the deadlock still exists, it will randomly pick an application and rollback its current transaction

5.Application A is running under the Repeatable Read isolation level and holds an Update lock on table TAB1. Application B wants to query table TAB1 and cannot wait for Application A to release its lock. Which isolation level should Application B run under to achieve this objective?
·         A. Repeatable Read
·         B. Read Stability
·         C. Cursor Stability
·         D. Uncommitted Read

6.Which of the following DB2 UDB isolation levels will only lock rows during read processing if another transaction tries to drop the table the rows are being read from?
·         A. Repeatable Read
·         B. Read Stability
·         C. Cursor Stability
·         D. Uncommitted Read

7.Application A holds a lock on a row in table TAB1. If lock timeout is set to 20, what will happen when Application B attempts to acquire a compatible lock on the same row?
·         A. Application B will acquire the lock it needs
·         B. Application A will be rolled back if it still holds its lock after 20 seconds have elapsed
·         C. Application B will be rolled back if Application A still holds its lock after 20 seconds have elapsed
·         D. Both applications will be rolled back if Application A still holds its lock after 20 seconds have elapsed

8.To which of the following resources can a lock NOT be applied?
·         A. Table spaces
·         B. Buffer pools
·         C. Tables
·         D. Rows

9.Which of the following causes a lock that is being held by an application using the Cursor Stability isolation level to be released?
·         A. The cursor is moved to another row
·         B. The row the cursor is on is deleted by the application
·         C. The row the cursor is on is deleted by another application
·         D. The row the cursor is on needs to be updated by another application

10.Which of the following modes, when used with the LOCK TABLE statement, will cause the DB2 Database Manager to acquire a table-level lock that prevents other concurrent transactions from accessing data stored in the table while the owning transaction is active?
·         A. SHARE MODE
·         B. ISOLATED MODE
·         C. EXCLUSIVE MODE
·         D. RESTRICT MODE

11.An application has acquired a Share lock on a row in a table and now wishes to update the row. Which of the following statements is true?
·         A. The application must release the row-level Share lock it holds and acquire an Update lock on the row
·         B. The application must release the row-level Share lock it holds and acquire an Update lock on the table
·         C. The row-level Share lock will automatically be converted to a row-level Update lock
·         D. The row-level Share lock will automatically be escalated to a table-level Update lock

12.Application A wants to read a subset of rows from table TAB1 multiple times. Which of the following isolation levels should Application A use to prevent other users from making modifications and additions to table TAB1 that will affect the subset of rows read?
·         A. Repeatable Read
·         B. Read Stability
·         C. Cursor Stability
·         D. Uncommitted Read

13.Application A issues the following SQL statements within a single transaction using the Uncommitted Read isolation level:
SELECT * FROM department WHERE deptno = 'A00';
 UPDATE department SET mgrno = '000100' WHERE deptno = 'A00';
As long as the transaction is not committed, which of the following statements is FALSE?
·         A. Other applications not running under the Uncommitted Read isolation level are prohibited from reading the updated row
·         B. Application A is allowed to read data stored in another table, even if an Exclusive lock is held on that table
·         C. Other applications running under the Uncommitted Read isolation level are allowed to read the updated row
·         D. Application A is not allowed to insert new rows into the DEPARTMENT table as long as the current transaction remains active

14.A table contains a list of all seats available at a football stadium. A seat consists of a section number, a seat number, and whether or not the seat has been assigned. A ticket agent working at the box office generates a list of all unassigned seats. When the agent refreshes the list, it should only change if another agent assigns one or more unassigned seats. Which of the following is the best isolation level to use for this application?
·         A. Repeatable Read
·         B. Read Stability
·         C. Cursor Stability
·         D. Uncommitted Read

15.Which of the following resources can be explicitly locked?
A. Row
B. Page
C. Table
D. Column

16.Application A issues the following SQL statements within in a single
transaction using the Uncommitted Read isolation level:
SELECT * FROM employee WHERE deptno='A00';
UPDATE employee SET salary = salary * 1.1 WHERE deptno='A00';
As long as the transaction has not been committed, which of the following is true for all other applications
not running under the Uncommitted Read isolation level?
A. They can read and make changes to data for any employee in department A00.
B. They can read but not make changes to data for any employee in department A00.
C. They must wait until the transaction is committed before accessing data of any employee in department A00.
D. They must wait until application A disconnects before accessing data of any employee in department A00.

17. Which of the following best describes how locks are used in DB2?
A. To maintain control of updated rows for commit processing
B. To ensure only committed changes are altered by another application
C. To allow two applications to update the same row of data simultaneously
D. To prevent multiple applications from accessing the same data simultaneously

18.If an application issues the same query more than once in the same Unit of Work, which isolation level will not permit this application to see additional rows inserted by other applications?
A. Read Stability (RS)
B. Repeatable Read (RR)
C. Uncommitted Read (UR)
D. Cursor Stability (CS)

19.If DB2 detects a deadlock between application A and application B (each waiting for a lock held by the other one), what action will DB2 take?
A. Rollback the transaction in both applications.
B. Rollback the transaction in one of the two applications.
C. Decrease the lock timeout value for both applications, thereby causing a lock timeout situation.
D. Send a message to let the administrator know of the situation and decide which application or applications should be terminated.

20.How does DB2 protect the integrity of indexes when data is updated?
A. Locks are acquired on the data.
B. Locks are acquired on index keys.
C. Locks are acquired on index pages.
D. Locks are acquired on index pointers.

21.Application A currently holds an exclusive lock on a single row and application B tries to access that row. If lock timeout is set to -1 and both applications are using isolation level RS, which of the following will occur?
A. Applications A and B will cause a deadlock situation.
B. Application B will read the previous version of the row.
C. Application B will read the row and see uncommitted changes made by application A.
D. Application B will be placed in a lock-wait state until application A releases its lock.

22.Which of the following resources can be referenced in the LOCK statement?
A. Row
B. Table
C. Column
D. Table space

23.If application A issues the following SQL statement, which of the following statements about concurrency is true?
SELECT deptno, deptname, mgrno FROM dept WHERE admrdept = 'A00' FOR READ ONLY WITH RS
A. Rows accessed by application A can be seen by other applications.
B. Rows accessed by application A cannot be seen by other applications.
C. Application A can see uncommitted changes made by other applications.
D. Results produced by re-execution of the statement by application A will not be affected by other applications.

24.Which of the following best describes the lock protection provided by DB2 for the current row of a cursor?
A. The cursor is only protected from updates and deletes by concurrent applications.
B. The row is only protected from positioned updates and deletes that reference another cursor of the same application.
C. The cursor is protected from positioned updates and deletes that reference another cursor of a different application.
D. The row is protected from updates and deletes by the current application and from positioned updates and deletes that reference another cursor of the same application.

25.Which of the following best describes the lock protection provided by DB2 for the current row of a cursor?
A. The cursor is only protected from updates and deletes by concurrent applications.
B. The row is only protected from positioned updates and deletes that reference another cursor of the same application.
C. The cursor is protected from positioned updates and deletes that reference another cursor of a different application.
D. The row is protected from updates and deletes by the current application and from positioned updates and deletes that reference another cursor of the same application

26.Which of the following is TRUE for the DB2 isolation level Cursor Stability (CS)?
A. An application process acquires at least a share lock on the current row of every cursor.
B. Any row that is read during a unit of work cannot be changed by other application processes until the unit of work is complete.
C. Any row changed by another application process can be read, even if the change has not been committed by that application process.
D. An application process that issues the same query more than once in a unit of work will not see additional rows caused by other application processes appending new information to the database.

27.Application A is designed to execute the following SQL statements within a single Unit of Work (UOW).
UPDATE employee SET salary = salary * 1.1 WHERE empno='000010'
UPDATE department SET deptname = 'NEW dept' WHERE deptno='A00'
Application B is designed to execute the following SQL statements within a single Unit of Work (UOW).
UPDATE department SET deptname = 'OLD DEPT' WHERE deptno='A00'
UPDATE employee SET salary = salary * 0.5 WHERE empno='000010'
Application A and application B execute their first SQL statement at the same time. When application A and application B try to execute their second SQL statement, a deadlock occurs. What will happen?
A. The database manager will rollback the transaction in both applications.
B. The database manager will rollback the transaction in one of the two applications.
C. Application B will successfully update the EMPLOYEE and DEPARTMENT tables; Application A will be placed in a lock wait state.
D. Application A will successfully update the EMPLOYEE and DEPARTMENT tables; Application B will terminate when the lock timeout value is reached.

28.Application A holds an Update lock on a single row and application B is trying to read that row. If both applications are using isolation level UR, which of the following will occur?
A. Application B will read the row.
B. Applications A and B will cause a deadlock situation.
C. Application B will wait until application A releases the Update lock.
D. Application A will be terminated so that application B can read the row.

29.To which of the following resources can a lock be applied?
A. Row
B. Alias
C. Bitmap
D. Column

Solutions ::::::::::::::::::::

1.The correct answer is D. The Repeatable Read isolation level will lock all rows scanned in response to a query. (The Read Stability isolation level will only lock the rows returned in the result data set; the Cursor Stability isolation level will only lock the row in the result data set that the cursor is currently pointing to; and the Uncommitted Read isolation level will not lock any rows during normal read processing.)

2.The correct answer is A. If Application B did not already have an Exclusive lock on table TAB2, Application B would be placed in a lock-wait state until Application A released its locks. However, because Application B holds an Exclusive lock on table TAB2, when Application A tries to acquire an Exclusive lock on table TAB2 and Application B tries to acquire an Exclusive lock on table TAB1, a deadlock will occur - processing by both transactions will be suspended until their second lock request is granted. Because neither lock request can be granted until one of the owning transactions releases the lock it currently holds (by performing a commit or rollback operation), and because neither transaction can perform a commit or rollback operation because they both have been suspended (and are waiting on locks), a deadlock has occurred.

3.The correct answer is C. When the Read Stability isolation level is used by a transaction that executes a query, locks are acquired on all rows returned to the result data set produced, and other transactions cannot modify or delete the locked rows; however, they can add new rows to the table that meet the query's search criteria. If that happens, and the query is run again, these new rows will appear in the new result data set produced.

4.The correct answer is A. When a deadlock cycle occurs, all transactions involved will wait indefinitely for a lock to be released unless some outside agent steps in and breaks the cycle. With DB2, this agent is a background process, known as the deadlock detector, and its sole responsibility is to locate and resolve any deadlocks found in the locking subsystem. Each database has its own deadlock detector, which is activated as part of the database initialization process. Once activated, the deadlock detector stays "asleep" most of the time but "wakes up" at preset intervals and examines the locking subsystem to determine whether a deadlock situation exists. If the deadlock detector discovers a deadlock cycle, it randomly selects one of the transactions involved to roll back and terminate; the transaction chosen (referred to as the victim process) is then sent an SQL error code, and every lock it had acquired is released. The remaining transaction(s) can then proceed, because the deadlock cycle has been broken.

5.The correct answer D. Typically, locks are not acquired during processing when the Uncommitted Read isolation level is used. Therefore, if Application B runs under this isolation level, it will be able to retrieve data from table TAB1 immediately - lock compatibility is not an issue that will cause Application B to wait for a lock.

6.The correct answer is D. Usually locks are not acquired during processing when the Uncommitted Read isolation level is used. However, rows that are retrieved by a transaction using the Uncommitted Read isolation level will be locked if another transaction attempts to drop or alter the table from which the rows were retrieved.

7.The correct answer is A. Any time one transaction holds a lock on a data resource and another transaction attempts to acquire a lock on the same resource, the DB2 Database Manager will examine each lock's state 
and determine whether they are compatible. If the state of a lock placed on a data resource by one transaction is such that another lock can be placed on the same resource by another transaction before the first lock acquired is released, the locks are said to be compatible and the second lock will be acquired. However, if the locks are not compatible, the transaction requesting the incompatible lock must wait until the transaction holding the first lock is terminated before it can acquire the lock it needs. If the requested lock is not acquired before the time interval specified in the locktimeout configuration parameter has elapsed, the waiting transaction receives an error message and is rolled back.

8.The correct answer is B. Locks can only be acquired for table spaces, tables, and rows.

9.The correct answer is A. If a row level lock is held by a application using the Cursor Stability isolation level, that lock remains in effect until either the cursor is moved to a new row (at which time the lock for the old row is released - if possible, and a new lock for the current row is acquired) or the transaction holding the lock is terminated.

10.The correct answer is C. The LOCK TABLE statement allows a transaction to explicitly acquire a table-level lock on a particular table in one of two modes: SHARE and EXCLUSIVE. If a table is locked using the SHARE mode, a table-level Share (S) lock is acquired on behalf of the transaction, and other concurrent transactions are allowed to read, but not change, the data stored in the locked table. If a table is locked using the EXCLUSIVE mode, a table-level Exclusive (X) lock is acquired, and other concurrent transactions can neither access nor modify data stored in the locked table.

11.The correct answer is C. If a transaction holding a lock on a resource needs to acquire a more restrictive lock on the same resource, the DB2 Database Manager will attempt to change the state of the existing lock to the more restrictive state. The action of changing the state of an existing lock to a more restrictive state is known as lock conversion. Lock conversion occurs because a transaction can hold only one lock on a specific data resource at any given time. In most cases, lock conversion is performed on row-level locks, and the conversion process is fairly straightforward. For example, if an Update (U) lock is held and an Exclusive (X) lock is needed, the Update (U) lock will be converted to an Exclusive (X) lock.

12.The correct answer is A. When the Repeatable Read isolation level is used, the effects of one transaction are completely isolated from the effects of other concurrent transactions; when this isolation level is used, every row that's referenced in any manner by the owning transaction is locked for the duration of that transaction. As a result, if the same SELECT SQL statement is issued multiple times within the same transaction, the result data sets produced are guaranteed to be the identical. Other transaction are prohibited from performing insert, update, or delete operations that would affect any row that has been accessed by the owning transaction as long as that transaction remains active.

13.The correct answer is D. When the Uncommitted Read isolation level is used, rows retrieved by a transaction are only locked if the transaction modifies data associated with one or more rows retrieved or if another transaction attempts to drop or alter the table the rows were retrieved from.) As the name implies, transactions running under the uncommitted read isolation level can see changes made to rows by other transactions before those changes have been committed. On the other hand, transactions running under the Repeatable Read, Read Stability, or Cursor Stability isolation level are prohibited from seeing uncommitted data. Therefore, applications running under the Uncommitted Read isolation level can read the row Application A updated while applications running under a different isolation level cannot. Because no locks are needed in order for Application A to read data stored in other tables, it can do so - even if a restrictive lock is held on that table. However, there is nothing that prohibits Application A from performing an insert operation from within the open transaction.

14.The correct answer is C. If the Repeatable Read isolation level is used, other agents will be unable to assign seats as long as the transaction that generated the list remains active; therefore, the list will not change when it is refreshed. If the Read Stability isolation level is used, other agents will be able to unassign currently assigned seats (and these unassigned seats will show up when the list is refreshed), but they will not be able to assign any seat that appears in the list as long as the transaction that generated the list remains active. If the Uncommitted Read isolation level is used, other agents will be able to unassign currently assigned seats, as well as assign unassigned seats; however, uncommitted seat unassignments/assignments will show up when the list is refreshed, and the agent may make an inappropriate change based on this data. Therefore, the best isolation level to use for this particular application is the Cursor Stability isolation level.

15.Answer: C

16.Answer: C

17.Answer: B

18.Answer: B

19.Answer: B

20.Answer: A

21.Answer: D

22.Answer: B

23.Answer: A

24.Answer: A

25.Answer: A

26.Answer: A

27.Answer: B

28.Answer: A

29.Answer: A


Test Your C Skills.

CHAPTER 1: DECLARATIONS AND INITIALIZATION

Q1> WHAT IS THE O/P?
  main()
  {  
   char far *s1,*s2;
   printf(""%d%d",sizeof(s1),sizeof(s2));
  }
answer>4 2


Q.2>What will be the o/p?
int x=40;
main()
{
int x=20;
printf("%d",x);
}
answer>20

Q.3>What will be the o/p?
main()
{
 int x=40;
  {
  int x=20;
  printf("%d",x);
   }
 printf("%d",x);
}
answer>20 40

Q.4>Is the following statement declaration or defination?
  extern int x;
answer> declaration

Q.5> What is the o/p?
 main()
  {
  extern int i;
  i=20;
  printf("%d",sizeof(i));
 }
answer> error,i undefined because extern int i is a declaration and not defination

Q.6>Is it true that the global variable have many declarations but only one defination?
answer> yes

Q.7>Is it true that the function may have many decalaratins but only one defination?
answer> yes


Q.8>In the following program where the variable a is geting defined and where it is declared?
   main()
  {
   extern int a;  /* declaration*/
     printf("%d",a0;
  }
int a=12;   /* defination*/


Q.9>What will be the o/p of above program?
answer>20



Q.10>What is the difference between declaration and defination of a variable?
answer> declaration:-only gives the type,status and nature of variable without reserving any space for the variable  defination;-actual space is reserverd for the variable and some initial value is given.


Q.11>if the defination of the external variable occurs in the source file before it's use in a perticular function then there is no need for an external declaration in the function?
answer> true

Q.12>suppose the program is devided in three source files f1,f2,f3 and the variable is defined in   file f1 but used in f2 and f3. In such a casewould we need the external declaration for the variable in files f2 and f3?
answer>yes

Q.13>when we mention the prototype of the function ,we are definig it or declaring it?
answer> declaring it


Q.14>what is the difference between following declarations
  extern int fun()
  int fun();
answer> nothing except that that the firat one gives us hint that function fun is probally in another  file.



Q.15>why  does the following programreports the redeclaration error of function display()
   main()
   {
      dispaly();
   }

 void dispaly()
 {
  printf("fggagaetaertrt");
 }
answer> here the function dispay() is called before it is declared .That is why the complier assumes it to be declared as  int display();  that accept unspecified no of arguments.i.e. undeclared function assumes to return int  on appering the declaration the fun shows that it returns void  hence the error.


Q.16> What will be the o/p?
  main()
 {
  extern int fun(float);
  int a;
  a=fun(3.14);
  printf("%d",a);
 }

 int fun(aa)        /* K & R style of function defenation*/
 float aa
 {
 return((int)aa);
}
answer> error, because we have mixed the ansi prototype with k & r style of function defenation If we use an ANSI prototype and pass float to the function then it is promoted to double  the funcction accepts it in to variable of type float hence the type mismatch occurs  To remady the situation define the function as
    int fun(float aa)
     {
       .....
     }


Q.17>Point error if any:
  struct emp
  {
    char name[20];
     int age;
  }

fun(int aa)
 {
  int bb;
  bb=aa*aa;
  return(bb);
 }

main()
{
 int a;
a=fun(20);
printf("%d",a);
}
answer> missing semicollon at the end of struct  due to which the function fun assumed to be returning vsr of type struct emp.  but it returns an int hence the error.

 Q.18> If you are to share the variables or functions across several source files how would you enshore that all definications  and declarations are consistant?
answer> The best arrangement is to place each defination in a revelent .c file , then put an external declaration in a header   file (.h file) and use #includeto briang the declaration wherever needed. The .c file which contains the definations should also include the header file, so that the complier can check that  the defination matches the declaration.


Q.19> Correct the error:
   f(struct emp0;
     struct emp
       {
         char name[20];
         int age;
       };
    main()
     {
       struct empe={"Vivek",21}
        f(e);
     }

   f(struct emp ee)
      {
        printf("\n %s %d",ee.name,ee.age);
      }  
answer> declare the structure before the prototype of f.


Q.20> Global variables are available to all functions. Does there exist a mechanism by way of which I can make it available  to some and not to others.
answer>NO.


Q.21>What do you mean by a translation unit?
answer> A trnslation unit is a set of source files as seen by the complier and translated as a unit. Generally one .c file plus all header files mentioned in the #include directives.


Q.22>What wouldbe the output of the following program
  main()
  {
    int a[5]={2,3}
     printf("\n %d %d %d",a[2],a[3],a[4]);
  }
answer> 0 0 0     if a automatic array is partially initialised then remaiing elements are initialised by 0


Q.23>What will be the output :
main()
 {
  struct emp
   {
     char name[20];
     int age;
     float sal;
   };

  struct emp e={"vivek"}
  printf("\n %d %f",e.age, e.sal);
 }
answer>0 0.000000  if an automatic structure is partially initialised then remaining elements are initialised bu 0.


Q.24>Some books sugget that the fillowing definations should be preceded by the word static. Is it correct?
  int a[]={2,3,4,12,32}
  struct emp e={"vinod",23}
answer> pre ANSI compilers has such requirment but compliers confirming to ANSI standard does not have such requirment.


Q.25>Point out error
 main()
 {
  int(*p)()=fun;
  (*p)();
 }

 fun()
  {
    printf("\n Loud and clear");
  }
answer> Here we are initialising function pointer to address of the function fun() but during the time of initialisation the   function has not been defined. Hence an error To eliminate the error add the prototype of function fun() before the declaration of p, as shown bellow;
    extern int fun();      or simply     int fun();



Q.26> point error if any
  main()
  {
    union a
     {
       int i;
       char ch[2];
     };
    union a z=512;
    printf("%d %d",z.ch[0],z.ch[1]);
  }
answer> In pre-ANSI complier union vriable can not be initialised . ANSI complier permits initialisation of first member of the  union.



Q.27> What do you mean by the scope of the variable? what are the 4 differet types of scopes that a variables can have?
answer> Scope indicates the region over which the variable's declaration has an effect. The four kinds of scopes are: file  function,block,prototype.


Q.28> What are different types of linkages?
answer> There are three different types of linkages : external , internal , and none. External linkage means global, non-static  variables and functions, internal linkage means static variables and functions with file scope and no linkage means  local variables.

SOME MCQ FOR U for Practice.......


#######################################################################
                         2.QUESTIONS
#######################################################################

1. Base class has some virtual method and derived class has a method with the same name. If we initialize the base class pointer with derived object; calling of that virtual method will result in which method being called?
a. Base method b. Derived method.
c. Error d. None of these 


2. Given below are two sets of statements:(a) & (b). Select the correct observation: 

a> const char *p="Hello"; p="World";
b> char * const p="Hello"; p[1]='P';

A. Both a & b are correct since non-const data/pointer is being changed in both cases. 
B. Both a & b are wrong since const data/pointer cannot be changed once assigned.
C. a is correct, b is wrong. 
D. a is wrong, b is correct.


3. void main ()
{
"Bunka"[2]='P';
}

Select the correct statement:
A. Error: lvalue required
B. Error: A string literal is a const char * and hence cannot be modified directly.
C. A string literal has the data type char * and hence cannot be modified.
D. The code compiles but memory access error at run-time.


4. Select all the correct statements about "Abstraction"
A. Assumes essential characteristics of an object to distinguish it from other kinds of objects. 
B. Provides a simplified view of the object.
C. It separates the implementation from its interface.
D. It is the enforcement of the type class of an object.

5. The behavior of a class is decided by
A. Data members. B. Methods. C. Access permissions. D. All of the above.

6. Which statement(s) is/are true about "Static Typing"?
A. Refers to Types declared at compile time.
B. More efficient and reliable than dynamic typing.
C. Can be used to implement polymorphism.
D. Refers to all static data/methods in your classes.

7. Which statements(s) is/are true about Dynamic binding?
A. The correct function to call is resolved at run-time.
B. These functions are statically typed.
C. These functions are dynamically typed.
D. Refers to all dynamically allocated data in your classes. 

8. Reusability of objects is achieved by
A. Inheritance. B. Aggregation. C. Polymorphism. D. All of the above.

9. Which statements(s) is/are true about "Hierarchy" of objects?
A. It is an ordering of abstractions. 
B. It refers to "is a " relationship expressed by inheritance.
C. It refers to "has a" relationship expressed by aggregation.
D. It refers to access permissions on the aggregated object within an object.

10. What are "Generic classes"? (Select all that are correct)
A. A universal base class to cater to a wide range of derived classes.
B. A parameterized class, which is reusable across, types.
C. Used where implementation and behavior is independent of type.
D. Also known as abstract classes. 

11. A language is "Object Base" if (Select all that are correct)
A. It supports abstraction. B. It has a concept of class.
C. It provides direct support for inheritance. D. All of the above.

12. "Object Persistence" covers which of the following (Select all that are correct)
A. Global variables & heap items. B. Object data storage.
C. Object type storage. D. All of the above.

13. Which statement(s) is/are true about shared inheritance? 
A. All base classes are by default example of shared inheritance.
B. In multiple inheritances the derived classes share a single instance of the Base Class.
C. The base class is declared dynamically & there can be only one instance of it.
D. It allows distributed objects to share remote object and treat it as their own.


14. void f (int y)
{
struct s *ptr;
ptr = malloc (size of (struct)+99*size of (int));
}
struct s
{
int i;
float p;
};
when free (ptr) is executed, what will happen?

15. . Using pointer, changing A to B and B to A is swapping the function using two addresses and one temporary variable. a, b are address, t is temporary variable. How function look like?

16. Write a c program to find whether a stack is progressing in forward or reverse direction.

17. What is the output of the following program?
void main ()
{
char *ptr1="DCM0DAT\0ASYSTEMS";
clrscr ();
printf ("%d %s ", strlen (ptr1),ptr1);
printf ("%d %s ",strlen (ptr1+8),ptr1+8);
getch ();
}

18. How do you declare an array of N pointers to functions returning pointers to functions returning pointers to characters? 

19. void main ()
{
char *s []={“dharma", "hewlett-packard", "siemens", "ibm"};
char **p;
p=s;
printf ("%s", ++*p);
printf ("%s", *p++);
printf ("%s", ++*p);
}

20. Which holds true for the following statement
class c: public A, public B
a) 2 member in class A, B should not have same name
b) 2 member in class A, C should not have same name
c) both 
d) none 

21. Given the following c program
func (int *i, int*j)
{*i=*i * *i;
*j=*j* *j;
}
main ()
{ int i = 5, j = 2;
func (&i, &j);
printf ("%d %d", i, j);
}
What is the output?

22. For the following C program
void insert (key, r)
type key key, data array r;
{extern int n;
if (n>=max) /*error table if full */
else r [n++]. k=key;
}
This on executing, enables a
a) Basic sequential search b) Binary search c) Interpolation search d) None

23. f (char *p)
{
p [0]? f (++p): 1;
printf ("%c", *p);
}
if call that function with f (Aabcd) what is the output??

24 In a class only declaration of the function is there but definition is not there then what is that function ?

25 What is the use of global static variable in C?

#######################################################################
                              2. ANSWERS
#######################################################################

1 (b)
15 swap (int *, int *, int)
18 The first part of this question can be answered in at least three ways:

a). char *(*(*a [N]) ())();

b) Build the declaration up incrementally, using typedefs:
typedef char *pc; /* pointer to char */
typedef pc fpc (); /* function returning pointer to char */
typedef fpc *pfpc; /* pointer to above */
typedef pfpc fpfpc (); /* function returning... */
typedef fpfpc *pfpfpc; /* pointer to... */
pfpfpc a [N]; /* array of... */

c) Use the cdecl program, which turns English into C and vice versa:
cdecl> declare a as array of pointer to function returning pointer to function returning pointer to char 
char *(*(*a []) ())()
cdecl can also explain complicated declarations, help with casts, and indicate which set of parentheses the arguments go in (for complicated function definitions, like the one above). 
Any good book on C should explain how to read these complicated C declarations "inside out" to understand them ("declaration mimics use").
The pointer-to-function declarations in the examples above have not included parameter type information. When the parameters have complicated types, declarations can *really* get messy. (Modern versions of cdecl can help here, too.)

19. "harma" (p->add (dharma) && (*p)->harma)
"harma" (after printing, p->add (hewlett-packard) &&(*p)->harma)
"ewlett-packard" 
20. (a)
23. dcbaA (Just reversing the string)
24. virtual function

Popular Posts