TCS Papers: Sample Questions 316 - 317 of 502

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

Question number: 316

» Languages » C & C Plus Plus

MCQ▾

Question

Which constructor function is designed to copy objects of the same class type?

Choices

Choice (4) Response

a.

Copy constructor

b.

Create constructor

c.

Object constructor

d.

Dynamic constructor

Answer

a.

Explanation

  • Copy constructor copies objects of the same class type

  • A copy constructor is a member function which initializes an object using another object of the same class.

  • Copy constructor is called when a new object is created from an existing object, as a copy of the existing object.

  • Assignment operator is called when an already initialized object is assigned a new value from another existing object.

  • Copy constructor has the following general prototype:

    ClassName (const ClassName &old_obj);

  • Example of copy constructor

  1. #include<iostream>
  2. using namespace std;
  3. class Point
  4. {
  5.     private:
  6.     int xy;
  7.     public:
  8.     Point(int x1int y1) { x = x1y = y1; }
  9.     // Copy constructor
  10.     Point(const Point &p2) {x = p2.xy = p2.y; }
  11.     int getX() { return x; }
  12.     int getY() { return y; }
  13. };
  14. int main()
  15. {
  16.     Point p1(2078); // Normal constructor
  17.     Point p2 = p1// Copy constructor
  18.     cout << "p1.x = " << p1.getX() << ", p1.y = " << p1.getY();
  19.     cout << " p2.x = " << p2.getX() << ", p2.y = " << p2.getY();
  20.     return 0;
  21. }
  • Output:

p1. x = 20, p1. y = 15

p1. x = 20, p1. y = 15

Question number: 317

» Basic CS » Networks

Essay Question▾

Describe in Detail

What are the criteria necessary for an effective and efficient network?

Explanation

A network must meet a certain criteria to become useable. Most important three criteria are as follows:

Performance:

  • Measured in many ways, including transmit time and response time.

  • Performance is a measurement of various factors such as the amount of time for messages to travel from one device to another, the time it requires to get a response starting from an inquiry.

  • Performance of a network depends on a number of factors such as number of active users, type of the transmission medium, capabilities of the connected hardware, and efficiency of the software.

Reliability:

  • Network reliability is measured by the frequency of failure, time it takes to recover from failure, the network’s robustness.

Security:

  • Security includes protecting data from unauthorized access and malicious programs like viruses.

  • Network must be secured- data sent should reach destination without any third-party reading, altering or destroying the data.

  • Network must also have secured procedures to recover from data losses and breaches.