Classes Objects interview questions

44 questions. Tap “Show answer” to check yourself.

Advertisement
  1. _____ of a class are data variables that represent the features or properties of a class.

    1. Access specifiers
    2. Visibility labels
    3. Member functions
    4. Data members
    Show answer

    D. Data members

  2. Declaration and function definitions are two specifications of which of the following

    1. Comments
    2. Class
    3. Data type
    4. None of the given
    Show answer

    B. Class

  3. The members that can also be accessed from outside the class should be declared as

    1. Protected
    2. Private
    3. Public
    4. None of these
    Show answer

    C. Public

  4. Members of a class are classified as

    1. Data functions and member functions
    2. Data hiding and data abstraction
    3. Data variables and data hiding
    4. Data members and member function
    Show answer

    D. Data members and member function

  5. void sum:: input ()<br>The above line tells

    1. function input is sub function of sum
    2. function sum is sub function of input
    3. function input is declared within the class sum
    4. function sum is declared within the class input
    Show answer

    C. function input is declared within the class sum

  6. Bjarne Stroustrup initially named C++ as

    1. C with classes
    2. Advanced C
    3. Deep C
    4. D
    Show answer

    A. C with classes

  7. Which of the following statements in NOT true?

    1. A non member function cannot access the private data of a class
    2. The return type of a member function cannot be object data type
    3. Several different classes can use the same function name
    4. Member functions can be of static type
    Show answer

    D. Member functions can be of static type

  8. int ex:: output ()<br> Which of the following is true with reference to the above line?

    1. The function output returns integer data type
    2. The function output returns ex type of data
    3. The class output returns integer type of data
    4. The function ex returns integer type of data
    Show answer

    A. The function output returns integer data type

  9. The body of the class starts and ends with

    1. Braces i.e.., {}
    2. Semi colon(;)
    3. Start and stop
    4. Begin and end
    Show answer

    A. Braces i.e.., {}

  10. Data abstraction in C++ is achieved by

    1. Encapsulation()
    2. Data Hiding()
    3. Polymorphism()
    4. Inheritance()
    Show answer

    B. Data Hiding()

  11. Data hiding refers to _____

    1. not giving names to data
    2. not specifying members and functions of a class
    3. declaring members as public
    4. members and functions of a class are not accessible by members of outside class
    Show answer

    D. members and functions of a class are not accessible by members of outside class

  12. The class members declared _____ can be accessed only within the class and the members of the inherited classes.

    1. protected
    2. unprotected
    3. public
    4. private
    Show answer

    A. protected

  13. Advertisement
  14. Declaration of class member are declared as private can be accessed only

    1. separately in another class
    2. inside or outside the class
    3. outside the class
    4. within class
    Show answer

    D. within class

  15. The private data of a class can be accessed

    1. only by member functions of its own class and friend functions
    2. only by member functions of its own class
    3. only by friend functions
    4. by any function
    Show answer

    A. only by member functions of its own class and friend functions

  16. The member functions declared under which scope can be accessed by the objects.

    1. protected
    2. global
    3. private
    4. public
    Show answer

    C. private

  17. The members of a class are accessed using ___

    1. New operator
    2. Dot operator
    3. + operator
    4. Size of operator
    Show answer

    B. Dot operator

  18. The body of a class is terminated by a _____

    1. .
    2. ;
    3. :
    4. #
    Show answer

    B. ;

  19. By default class members are treated as ____

    1. Public
    2. Private
    3. Protected
    4. Unprotected
    Show answer

    D. Unprotected

  20. The binding of data and functions together into a single entity is known as ____

    1. Inheritance
    2. Encapsulation
    3. Overloading
    4. Polymorphism
    Show answer

    B. Encapsulation

  21. Which of the following is a way to bind the data and its associated functions together?

    1. Methods
    2. Class
    3. Data
    4. Functions
    Show answer

    B. Class

  22. Private access specifier is accessible by special function called ____

    1. Void
    2. Inline
    3. Friend
    4. All of these
    Show answer

    C. Friend

  23. _____  member variable are initialized only once when the first object of its class is created.

    1. Inline
    2. Static
    3. Private
    4. Public
    Show answer

    B. Static

  24. One copy of ___ data members of a class are shared by all objects of that class.

    1. Public
    2. Static
    3. Private
    4. Inline
    Show answer

    B. Static

  25. The members defined within the class behave like ____functions.

    1. Inline
    2. Public
    3. Friend
    4. None of these
    Show answer

    A. Inline

  26. Advertisement
  27. :: is a ___

    1. Short circuit AND
    2. Short circuit OR
    3. Not operator
    4. Scope resolution operator
    Show answer

    D. Scope resolution operator

  28. A class belongs to which of the following data types?

    1. Array Type
    2. Derived Type
    3. Built-in Type
    4. User Defined Type
    Show answer

    D. User Defined Type

  29. Every class declaration is terminated by ____

    1. ,(comma)
    2. .(dot)
    3. ; (semi colon)
    4. :: (double colon)
    Show answer

    C. ; (semi colon)

  30. A member function calling another function directly is called as ____

    1. Nesting functions
    2. Recursive functions
    3. Inline functions
    4. Friend functions
    Show answer

    A. Nesting functions

  31. Class access specifiers are also known as ____

    1. Specifications
    2. Class depth
    3. Visibility labels
    4. None of these
    Show answer

    C. Visibility labels

  32. ____ are the functions that perform specific task in a class.

    1. Data functions
    2. Concrete functions
    3. Member functions
    4. Data members
    Show answer

    C. Member functions

Advertisement