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