LakshyaEducation.in

VEDIC MATHS Video Series
  • Home
  • Video Series
    • Vedic Maths Videos
    • Quantitative Aptitude Videos
    • Class 8 Maths Videos
    • Class 9 Maths Videos
    • Class 10 Maths Videos
  • Quiz & Solutions
  • Blog
  • Store
  • Login
  • Contact Us
  • Home
  • Topic
  • C++ Programming
  • Derived Classes

C++ Programming

DERIVED CLASSES MCQs

Total Questions : 10

Question 1.

Which constructor will initialize the base class data member?


  1.    derived class
  2.    base class
  3.    class
  4.    None of the mentioned
 Discuss Question
Answer is Option B. -> base class

Because it is having the proper data set to initialize, Otherwise it will throw a error.

Question 2.


What is the output of this program?



1.
#include
2.
using namespace std;
3.
class X
4.
{
5.
int m;
6.
public:
7.
X() : m(10)
8.
{
9.
}
10.
X(int mm): m(mm)
11.
{
12.
}
13.
int getm()
14.
{
15.
return m;
16.
}
17.
};
18.
class Y : public X
19.
{
20.
int n;
21.
public:
22.
Y(int nn) : n(nn) {}
23.
int getn() { return n; }
24.
};
25.
int main()
26.
{
27.
Y yobj( 100 );
28.
cout
  1.    10 100
  2.    100 10
  3.    10 10
  4.    100 100
 Discuss Question
Answer is Option A. -> 10 100

In this program, We are passing the value and getting the result by derived class.
Output:
$ g++ der5.cpp
$ a.out
10 100

Question 3.

Which operator is used to declare the destructor?


  1.    #
  2.    ~
  3.    @
  4.    $
 Discuss Question
Answer is Option B. -> ~

None.

Question 4.


What is the output of this program?



1.
#include
2.
using namespace std;
3.
class Parent
4.
{
5.
public:
6.
Parent (void)
7.
{
8.
cout
  1.    10 100
  2.    100 10
  3.    10 10
  4.    100 100
 Discuss Question
Answer is Option A. -> 10 100

Answer:b
Explanation:
In this program, We got an error in overloading because we didn’t invoke the 

destructor of parent.

Question 5.


What is the output of this program?



1.
#include
2.
using namespace std;
3.
class Base
4.
{
5.
public:
6.
int m;
7.
Base(int n=0)
8.
: m(n)
9.
{
10.
cout
  1.    10 100
  2.    100 10
  3.    10 10
  4.    100 100
 Discuss Question
Answer is Option A. -> 10 100

Answer:a
Explanation: 
In this program, We are printing the execution order of the program.
Output:
$ g++ der2.cpp
$ a.out
Instantiating Base
Base
Instantiating Derived
Base
Derived

Question 6.

Which of the following can derived class inherit?


  1.    members
  2.    functions
  3.    both a & b
  4.    None of the mentioned
 Discuss Question
Answer is Option C. -> both a & b

None.

Question 7.


What is the output of this program?



1.
#include
2.
using namespace std;
3.
class A
4.
{
5.
public:
6.
A(int n )
7.
{
8.
cout
  1.    54.3R
  2.    R4.35
  3.    4.3R5
  4.    None of the mentioned
 Discuss Question
Answer is Option A. -> 54.3R

In this program, We are passing the value and manipulating by using the derived class.
Output:
$ g++ der.cpp
$ a.out
54.3R

Question 8.


What is the output of this program?



1.
#include
2.
using namespace std;
3.
class BaseClass
4.
{
5.
protected:
6.
int i;
7.
public:
8.
BaseClass(int x)
9.
{
10.
i = x;
11.
}
12.
~BaseClass()
13.
{
14.
}
15.
};
16.
class DerivedClass: public BaseClass
17.
{
18.
int j;
19.
public:
20.
DerivedClass(int x, int y): BaseClass(y)
21.
{
22.
j = x;
23.
}
24.
~DerivedClass()
25.
{
26.
}
27.
void show()
28.
{
29.
cout
  1.    3 4
  2.    4 3
  3.    4
  4.    3
 Discuss Question
Answer is Option B. -> 4 3

In this program, We are passing the values and assigning it to i and j and we are printing it.
Output:
$ g++ der1.cpp
$ a.out
4 3

Question 9.

Where is the derived class is derived from?


  1.    derived
  2.    base
  3.    both a & b
  4.    None of the mentioned
 Discuss Question
Answer is Option B. -> base

Because derived inherits functions and variables from base.

Question 10.

Pick out the correct statement.


  1.    A derived class's constructor cannot explicitly invokes its base class's constructor.
  2.    A derived class's destructor cannot invoke its base class's destructor.
  3.    A derived class's destructor can invoke its base class's destructor.
  4.    None of the mentioned
 Discuss Question
Answer is Option B. -> A derived class's destructor cannot invoke its base class's destructor.

Destructors are automatically invoked when a object goes out of scope or when a dynamically 

allocated object is deleted. Inheritance does not change this behavior. This is the reason a 

derived destructor cannot invoke its base class destructor.

  • Share on Facebook!
  • Share on Pinterest!

Sub Topics

  • Abstract Classes
  • Access Control
  • Argument Passing
  • Arrays
  • Booleans
  • C++ Concepts
  • Catching Exceptions
  • Character Types
  • Class Hierarchies And Abstract Classes
  • Class Hierarchies Introduction
  • Classes
  • Comments And Indentation
  • Complex Number Type
  • Constants
  • Constructors And Destructors
  • Container Design
  • Conversion Operators
  • Declaration
  • Default Arguments
  • Dereferencing
  • Derivation And Templates
  • Derived Classes
  • Design Of Class Hierarchies
  • Enumerations
  • Error Handling
  • Error Handling Alternatives
  • Essential Operators
  • Exception Specifications
  • Exceptions
  • Exceptions And Efficiency
  • Exceptions That Are Not Errors
  • Floating Point Types
  • Free Store
  • Friends
  • Function Call
  • Function Declarations
  • Function Templates
  • Functions
  • Grouping Of Exceptions
  • Header Files Usage
  • Increment And Decrement
  • Integer Types
  • Large Objects
  • Linkage
  • Macros
  • Modularization And Interfaces
  • Multiple Inheritance
  • Namespaces
  • Objects
  • Objects And Classes
  • Oops Concepts
  • Operator Functions
  • Operators
  • Overloaded Function Names
  • Pointer To Function
  • Pointer To Void
  • Pointers
  • Pointers Into Arrays
  • Pointers To Members
  • References
  • Resource Management
  • Run Time Type Information
  • Sequence Adapters
  • Sequences
  • Simple String Template
  • Sizes
  • Specialization
  • Standard Exceptions
  • Standard Library Design
  • Statements
  • String Class
  • Structures
  • Subscripting
  • Template Arguments To Specify Policy Usage
  • Types
  • Uncaught Exceptions
  • Unspecified Number Of Arguments
  • User Defined Types
  • Value Return
  • Vector
  • Void

Topics

  • Computer Aptitude
  • SAIL Junior Officer (E-0)
  • 10th Grade
  • 11th Grade
  • 12th Grade
  • 4th Grade
  • 5th Grade
  • 6th Grade
  • 7th Grade
  • 8th Grade
  • 9th Grade
  • NCERT
  • Cat
  • Commerce
  • Computer Science
  • Engineering
  • English
  • General Knowledge
  • Ias
  • Management
  • Quantitative Aptitude
  • Reasoning Aptitude
  • General Studies (Finance And Economics)
  • Analytical Instrumentation
  • Biochemistry
  • Bioinformatics
  • Biology
  • Biotechnology
  • Bitsat
  • Business Statistics
  • C Programming
  • C++ Programming
  • Cell Biology
  • Chemistry
  • Cost Accounting
  • Drug And Pharmaceutical Biotechnology
  • Electrical Measurement And Instrumentation
  • Environment Management
  • Environmental Biotechnology
  • Enzyme Technology
  • Financial Management And Financial Markets
  • Gate
  • General Science
  • Geography
  • Heat Transfer
  • History And National Movements
  • Human Anatomy And Physiology
  • Human And Cultural Diversity
  • Human Resource Management
  • Indian Economy
  • Indian Geography
  • Indian History
  • Indian Polity
  • Instrumentation Transducers
  • International Relations
  • Life Sciences
  • Marketing And Marketing Management
  • Mass Transfer
  • Mechanics Of Materials
  • Microbiology
  • Neet
  • Professional Communication
  • Renewable Energy
  • Sociology
  • Surveying
  • Total Quality Management
  • Uidai Aadhaar Supervisor Certification
  • Virology

Recent Questions

Q.   In Each Question, The First And The Last Sentences Of The Pa....

Q.   His Death Is A Great Blow, Most Terrible To . . . . . . . .

Q.   Azure Blob Storage Offers How Many Storage Tiers?

Q.   Find Out Whether There Is Any Grammatical Error In Below Sen....

Q.   In Power Point, This Is A Container For Text Or Graphics.

Q.   Symmetric Multiprocessing (SMP) Architectures Are Useful For....

Q.   It Is An Instrument That Entitles The Holder To A Proportio....

Q.   In Each Question Below A Sentence Broken Into Four Or Five P....

Q.   The Playground Of Lawn Tennis Is Called

Q.   How Many Numbers (N) Can We Have, Such That 100<N<1000....

Q.    a Button That Makes Characters Either Upper Or Lower Case ....

Q.    the Area Of A Rectangle Is 45 Cm². If Its Length Is 9 Cm,....

Q.   Which Of The Following Presentation Elements Can You Modify ....

Q.   Di....

Q.   Adversity

Q.   1 U = _______ Nanokatals.

Q.   The Manner In Which Bombs Exploded In Five Trains With In A ....

Q.   Spiny Seeds With Hooks are Dispersed By Animals.

Q.   The Process Of Improving The Cutting Action Of The Grinding ....

Q.   To Meet The Educational Needs Of The People, The Madarasa-I ....

LakshyaEducation.in
Lakshya Education
Bhilai,Chattisgarh,India
Email: admin@lakshyaeducation.in Phone: 07893519977 (WhatsApp)

Quick Links

  • Vedic Maths
  • Quantitative Aptitude
  • Class – IX Maths
  • Class – X Maths
  • YouTube Channel
  • Maths Fast Trick
  • Blog

Our Services

  • About us
  • Privacy
  • TOS
  • Refund / Cancellation
  • Contact
  • Affiliate Program
  • Copyright © 2022 All Right Reserved | Lakshya Education     ( )
    Login / Register

    Your Account will be created automatically when you click the below Google or Facebook Login Button.
    •   Login With Facebook
    •  Login With Google
     Login With Email/Password