3i Infotech Papers: Sample Questions 529 - 531 of 1245

Examrace Placement Series prepares you for the toughest placement exams to top companies.

Question number: 529

» Operating System » Unix

Short Answer Question▾

Write in Short

Predict the output of the following program code:

  1. main ()
  2. {
  3.     fork ();
  4.     printf (“Hello World!”);
  5. }

Explanation

  • Hello World! Hello World:

  • The fork creates a child that is a duplicate of the parent process.

  • The child begins from the fork ().

  • All the statements after fork () are executed twice (once by the parent and second time by child).

  • The statement before fork () is executed only by the parent process.

Question number: 530

» Languages » C & C Plus Plus

Short Answer Question▾

Write in Short

What is slicing?

Explanation

  • Slicing means that the data added by a subclass are discarded when an object of the subclass is passed or returned by value or from a function expecting a base class object. Explanation: Consider the following class declaration: class base {… base& operator = (const base&); base (const base&); } void fun () {base e = m; e = m; }

  • Base copy functions are not aware about the derived members, thus only the base part of the derived is copied. This is called slicing.

  • One reason to pass objects of classes in a hierarchy is to avoid slicing, other reason can be preserving polymorphic behavior and gaining efficiency.

Question number: 531

» Languages » C & C Plus Plus

Essay Question▾

Describe in Detail

What is an orthogonal base class?

Explanation

  • If two base classes have no overlapping methods or data, they are said to be independent of, or orthogonal to each other.

  • Orthogonal means that two classes operate in different dimensions and do not interfere with each other in any way.

  • The same derived class may inherit such classes with no difficulty.

Orthogonal base class

Orthogonal Base Class

Given the image is orthogonal bases example