Languages [3i Infotech Placement]: Sample Questions 56 - 57 of 546

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

Question 56

Edit

Write in Short

Short Answer▾

Differentiate between the message and method.

Explanation

Differentiate between the Message and Method
MessageMethod
Objects communicate by sending messages to each other.Provides response to a message.
A message is sent to invoke a method.It is an implementation of an operation.
Message refers to instruction sent to object which will invoke the related method.Method is a function or procedure that is defined for a class and typically can access the internal state of an object of that class to perform some operation.
A message is any packet of communication between objects. The objects may be in the same program, or they may be on different systems. It simply doesn՚t matter.A method is a block of code attached to an object by some means. It may be implicitly attached by means of a class, or it may be an anonymous closure attached to an arbitrary attribute of the object.

Question 57

Edit

Write in Short

Short Answer▾
  1. main ()
  2. {
  3.     inti =5;
  4.     printf ( “%d%d%d%d%d%d” i ++, i--, ++ i, -i, i);
  5. }

Explanation

  • The evaluation is by popping out from the stack.
Table Shows the Program
int i = 5;Here define the integer variable i = 5
printf ( “% d % d % d % d % d % d” i ++ , i-, ++ i, -i, i) ;Print the all values of i

The arguments in a function call are pushed into the stack from left to right.

First value in stack top to bottom is ii = 5
Second value in stack is -i-i = 4
Third value in stack is ++ i++ i = 5
Fourth value in stack is i-i-= 5
Fifth value in stack is i ++i ++ = 4
  • And the evaluation is from right to left
  • So the answer is 45545.

Developed by: