Get Off-Campus Placement Jobs Info !!!
Programs asked in Mettl Coding Round
Click To Practce List of Programs asked in Nagarro !!!

Technical Interview Questions and Answers :: TCS

276.5K

Tot. Mock Test: 40


Total Qs: 157+

  •  Select All
  •  SQL
  •  Java
  •  C++
  •  WebMethod
  •  Informatica
  •  C
  •  DBMS
  •  Operating System
  •  Soft. Engineering
  •  Data Structure
  •  Networking
  •  Hadoop
  •  HR Question in TR
    Answer:

    Object is a software bundle of variables and related methods. Objects have state and behavior.

    Please Login First :

    32 / 157

    What is the use of constructor?
    Answer:

    Constructor is used to initialise class variable when object of class is created

    Please Login First :

    33 / 157

    What is the difference between class and structure?
    Answer:

    Structure: Initially (in C) a structure was used to bundle different type of data types together to perform a particular functionality. But C++ extended the structure to contain functions also. The major difference is that all declarations inside a structure are by default public.

    Class: Class is a successor of Structure. By default all the members inside the class are private.

    Please Login First :

    34 / 157

    What is virtual class and friend class?
    Answer:

    Friend classes are used when two or more classes are designed to work together and need access to each others implementation in ways that the rest of the world shouldn’t be allowed to have. In other words, they help keep private things private. For instance, it may be desirable for class Database Cursor to have more privilege to the internals of class Database than main () has.

    Please Login First :

    35 / 157

    What is a container class?
    Answer:

    Container class is a class that hold group of same or mixed objects in memory. It can be heterogeneous and homogeneous. Heterogeneous container class can hold mixed objects in memory whereas when it is holding same objects, it is called as homogeneous container class.

    Please Login First :

    36 / 157

    How can we access private members of a classs?
    Answer:

    By using a friend function.
    A friend function has access to all private and protected members of the class for which it is a friend.

    Please Login First :

    37 / 157

    Can we create an empty class? If so what would be the sizeof such object.
    Answer:

    Yes, Size of an empty class is not zero. It is 1 byte generally. It is nonzero to ensure that the two different objects will have different addresses.

    Please Login First :

    38 / 157

    Explain about Friend function and friend class.
    Answer:

    Friend Function:
    A friend function can access a class private data, even though it is not a member function of the class. This is useful when one function must have access to two or more unrelated classes and when an overloaded operator must use, on its left side, a value of a class other than one of which it is a member. Friends are also used to facilitate functional notation.

    Friend Class:
    It is possible to grant a non-member function access to the private members of a class by using a friend. A friend function has access to all private and protected members of the class for which it is a friend.

    Please Login First :

    39 / 157

    Why the size of empty Class is one byte? OR What will the sizeof empty Class ?
    Answer:

    No Discussion on this question yet!

    Please Login First :

    40 / 157

    What Is Inheritance? What is the diamond problem that can occur with multiple inheritance? Explain an example.
    Answer:

    Inheritence is deriving parent(base) class properties to derived class.


    The Diamond Problem :


        A


       /  \


      B   C


       \   /


        D


    Now Class B

    Please Login First :


Most Frequent Qs.