Classes Objects interview questions
44 questions. Tap “Show answer” to check yourself.
-
_____ of a class are data variables that represent the features or properties of a class.
- Access specifiers
- Visibility labels
- Member functions
- Data members
Show answer
D. Data members
-
Declaration and function definitions are two specifications of which of the following
- Comments
- Class
- Data type
- None of the given
Show answer
B. Class
-
The members that can also be accessed from outside the class should be declared as
- Protected
- Private
- Public
- None of these
Show answer
C. Public
-
Members of a class are classified as
- Data functions and member functions
- Data hiding and data abstraction
- Data variables and data hiding
- Data members and member function
Show answer
D. Data members and member function
-
void sum:: input ()<br>The above line tells
- function input is sub function of sum
- function sum is sub function of input
- function input is declared within the class sum
- function sum is declared within the class input
Show answer
C. function input is declared within the class sum
-
Bjarne Stroustrup initially named C++ as
- C with classes
- Advanced C
- Deep C
- D
Show answer
A. C with classes
-
Which of the following statements in NOT true?
- A non member function cannot access the private data of a class
- The return type of a member function cannot be object data type
- Several different classes can use the same function name
- Member functions can be of static type
Show answer
D. Member functions can be of static type
-
int ex:: output ()<br> Which of the following is true with reference to the above line?
- The function output returns integer data type
- The function output returns ex type of data
- The class output returns integer type of data
- The function ex returns integer type of data
Show answer
A. The function output returns integer data type
-
The body of the class starts and ends with
- Braces i.e.., {}
- Semi colon(;)
- Start and stop
- Begin and end
Show answer
A. Braces i.e.., {}
-
Data abstraction in C++ is achieved by
- Encapsulation()
- Data Hiding()
- Polymorphism()
- Inheritance()
Show answer
B. Data Hiding()
-
Data hiding refers to _____
- not giving names to data
- not specifying members and functions of a class
- declaring members as public
- 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
-
The class members declared _____ can be accessed only within the class and the members of the inherited classes.
- protected
- unprotected
- public
- private
Show answer
A. protected
- Advertisement
-
Declaration of class member are declared as private can be accessed only
- separately in another class
- inside or outside the class
- outside the class
- within class
Show answer
D. within class
-
The private data of a class can be accessed
- only by member functions of its own class and friend functions
- only by member functions of its own class
- only by friend functions
- by any function
Show answer
A. only by member functions of its own class and friend functions
-
The member functions declared under which scope can be accessed by the objects.
- protected
- global
- private
- public
Show answer
C. private
-
The members of a class are accessed using ___
- New operator
- Dot operator
- + operator
- Size of operator
Show answer
B. Dot operator
-
The body of a class is terminated by a _____
- .
- ;
- :
- #
Show answer
B. ;
-
By default class members are treated as ____
- Public
- Private
- Protected
- Unprotected
Show answer
D. Unprotected
-
The binding of data and functions together into a single entity is known as ____
- Inheritance
- Encapsulation
- Overloading
- Polymorphism
Show answer
B. Encapsulation
-
Which of the following is a way to bind the data and its associated functions together?
- Methods
- Class
- Data
- Functions
Show answer
B. Class
-
Private access specifier is accessible by special function called ____
- Void
- Inline
- Friend
- All of these
Show answer
C. Friend
-
_____ member variable are initialized only once when the first object of its class is created.
- Inline
- Static
- Private
- Public
Show answer
B. Static
-
One copy of ___ data members of a class are shared by all objects of that class.
- Public
- Static
- Private
- Inline
Show answer
B. Static
-
The members defined within the class behave like ____functions.
- Inline
- Public
- Friend
- None of these
Show answer
A. Inline
- Advertisement
-
:: is a ___
- Short circuit AND
- Short circuit OR
- Not operator
- Scope resolution operator
Show answer
D. Scope resolution operator
-
A class belongs to which of the following data types?
- Array Type
- Derived Type
- Built-in Type
- User Defined Type
Show answer
D. User Defined Type
-
Every class declaration is terminated by ____
- ,(comma)
- .(dot)
- ; (semi colon)
- :: (double colon)
Show answer
C. ; (semi colon)
-
A member function calling another function directly is called as ____
- Nesting functions
- Recursive functions
- Inline functions
- Friend functions
Show answer
A. Nesting functions
-
Class access specifiers are also known as ____
- Specifications
- Class depth
- Visibility labels
- None of these
Show answer
C. Visibility labels
-
____ are the functions that perform specific task in a class.
- Data functions
- Concrete functions
- Member functions
- Data members
Show answer
C. Member functions