Languages-C & C Plus Plus [3i Infotech Placement]: Sample Questions 8 - 9 of 354

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

Question 8

C & C Plus Plus
Edit

Write in Short

Short Answer▾

What are proxy objects?

Explanation

  • Objects that points to other objects are called proxy objects or surrogates.
  • Proxy object provide the same interface as the server object but provide no functionality.
  • A method invocation to proxy object routes data to the true server object and sends back the return value to the object.
  • Proxy objects have significantly reduced capabilities compared to their corresponding custom objects. For example, operations such as erasing and moving an object, or changing object properties, may or may not be possible on a proxy object, depending on the application that created it.

Question 9

C & C Plus Plus
Edit

Describe in Detail

Essay▾
  1. voidmain ()
  2. {
  3.     char ⚹s[] ={ "dharma", "hewlett-packard" ,"siemens" ,"ibm" };
  4.     char ⚹⚹p;
  5.     p =s;
  6.     printf("%s ",++⚹p);
  7.     printf("%s ",⚹p++);
  8.     printf("%s ",++⚹p);
  9. }

Explanation

  • The program uses pointer to pointer
  • The first pointer is using to store the address of second pointer. That is why they are known as double pointers.
Concept of Double Pointer
Table Showing the Program
char ⚹ s [] = { “dharma” , “hewlett-packard” , “siemens” , “ibm” } ;
  • Define the pointer array
char ⚹⚹ p;
  • Define the character pointer to pointer p
p = s;
  • Pointer stores the array value
printf ( “% s” , ++ ⚹ p) ;
  • Here printf print the incremented pointer value
  • Here apply (++ ⚹ p) - p thus points to harma from dharma
printf ( “% s” , ⚹ p ++) ;
  • Here printf prints the pointer value
  • Here apply (⚹ p ++) . The increment moves to next char array so p now points to hewlett-packard
printf ( “% s” , ++ ⚹ p) ;
  • Again ++ ⚹ p makes “p” point to ewlett-packard

Developed by: