MCQ Oops With C++ Questions With Answer
MCQ Oops With C++ Questions With Answer
a. top-down
b. procedural
c. bottom-up C
d. all of these.
.
A. Friend keyword can be used in the class to allow access to another class.
B. Friend keyword can be used for a function in the public section of a class.
C. Friend keyword can be used for a function in the private section of a class.
b. Virtual Functions
c. Templates C
d. None of these
int main()
{
while(1)
{
Cout<<"kumar.com"<<endl;
}
return 0;
}
(A) 1 time
(B) Compilation Error
(C) Infinite times c
(D) Runtime Error
A. Protected
B. Public
C. Private C
D. Friend
Q7 Which of the following keywords is used to control access to a class member?
A. Default
B. Break
C. Protected C
D. public
Q8 What is output of below program?
int main()
{
int i,j,count;
count=0;
for(i=0; i<5; i++);
{
for(j=0;j<5;j++);
{
count++;
}
}
printf("%d",count);
return 0;
(A) 55
(B) 54
(C) 1 C
(D) 0
class Bike
{
Engine objEng;
};
class Engine
{
float CC;
};
A. kind of relationship
B. has a relationship B
C. Inheritance
D. Both A and B
Q10 What does a class hierarchy depict?
A. It shows the relationships between the classes in the form of an organization chart.
return 0;
}
a) Yes, always
b) Yes, if program doesn’t contain any classes
c) No, because main function is user defined
d) No, never D
a. Copy constructor
b. Friend constructor B
c. Default constructor
d. Parameterized constructor
Q15 What is output of below program?
int main()
{
for(; ;);
for(; ;);
printf("Hello");
return 0;
}
(A) Compilation Error
(B) Runtime Error
(C) Hello is printed one time
(D) Hello is printed infinite times D
Q16 Which of the following concepts means determining at runtime what method to
invoke?
a.Data hiding
b.Dynamic Typing
c. Dynamic binding
d. Dynamic loading
Q17 Which of the following correctly describes overloading of functions?
a. Virtual polymorphism
b. Transient polymorphism
c. Ad-hoc polymorphism
d. Pseudo polymorphism
Q18 A constructor that accepts __________ parameters is called the default constructor.
a. One
b. Two
c. Three
d. No D
Q19 Can a class have virtual destructor?
a. Yes A
b. No
c. May be
d. None of above
Q20 Which constructor function is designed to copy objects of the same class type?
class Student
{
int a;
public : float a;
};
a) Error : same variable name can’t be used twiceA
b) Error : Public must come first
c) Error : data types are different for same variable
d) It is correct
Q25 Which among the following handles the undefined class exception in program?
A. ClassNotFound
B. NoClassException B
C.ClassFoundException
D. ClassNotFoundException handles the undefined class exception in program
(A) 11
(B) 10
(C) Compilation Error C
(D) 0Q27 What is meant by multiple inheritance?
A. Deriving a base class from derived class
B. Deriving a derived class from base class
C. Deriving a derived class from more than one base class
D. None of the mentioned
int main()
{
int A;
A = 10;
printf("%d", A);
return 0;
}
(A) extern
(B) auto B
(C) register
(D) static
Q29 Which symbol is used to create multiple inheritance?
A. Dot
B. CommaB
C. Dollar
D. None of the above
class Base
{
public:
Base(){}
~Base(){}
protected:
private:
};
class Derived:public Base
{
public:
Derived(){}
Derived(){}
private:
protected:
};
int main()
{
cout << "Executed" << endl;
}
A. Executed
B. ErrorB
C. Runtime error
D. None of the mentioned
Q31Which of the following is true about the following program
class Base1
{
public:
~Base1() { cout << " Base1" << endl; }
};
class Base2
{
public:
~Base2() { cout << " Base2" << endl; }
};
int main()
{
Derived d;
return 0;
}
A. Base1 Base2 Derived
B. Derived Base2 Base1B
C. Derived
D. Compiler Dependent
Q32 What will be the output of the following C++ code?
class Base
{
public:
virtual void print() const = 0;
};
class DerivedOne : public Base
{
public:
void print() const
{
cout << "DerivedOne\n";
}
};
class DerivedTwo : public Base
{
public:
void print() const
{
cout << "DerivedTwo\n";
}
};
class Multiple : public DerivedOne, public DerivedTwo
{
public:
void print() const
{
DerivedTwo :: print();
}
};
int main()
{
int i;
Multiple both;
DerivedOne one;
DerivedTwo two;
Base *array[ 3 ];
array[ 0 ] = &both;
array[ 1 ] = &one;
array[ 2 ] = &two;
array[ i ] -> print();
return 0;
}
a) DerivedOne
b) DerivedTwo
c) Error
d) DerivedThree
Q33 What would be the behaviour if this() and super() used in a method?
a) Runtime error
b) Throws exception
c) compile time error C
d) Runs successfully
Q34 Which of the following is the correct class of the object cout?
A. iostream
B. istream
C. Ostream C
D. ifstream
Q35 Which of the following functions are performed by a constructor?
A NEW
B. Construct a new object
D. Initialize objects D
Q36 More than one user-defined functions can have the same name and perform different
operations. This is a powerful feature of C++ and is known as —-
a. inheritance
b. operator loading
c. function overloading C
d. both c and b
Q.37 (i) ‘ios’ is the base class of ‘istream’
(ii) All the files are classified into only 2 types. (1) Text Files (2) Binary Files.
void main() {
char *s = "C++";
cout<<s<<" ";
s++;
cout<<s<<" ";
}
A - C++ C++
B - C++ ++
C - ++ ++
D - Compile error
Q39 What the output of following C++ program?
class Empty {};
int main()
{
cout << sizeof(Empty);
return 0;
}
A. class name
(A) One
(B) Two
(C) Three
(D) Unlimited D
A. Addition
B. Modulus
C. Multiply
D. DIVISION
b. malloc()
c. Realloc()
d. both a and b D
b. object of Class1
c. reference to ptr B
d. reference of Class1
int
main ()
{
cout << "Hello World!" return 0;
}
a. Hello World
b. Syntax error B
c. 0
d. Hello World!
a. Structured Programming A
b. Object Oriented Programming (OOP)
c. Functional Programming
d. Aspect Oriented Programming (AOP)