3i Infotech Placement: Sample Questions 263 - 264 of 1245

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 263

Edit

Describe in Detail

Essay▾

What is reflexive association?

Explanation

  • The ‘is-a’ relation is called a reflexive association. It permits classes to have “is-a” association not only with their super-classes but also with themselves.
  • Differs from a ‘specializes-from’ usually used in inheritance from super-class to a sub-class.
  • For example: printer is-a printer.
  • Reflexive association is from a class to itself. There are two main types:
    • Asymmetric Reflexive Associations occurs when ends of the association are semantically different, even though associated class is the same.
    • Symmetric Reflexive Association occur ends of the association are not semantically different.
Given the the Reflexive Associations from a Class to Itself

Question 264

Edit

Describe in Detail

Essay▾

What is the output for the following program

  1. main ()
  2. {
  3.     intarr2D[3][3];
  4.     printf( “%d”, ( (arr2D == ⚹arr2D) && ( ⚹arr2D == arr2D[0]) ) );
  5. }

Explanation

  • Shows close relation between the arrays and pointers.
  • N dimensional arrays are made up of (N-1) N dimensional arrays.
Table Shows the Program
int arr2D [3] [3] ;
  • arr2D is made up of a 3 single arrays that contains 3 integers each.
  • The name arr2D refers to the beginning of all the 3 arrays.
printf ( “% d” , ( (arr2D == ⚹ arr2D) && (⚹ arr2D == arr2D [0] ) ) ) ;
  • arr2D refers to the start of the first 1D array (of 3 integers) that is the same address as arr2D.
  • So, the expression (arr2D == ⚹ arr2D) is true.
  • Similarly, ⚹ arr2D is nothing but ⚹ (arr2D + 0) , adding a zero doesn՚t change the value/meaning.
  • Again arr2D [0] is another way of telling ⚹ (arr2D + 0) .
  • So the expression (⚹) arr2D + 0) == arr2D [0] ) is true.
  • Since, both parts of the expression evaluates to true the result is true (1) and the same is printed.

Developed by: