cpp class objects exercise

C++ exercise

1. Which of the following is not a valid class specifier ?

a. Private
b. Public
c. Protected
d. Pointer

Show Answer

The correct option is (d)
Explanation:
No Explanation for this Question.

2. In C++, the class variables are called as ____

a. Objects
b. Functions
c. Methods
d. Constants

Show Answer

The correct option is (a)
Explanation:
No Explanation for this Question.

3. What does a class in C++ holds ?

a. functions
b. both data & functions
c. arrays
d. data

Show Answer

The correct option is (b)
Explanation:
The classes in C++ encapsulates(i.e. put together) all the data and functions related to them for manipulation.

4. How many specifiers are present in access specifiers in class ?

a. 1
b. 2
c. 3
d. 4

Show Answer

The correct option is (c)
Explanation:
There are three types of access specifiers. They are public, private, protected

5.Which is used to define the member of a class externally ?

a. ::
b. :
c. #
d. !!$

Show Answer

The correct option is (a)
Explanation:
:: operator is used to define the body of any class function outside the class.

6. Which other keywords are also used to declare the class other than class ?

a. union
b. object.
c. both struct & union
d. struct

Show Answer

The correct option is (d)
Explanation:
union and Struct take the same definition of class but differs in the access techniques.

7. The data members and functions of a class in C++ are by default ____________?

a. public.
b. public & protected
c. protected
d. private

Show Answer

The correct option is (d)
Explanation:
By default all the data members and member functions of class are private.

8. Constructors are used to ____________ ?

a. construct the data members.
b. both initialize the objects & construct the data members
c. delete the objects
d. initialize the objects

Show Answer

The correct option is (d)
Explanation:
Once the object is declared means, the constructor are also declared by default.

9. Which operator is used to allocate an object dynamically of a class in C++ ?

a. Scope resolution operator.
b. Conditional operator
c. New operator
d. Membership access

Show Answer

The correct option is (c)
Explanation:
No Explanation for this Question.

10. Statically allocated object for class A in C++ is ?

a. A obj = new A();
b. A *obj = new A();
c. A obj;
d. None

Show Answer

The correct option is (c)
Explanation:
No Explanation for this Question.

  • C++ Dynamic Initialization of Objects
  • C++ Copy Constructor
  • C++ Dynamic Constructor
  • C++ Destructors
  • C++ Exercise
  • C++ Operator Overloading
  • C++ Overloading Unary Operators
  • Const pointer in C
  • Void pointer in c
  • C++ Overloading Binary Operators
  • C++ Overloading Binary Operators Using Friends
  • C++ Manipulation String Using Operators
  • C++ Rules for overloading operators
  • C++ Exercise
  • C++ Basic To class Type
  • C++ Class TO Basic Type
  • C++ One class To another class type
  • C++ Exercise
  • C++ Inheritance introduction
  • C++ Single Inheritance
  • C++ Multiple Inheritance
  • C++ Ambiguity Resolution in inheritance
  • C++ Hierarchical Inheritance
  • C++ Hybrid Inheritance
  • C++ Virtual Base Classes
  • C++ Exercise
  • C++ abstract class
  • C++ nesting of classes
  • C++ Exercise
  • C++ polymorphism
  • C++ Exercise
  • C++ pointers
  • C++ Pointers TO object
  • C++ this pointer
  • C++ Pointer to Derived class
  • C++ Virtual functions
  • C++ Exercise
  • C++ streams
  • C++ unformatted I/O operations
  • C++ Put() and get()
  • C++ getline() and write()
  • C++ Formatted console I/O
  • C++ Manipulators
  • C++ Exercise
  • C++ file handling
  • C++ file stream classes
  • C++ Open and closing file
  • C++ open using constructor
  • C++ open using open()
  • C++ Detecting End of file
  • C++ File modes
  • C++ File pointers and Manipulators
  • C++ Sequential I/O
  • C++ Reading and Writing
  • C++ Updating a File
  • C++ Error handling In File
  • C++ Command Line Arguments
  • C++ Exercise
  • C++ Template introduction
  • C++ Class Templates with multiple Parameters
  • C++ Function templates
  • C++ Function templates with multiple parameters
  • C++ member function Template
  • C++ Exercise
  • C++ Exception handling
  • C++ Basics of Exception Handling
  • C++ Exception Handling Mechanism
  • C++ Throwing Mechanism
  • C++ Catch Mechanism
  • C++ Catch all Exceptions
  • C++ Re-Throwing An Exception
  • C++ Specifying Exceptions
  • C++ Exercise