Object oriented programming using C++ mcq test for Btech

Quiz

This test completely based on Exam pattern and Syllabus, So give this test and Improve your preparations! Wish you very all the best!

Q.1 What is the implicit return type of constructor?

(A) No return type
(B) A class object in which it is defined.
(C) void
(D) None

Q.2 When is the object created with a new keyword?

(A) At run time
(B) At compile time
(C) Depends on the code
(D) None

Q.3 Identify the scope resolution operator.

(A) :
(B) ::
(C) ?:
(D) None

Q.4 Total types of constructors in C++ are?

(A) 1
(B) 2
(C) 3
(D) 4

Q.5 Under which pillar of OOPS do base class and derived class relationships come?

(A) Polymorphism
(B) Inheritance
(C) Encapsulation
(D) Abstraction

Q.6 Which constructor will be called from the object created in the below C++ code?

class A { int i; A() { i=0; cout<<i; } A(int x=0) { i=x; cout<<I; }; } A obj1

(A) Parameterized constructor
(B) Default constructor
(C) Run time error
(D) Compile time error

Q.7 Which among the following can show polymorphism?

(A) Overloading &&
(B) Overloading <<
(C) Overloading ||
(D) Overloading +=

Q.8 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
(C) Protected

Q.9 Which is most appropriate comment on following class definition?

class Student { int a; public : float a; };

(A) Error : same variable name can’t be used twice
(B) Error : Public must come first
(C) Error : data types are different for same variable
(D) It is correct

Q.10 Which class/set of classes can illustrate polymorphism in the following C++ code?

abstract class student { public : int marks; calc_grade(); } class topper:public student { public : calc_grade() { return 10; } }; class average:public student { public : calc_grade() { return 20; }}; class failed{ int marks; };

(A) Only class student and topper together can show polymorphism
(B) Only class student can show polymorphism
(C) Class failed should also inherit class student for this code to work for polymorphism
(D) All class student, topper and average together can show polymorphism

Post a Comment

Previous Post Next Post