Explore topic-wise MCQs in Technical Programming.

This section includes 916 Mcqs, each offering curated multiple-choice questions to sharpen your Technical Programming knowledge and support exam preparation. Choose a topic below to get started.

751.

When is the destructor of a global object called?

A. Just before end of program
B. Just after end of program
C. With the end of program
D. Anytime when object is not needed
Answer» B. Just after end of program
752.

If in multiple inheritance, class C inherits class B, and Class B inherits class A. In which sequence are their destructors called, if an object of class C was declared?

A. ~C() then ~B() then ~A()
B. ~B() then ~C() then ~A()
C. ~A() then ~B() then ~C()
D. ~C() then ~A() then ~B()
Answer» D. ~C() then ~A() then ~B()
753.

Which among the following is correct for abstract class destructors?

A. It doesn’t have destructors
B. It has destructors
C. It may or may not have destructors
D. It contains an implicit destructor
Answer» B. It has destructors
754.

When a destructor is called?

A. After the end of object life
B. Anytime in between object’s lifespan
C. At end of whole program
D. Just before the end of object life
Answer» E.
755.

Which among the following describes a destructor?

A. A special function that is called to free the resources, acquired by the object
B. A special function that is called to delete the class
C. A special function that is called anytime to delete an object
D. A special function that is called to delete all the objects of a class
Answer» B. A special function that is called to delete the class
756.

The destructor can be called before the constructor if required. (True/False)

A. True
B. False
Answer» C.
757.

The destructors ____________

A. Have a return type
B. May have a return type
C. Of derived classes have return type
D. Doesn’t have a return type
Answer» E.
758.

The constructor _____________

A. Have a return type
B. May have a return type
C. Of derived classes have return type
D. Doesn’t have a return type
Answer» E.
759.

Which among the following is true for destructors?

A. Destructors can be overloaded
B. Destructors can be define more than one time
C. Destructors can’t be overloaded
D. Destructors are overloaded in derived classes
Answer» D. Destructors are overloaded in derived classes
760.

If a class have 4 constructors then it must have 4 destructors also.

A. True
B. False
Answer» C.
761.

For explicit call _________________

A. The destructor must be private
B. The destructor must be public
C. The destructor must be protected
D. The destructor must be defined outside the class
Answer» C. The destructor must be protected
762.

Number of destructors called are

A. Always equal to number of constructors called
B. Always less than the number of constructors called
C. Always greater than the number of constructors called
D. Always less than or equal to number of constructors
Answer» B. Always less than the number of constructors called
763.

Destructor calls ________________ (C++)

A. Are only implicit
B. Are only explicit
C. Can be implicit or explicit
D. Are made at end of program only
Answer» D. Are made at end of program only
764.

The destructors _____________________

A. Can have maximum one argument
B. Can’t have any argument
C. Can have more than one argument
D. Can’t have more than 3 arguments
Answer» C. Can have more than one argument
765.

What is the sequence of destructors call?

A. Same order as that of the constructors call
B. Random order
C. Random order
D. Revere of the order of constructor call
Answer» E.
766.

Which among the following is correct syntax for the destructors?

A. classname()
B. ()classname
C. ~classname()
D. -classname()
Answer» D. -classname()
767.

Which among the following represents correct constructor?

A. ()classname
B. ~classname()
C. –classname()
D. classname()
Answer» E.
768.

Which among the following best describes destructor?

A. A function which is called just before the objects are destroyed
B. A function which is called after each reference to the object
C. A function which is called after termination of the program
D. A function which is called before calling any member function
Answer» B. A function which is called after each reference to the object
769.

Which among the following best describes the constructors?

A. A function which is called whenever an object is referenced
B. A function which is called whenever an object is created to initialize the members
C. A function which is called whenever an object is assigned to copy the values
D. A function which is called whenever an object is to be given values for members
Answer» C. A function which is called whenever an object is assigned to copy the values
770.

Which is correct syntax?

A. classname objectname= new() integer;
B. classname objectname= new classname;
C. classname objectname= new classname();
D. classname objectname= new() classname();
Answer» D. classname objectname= new() classname();
771.

What is we only create an object but don’t call any constructor for it in java?

A. Implicit constructor will be called
B. Object is initialized to some null values
C. Object is not created
D. Object is created but points to null
Answer» E.
772.

Which among the following is not valid in java?

A. Constructor overloading
B. Recursive constructor call
C. Default value constructors
D. String argument constructor
Answer» C. Default value constructors
773.

If programmer have defined parameterized constructor only, then __________________

A. Default constructor will not be created by the compiler implicitly
B. Default constructor will be created by the compiler implicitly
C. Default constructor will not be created but called at runtime
D. Compile time error
Answer» B. Default constructor will be created by the compiler implicitly
774.

Why do we use constructor overloading?

A. To use different types of constructors
B. Because it’s a feature provided
C. To initialize the object in different ways
D. To differentiate one constructor from another
Answer» D. To differentiate one constructor from another
775.

Which among the following function can be used to call default constructor implicitly in java?

A. this()
B. that()
C. super()
D. sub()
Answer» B. that()
776.

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
Answer» E.
777.

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
Answer» C. Constructors are overloaded with different signature
778.

Which among the following is possible way to overload constructor?

A. Define default constructor, 1 parameter constructor and 2 parameter constructor
B. Define default constructor, zero argument constructor and 1 parameter constructor
C. Define default constructor, and 2 other parameterized constructors with same signature
D. Define 2 default constructors
Answer» B. Define default constructor, zero argument constructor and 1 parameter constructor
779.

Does constructor overloading include different return types for constructors to be overloaded?

A. Yes, if return types are different, signature becomes different
B. Yes, because return types can differentiate two functions
C. No, return type can’t differentiate two functions
D. No, constructors doesn’t have any return type
Answer» E.
780.

Can constructors be overloaded in derived class?

A. Yes, always
B. Yes, if derived class has no constructor
C. No, programmer can’t do it
D. No, never
Answer» E.
781.

Which among the following best describes constructor overloading?

A. Defining one constructor in each class of a program
B. Defining more than one constructor in single class
C. Defining more than one constructor in single class with different signature
D. Defining destructor with each constructor
Answer» D. Defining destructor with each constructor
782.

Copy constructors are overloaded constructors.

A. True
B. False
Answer» B. False
783.

The arguments to a copy constructor _____________

A. Must be const
B. Must not be cosnt
C. Must be integer type
D. Must be static
Answer» B. Must not be cosnt
784.

Can a copy constructor be made private?

A. Yes, always
B. Yes, if no other constructor is defined
C. No, never
D. No, private members can’t be accessed
Answer» B. Yes, if no other constructor is defined
785.

The deep copy is possible only with the help of __________

A. Implicit copy constructor
B. User defined copy constructor
C. Parameterized constructor
D. Default constructor
Answer» C. Parameterized constructor
786.

Copy constructor will be called whenever the compiler __________

A. Generates implicit code
B. Generates member function calls
C. enerates temporary object
D. Generates object operations
Answer» D. Generates object operations
787.

Out of memory error is given when the object _____________ to the copy constructor.

A. Is passed with & symbol
B. Is passed by reference
C. Is passed as
D. Is not passed by reference
Answer» E.
788.

Object being passed to a copy constructor ___________

A. Must be passed by reference
B. Must be passed by value
C. Must be passed with integer type
D. Must not be mentioned in parameter list
Answer» B. Must be passed by value
789.

What is the syntax of copy constructor?

A. classname (classname &obj){ /*constructor definition*/ }
B. classname (cont classname obj){ /*constructor definition*/ }
C. classname (cont classname &obj){ /*constructor definition*/ }
D. classname (cont &obj){ /*constructor definition*/ }
Answer» D. classname (cont &obj){ /*constructor definition*/ }
790.

If a class implements some dynamic memory allocations and pointers then _____________

A. Copy constructor must be defined
B. Copy constructor must not be defined
C. Copy constructor can’t be defined
D. Copy constructor will not be used
Answer» B. Copy constructor must not be defined
791.

If programmer doesn’t define any copy constructor then _____________

A. Compiler provides an implicit copy constructor
B. Compiler gives an error
C. The objects can’t be assigned with another objects
D. The program gives run time error if copying is used
Answer» B. Compiler gives an error
792.

Which returning an object, we can use ____________

A. Default constructor
B. Zero argument constructor
C. Parameterized constructor
D. Copy constructor
Answer» E.
793.

The copy constructors can be used to ________

A. Copy an object so that it can be passed to a class
B. Copy an object so that it can be passed to a function
C. Copy an object so that it can be passed to another primitive type variable
D. Copy an object for type casting
Answer» C. Copy an object so that it can be passed to another primitive type variable
794.

If two classes have exactly same data members and member function and only they differ by class name. Can copy constructor be used to initialize one class object with another class object?

A. Yes, possible
B. Yes, because the members are same
C. No, not possible
D. No, but possible if constructor is also same
Answer» D. No, but possible if constructor is also same
795.

The copy constructor can be used to:

A. Initialize one object from another object of same type
B. Initialize one object from another object of different type
C. Initialize more than one object from another object of same type at a time
D. Initialize all the objects of a class to another object of another class
Answer» B. Initialize one object from another object of different type
796.

Copy constructor is a constructor which ________________

A. Creates an object by copying values from any other object of same class
B. Creates an object by copying values from first object created for that class
C. Creates an object by copying values from another object of another class
D. Creates an object by initializing it with another previously created object of same class
Answer» E.
797.

If constructors of a class are defined in private access, then:

A. The class can’t be inherited
B. The class can be inherited
C. Instance can be created only in another class
D. Instance can be created anywhere in the program
Answer» B. The class can be inherited
798.

When is the static constructor called?

A. After the first instance is created
B. Before default constructor call of first instance
C. Before first instance is created
D. At time of creation of first instance
Answer» D. At time of creation of first instance
799.

Default constructor initializes all data members as:

A. All numeric member with some garbage values and string to random string
B. All numeric member with some garbage values and string to null
C. All numeric member with zero and strings to random value
D. All numeric member with zero and strings to null
Answer» E.
800.

Within a class, only one static constructor can be created.

A. True
B. False
Answer» B. False