TCS Papers: Sample Questions 476 - 477 of 502

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

Question number: 476

» Basic CS » Networks

Essay Question▾

Describe in Detail

What is framing?

Explanation

  • Framing in data link layer separates a message from one source to a destination, or from other messages to other destinations, by adding a sender address and a destination address.

  • The destination address defines where the packet has to go and the sender address helps recipient acknowledge the receipt.

  • The efficiency of any error detection scheme decreases as the length of the data increases. Thus, small frames increase the reliability.

  • Types: -

    • Fixed Size Framing: Here boundaries to the frame are not provided as length of the frame is known.

    • Variable Size Framing: Requires end of frame marker. For this character oriented and bit oriented approach is used.

      • Character oriented

        ASCII characters are sent- byte stuffing is required

      • Bit oriented

        Bits are sent in this- bit stuffing is required

 Image shows the Frame

Image Shows the Frame

Given the image is define the framing

Question number: 477

» Languages » C & C Plus Plus

MCQ▾

Question

Can a class have virtual destructor?

Choices

Choice (4) Response

a.

No

b.

Yes

c.

None of the above

d.

All of the above

Answer

b.

Explanation

  • Any class that is inherited publicly, polymorphic or not, should have a virtual destructor.

  • To put another way, if a class can be pointed to by a base class pointer, its base class should have a virtual destructor.

  • If virtual, first the derived class destructor gets called, then the base class constructor

  • Deleting a derived class object using a pointer to a base class that has a non-virtual destructor results in undefined behavior.

  • To correct this situation, the base class should be defined with a virtual destructor

  • For example

  1. #include<iostream>
  2. using namespace std;
  3. class Base
  4. {
  5.     public:
  6.     Base()
  7.     {
  8.         cout<<"Constructing base  ";
  9.     }
  10.     ~Base()
  11.     {
  12.         cout<<"Destructing base  ";
  13.     }
  14. };
  15. class Derivedpublic Base
  16. {
  17.     public:
  18.     Derived()
  19.     {
  20.         cout<<"Constructing derived  ";
  21.     }
  22.     ~Derived()
  23.     {
  24.         cout<<"Destructing derived  ";
  25.     }
  26. };
  27. int main(void)
  28. {
  29.     Derived *d = new Derived();
  30.     Base *b = d;
  31.     delete b;
  32.     getchar();
  33.     return 0;
  34. }
  • Output:

Constructing base

Constructing derived

Constructing base