3i Infotech Placement: Sample Questions 543 - 544 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 543

Edit

Describe in Detail

Essay▾

What is a Null object?

Explanation

  • 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.
  • In object-oriented computer programming, a Null Object is an object with no referenced value or with defined neutral behavior.
  • The Null Object design pattern describes the uses of such objects and their behavior (or lack thereof) .
Define the Null Object Synopsis, Context and Forces

Question 544

Edit

Describe in Detail

Essay▾

What is the output of the following program?

  1. voidmain()
  2. {
  3.     int ⚹mptr,⚹cptr;
  4.     mptr=(int⚹)malloc(sizeof(int));
  5.     printf(“%d ”,⚹mptr );
  6.     cptr=(int⚹)calloc(sizeof(int),1);
  7.     printf(“%d”,⚹cptr);
  8. }

Explanation

In the program

Table Shows the Program
int ⚹ mptr, ⚹ cptr;
  • Given the integer pointer mptr and cptr.
mptr = (int ⚹) malloc (sizeof (int) ) ;

printf ( “% d” , ⚹ mptr) ;

  • The memory space allocated by malloc is uninitialized.
  • So it will print garbage value.
cptr = (int ⚹) calloc (sizeof (int) , 1) ;

printf ( “% d” , ⚹ cptr) ;

  • Calloc initializes the allocated memory space to zero.
Define the Calloc and Malloc Function

Developed by: