1 / 7100%
Choose the correct answer:
………is a programming paradigm based on the concept of “objects”.
a) OOP b) c++ c) functional d) procedural
A ……is a style of programming, a way of thinking about software
construction.
a) programming paradigm b) language c) syntax semantic
In which access should a constructor be defined, so that object of the class
can be created in any function?
a) Any access specifier will work
b) Private
c) Public
d) Protected
The copy constructors can be used to ________
a) Copy an object so that it can be passed to another primitive type variable
b) Copy an object for type casting
c) Copy an object so that it can be passed to a function
d) Copy an object so that it can be passed to a class
Which among the following represents correct constructor?
a) classname()
b) classname()
c) ()classname
d) ~classname()
Which access specifier is usually used for data members of a class?
a) Protected
b) Private
c) Public
d) Default
Which type of members cant be accessed in derived classes of a base class?
a) All can be accessed
b) Protected
c) Private
d) Public
How to access the private member function of a class?
a) Using class address
b) Using object of class
c) Using object pointer
d) Using address of member function
Which among the following is not a necessary condition for constructors?
a) Its name must be same as that of class
b) It must not have any return type
c) It must contain a definition body
d) It can contains arguments
Pure OOP can be implemented without using class in a program.
a) True
b) False
What is default access specifier for data members or member functions
declared within a class without any specifier, in C++?
a) Private
b) Protected
c) Public
d) Depends on compiler
Which is most appropriate comment on following class definition?
a) Error : same variable name cant be used twice
b) Error : Public must come first
c) Error : data types are different for same variable
d) It is correct
Which definition best describes an object?
a) Instance of a class
b) Instance of itself
c) Child of a class
d) Overview of a class
Which among the following is correct?
a) class student{ public: int student(){} };
b) class student{ public: void student (){} };
c) class student{ public: student{}{} };
d) class student{ public: student(){} };
In which access should a constructor be defined, so that object of the class
can be created in any function?
a) Public
b) Protected
c) Private
d) Any access specifier will work
Which object will be created first?
a) s1 then s2 then s3
b) s3 then s2 then s1
c) s2 then s3 then s1
d) all are created at same time
For constructor overloading, each constructor must differ in ___________
and __________
a) Number of arguments and type of arguments
b) Number of arguments and return type
c) Return type and type of arguments
d) Return type and definition
Choose the correct option for the following code.
a) Object s1 should be passed with argument
b) Object s2 should not be declared
c) Object s2 will not be created, but program runs
d) Program gives compile time error
Which constructor is called while assigning some object with another?
a) Default
b) Parameterized
c) Copy
d) Direct assignment is used
Which type of constructor cant have a return type?
a) Default
b) Parameterized
c) Copy
d) Constructors dont have a return type
Which among the following is false for a constructor?
a) Constructors doesn’t have a return value
b) Constructors are always user defined
c) Constructors are overloaded with different signature
d) Constructors may or may not have any arguments being accepted
When is the constructor called for an object?
a) As soon as overloading is required
b) As soon as class is derived
c) As soon as class is created
d) As soon as object is created
Why do we use constructor overloading?
a) To use different types of constructors
b) Because its a feature provided
c) To initialize the object in different ways
d) To differentiate one constructor from another
Which constructor will be called from the object obj2 in the following
program?
a) A(int x)
b) A(int y)
c) A(int y, int x)
d) A(int y; int x)
Destructors doesn’t accept parameters.
a) True
b) False
When the ………… access modifier is applied to a class member, the
member can be accessed by code inside the class or outside.
a) Public b)private c) protected d) none of these
When the ………. access modifier is applied to a class member, the member
cannot be accessed by code outside the class.
a)Public b)private c) protected d) none of these
Create a class to store details of a circle such as radius and
color.
1. Make the radius and color variables are private.
2. Create a constructor with default values.
3. Create getter functions to return radius and color.
4. Create a function to compute circle area.
Create a class to store details of a square such as length.
1. Make the length variable is private.
2. Create a constructor with default values.
3. Create getter functions to return length.
4. Create a function to compute square area.
Create a class to store details of a rectangle such as width
and height.
1. Make the height and width variables are private.
2. Create a constructor with default values.
3. Create getter functions to return width and height.
4. Create a function to compute rectangle area.
Find the errors in the following codes:
Find the errors in the following codes:
Find the errors in the following codes:
Powered by TCPDF (www.tcpdf.org)
Students also viewed