0% found this document useful (0 votes)
55 views43 pages

Fpli II Unitii MCQ

The document contains multiple-choice questions (MCQs) related to object-oriented programming concepts in C++. It covers topics such as class declarations, constructors, access specifiers, polymorphism, and exception handling. Each question is followed by the correct answer and a brief explanation where applicable.

Uploaded by

quansaha085
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views43 pages

Fpli II Unitii MCQ

The document contains multiple-choice questions (MCQs) related to object-oriented programming concepts in C++. It covers topics such as class declarations, constructors, access specifiers, polymorphism, and exception handling. Each question is followed by the correct answer and a brief explanation where applicable.

Uploaded by

quansaha085
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 43

FPL-II Unit-2

Object oriented Programming Concepts

MCQ's

QUESTION: What does your class can hold?


A: Data
B: functions
C: both a & b
D: none of the mentioned

Ans: C
EXPLANATION: The classes in c++ are used to manipulate both data and functions.
QUESTION: Which is used to define the member of a class externally?
A: :

B: ::

C: #

D: none of the mentioned

Ans: B
QUESTION: Which other keywords are also used to declare the class other than class?
A: struct
B: union
C: object
D: both a & b

Ans: D

QUESTION: What is OP?

#include <iostream>
using namespace std;
class rect
{
int x, y;
public:
void val (int, int);
int area ()
{
return (x * y);
}
};
void rect::val (int a, int b)
{
x = a;
y = b;
}
int main ()
{
rect rect;
rect.val (3, 4);
cout << "rect area: " << rect.area();
return 0;
}

A: rect area:1

B: rect area: 12

C: rect area:24

D: none of the mentioned

Ans: B

QUESTION: Which of the following is a valid class declaration?

A: class A { int x; };
B: class B { }
C: public class A { }
D: object A { int x; };

Ans: A

QUESTION: The fields in the class in c++ program are by default

A: protected
B: private
C: public
D: none of the mentioned
Ans: B

QUESTION: Constructors are used to

A: initalize the objects


B: construct the data members
C: both a & b
D: none of the mentioned

Ans: A
QUESTION: When struct is used instead of the keyword class means, what will happen
in the program?
A: access is public by default
B: access is private by default
C: access is protected by default
D: none of the mentioned

Ans: A
QUESTION: Where does the object is created?
A: class
B: constructor
C: destructor
D: attributes

Ans: A
QUESTION: How to access the object in the class?
A: scope resolution operator
B: ternary operator
C: direct member access operator
D: none of the mentioned

Ans: C

QUESTION: Which of these following members are not accessed by using direct member
access operator?
A: public
B: private
C: protected
D: Both b & c

Ans: D
QUESTION: What is the output of the following program?

#include <iostream>
using namespace std;
class Box
{
public :
double length;
double breadth;
double height;
};
int main( )
{
Box Box1;
double volume;
Box1.height = 5;
Box1.length = 6;
Box1.breadth = 7.1;
volume = Box1.height * Box1.length * Box1.breadth;
cout << "Volume of Box1 : " << volume <<endl;
return 0;
}
A: 210
B: 213
C: 215
D: 217

Ans: B
QUESTION: Pick out the other definition of objects.
A: member of the class
B: associate of the class
C: attribute of the class
D: instance of the class

Ans: D

QUESTION: How many objects can present in a single class?


A: 1
B: 2
C: 3
D: as many as possible

Ans: D

QUESTION: What is the output of this program?


#include <iostream>
using namespace std;
class sample
{
private:
int var;
public:
void input()
{
cout << var;
}
void output()
{
cout << "Variable entered is ";
cout << var << "\n";
}
};
int main()
{
sample object;
object.input();
object.output();
object.var();
return 0;
}

A: Enter an integer 5 Variable entered is 5


B: runtime error
C: error
D: none of the mentioned

Ans: C
QUESTION: Which special character is used to mark the end of class?

A: ;

B: :

C: #

D: $

Ans: A
QUESTION: What is the output of this program?
#include <iostream>
using namespace std;
class number
{
int i;
public:
int geti();
void puti(int j);
};
int number::geti()
{
return i;
}
void number::puti(int j)
{
i = j;
}
int main()
{
number s;
s.puti(10);
cout << s.geti( );
return 0;
}

A: 10
B: 11
C: 20
D: 22

Ans: A

QUESTION: Which of the following type of class allows only one object of it to be
created?
A: Virtual class
B: Abstract class
C: Singleton class
D: Friend class

Ans: C
QUESTION: Which of the following is not a type of constructor?
A: Copy constructor
B: Friend constructor
C: Default constructor
D: Parameterized constructor
Ans: B
QUESTION: Which of the following statements is correct?
A: Base class pointer cannot point to derived class.
B: Derived class pointer cannot point to base class
C: Pointer to derived class cannot be created.
D: Pointer to base class cannot be created.

Ans: B
QUESTION: Which of the following is not the member of class
A: Static function
B: Friend function
C: Const function
D: Virtual function

Ans: B
QUESTION: 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

Ans: C

QUESTION: Which of the following term is used for a function defined inside a class?
A: Member Variable
B: Member function
C: Class function
D: Classic function

Ans: B
QUESTION: Which of the following concept of oops allows compiler to insert arguments
in a function call if it is not specified?
A: Call by value
B: Call by reference
C: Default arguments
D: Call by pointer

Ans: C
QUESTION: How many instances of an abstract class can be created?
A: 1
B: 5
C: 13
D: 0

Ans: D
QUESTION: Which of the following cannot be friend?
A: Function
B: Class
C: Object
D: Operator function

Ans: C
QUESTION: Which of the following concepts of OOPS means exposing only necessary
information to client?
A: Encapsulation
B: Abstraction
C: Data hiding
D: Data binding

Ans: C
QUESTION: Which of the following concepts provides facility of using object of one class
inside another class?
A: Encapsulation
B: Abstraction
C: Composition
D: Inheritance

Ans: C
QUESTION: How many types of polymorphisms are supported by C++?
A: 1
B: 2
C: 3
D: 4

Ans: B
QUESTION: Which of the following is an abstract data type?
A: int
B: double
C: string
D: Class

Ans: D
QUESTION: Which of the following concepts means adding new components to a
program as it runs?
A: Data hiding
B: Dynamic typing
C: Dynamic binding
D: Dynamic loading

Ans: D
QUESTION: Which of the following statement is correct?
A: A constructor is called at the time of declaration of an object
B: A constructor is called at the time of use of an object.
C: A constructor is called at the time of declaration of a class
D: A constructor is called at the time of use of a class.

Ans: A
QUESTION: Which of the following correctly describes overloading of functions?
A: Virtual polymorphism
B: Transient polymorphism
C: Ad-hoc polymorphism
D: Pseudo polymorphism

Ans: C
QUESTION: Which of the following approach is adapted by C++?
A: Top-down
B: Bottom-up
C: Right-left
D: Left-right

Ans: B
QUESTION: Which of the following is correct about function overloading?
A: The types of arguments are different
B: The order of argument is different
C: The number of argument is same.
D: Both A and B.

Ans: D
QUESTION: Which of the following is correct about class and structure?
A: class can have member functions while structure cannot
B: class data members are public by default while that of structure are private
C: Pointer to structure or classes cannot be declared.
D: class data members are private by default while that of structure are public by default.

Ans: D
QUESTION: Which of the following concepts means wrapping up of data and functions
together?
A: Abstraction
B: Encapsulation
C: Inheritance
D: Polymorphism
Ans: B
QUESTION: Which of the following concepts means waiting until runtime to determine
which function to call?
A: Data hiding
B: Dynamic casting
C: Dynamic binding
D: Dynamic loading

Ans: C
QUESTION: Which of the following operator is overloaded for object cout?

A: >>
B: <<
C: +
D: =

Ans: B

QUESTION: Which of the following is the correct class of the object cout?
A: iostream
B: istream
C: ostream
D: ifstream

Ans: C
QUESTION: Which of the following cannot be used with the keyword virtual?
A: class
B: member functions
C: constructor
D: destructor

Ans: C
QUESTION: Which of the following problem causes an exception?

A: Missing semicolon in statement in main().


B: A problem in calling function
C: A syntax error
D: A run-time error.

Ans: D

QUESTION: Which one of the following options is correct about the statement given
below? The compiler checks the type of reference in the object and not the type of object.
A: Inheritance
B: Polymorphism
C: Abstraction
D: Encapsulation

Ans: B
QUESTION: What will be the output of following program?

#include<iostream.h>
void main()
{
float x;
x=(float)9/2;
cout<<x;
}

A: 4.5
B: 4.0
C: 4
D: 5

Ans: A

QUESTION: The term __________ means the ability to take many forms.
A: Inheritance
B: Polymorphism
C: Member function
D: Encapsulation

Ans: B
QUESTION: Runtime polymorphism is achieved by
A: Friend function
B: Virtual function
C: Operator overloading
D: Function overloading

Ans: B
QUESTION: Access to private data
A: Restricted to methods of the same class
B: Restricted to methods of other classes
C: Available to methods of the same class and other classes
D: Not an issue because the program will not compile
Ans: B
QUESTION: Additional information sent when an exception is thrown may be placed in
A: The throw keyword
B: The function that caused the error
C: The catch block
D: An object of the exception class

Ans: C
QUESTION: A static data member is given a value
A: Within the class definition
B: Outside the class definition
C: When the program is executed
D: Never

Ans: D
QUESTION: In a class specifier ,data or function designated private are accessible
A: To any function in the program
B: Only if you the password
C: To member functions of that class
D: Only to public members of the class

Ans: C
QUESTION: Which of the statements are true ?
I. Function overloading is done at compile time.
II. Protected members are accessible to the member of derived class.
III. A derived class inherits constructors and destructors.
IV. A friend function can be called like a normal function.
V. Nested class is a derived class.
A: I, II, III
B: II, III, V
C: III, IV, V
D: I, II, IV

Ans: D
QUESTION: At which point of time a variable comes into existence in memory is
determined by its :-
A: Scope
B: Storage class
C: Data type
D: All of the above

Ans: B
QUESTION: When the compiler cannot differentiate between two overloaded
constructors, they are called
A: Overloaded
B: Destructed
C: Ambiguous
D: Dubious

Ans: C
QUESTION: The actual source code for implementing a template function is created
when
A: The declaration of function appears
B: The function is invoked
C: The definition of the function appears
D: None of the above

Ans: B
QUESTION: Usually a pure virtual function

A: Has complete function body


B: Will never be called
C: Will be called only to delete an object
D: Is defined only in derived class

Ans: D

QUESTION: Which of the following is the valid class declaration header for the derived
class d with base classes b1 and b2?
A: class d : public b1, public b2
B: class d : class b1, class b2
C: class d : public b1, b2
D: class d : b1, b2

Ans: A
QUESTION: The process of extracting the relevant attributes of an object is known as
A: Polymorphism
B: Inheritence
C: Abstraction
D: Data hiding

Ans: B
QUESTION: What features make C++ so powerful ?
A: Easy implementation
B: Reusing old code
C: Reusing old code
D: All of the above
Ans: D
QUESTION: The keyword friend does not appear in
A: The class allowing access to another class
B: The class desiring access to another class
C: The private section of a class
D: The public section of a class

Ans: C
QUESTION: Exception handling is targeted at
A: Run-time error
B: Compile time error
C: Logical error
D: All of the above

Ans: A
QUESTION: To access the public function fbase() in the base class, a statement in a
derived class function fder() uses the statement.fbase();
A: fbase();
B: fder();
C: base::fbase();
D: der::fder();

Ans: A
QUESTION: In which case is it mandatory to provide a destructor in a class?
A: Almost in every class
B: Class for which two or more than two objects will be created
C: Class for which copy constructor is defined
D: Class whose objects will be created dynamically

Ans: D
QUESTION: _________ members of a base class are never accessible to a derived class.
A: Public
B: Private
C: Protected
D: A,B and C

Ans: B
QUESTION: What is the error in the following code?
class t
{
virtual void print();
}
A: No error
B: Function print() should be declared as static.
C: Function print() should be defined.
D: Class t should contain data members.

Ans: A
QUESTION: It is possible to declare as a friend
A: A member function
B: A global function
C: A class
D: All of the above

Ans: D
QUESTION: What is the output of the following code

char symbol[3]={„a‟,„b‟,„c‟};
for (int index=0; index<3; index++)
cout << symbol [index];

A: a b c
B: “abc”
C: abc
D: „abc‟

Ans: C

QUESTION: Identify the operator that is NOT used with pointers


A: ->
B: &
C: *
D: >>

Ans: D
QUESTION: Overloading a postfix increment operator by means of a member function
takes
A: No argument
B: One argument
C: Two arguments
D: Three arguments

Ans: A
QUESTION: Which of the following is not the characteristic of constructor?
A: They should be declared in the public section.
B: They do not have return type.
C: They can not be inherited.
D: They can be virtual.

Ans: D
QUESTION: You separated a derived class name from its access specifier with
A: A colon
B: Two colons
C: Atleast one space
D: A semi colon

Ans: B
QUESTION: The members of a class by default are
A: Public
B: Protected
C: Private
D: Mandatory to specify

Ans: C
QUESTION: The type of value that a function sends back to the function that calls it is
known as its _____
A: type
B: return value
C: reference data
D: sentinel

Ans: B
QUESTION: Which of the following are never inherited?
A: public data members
B: constructor functions
C: void functions
D: overloaded + operators

Ans: B
QUESTION: A function's purpose is to print customer data. Which of the following is the
best name for this function?
A: pcd(). It's short for "print customer data" and takes few keystrokes
B: Printcustomerdata(). It states everything the function will do
C: printCustomer(). It states the function's purpose and is easy to read
D: lastFunction(). It is the final function called in most programs, and this name identifies the
function's timing

Ans: C
QUESTION: The function strcmp("Jose", "JOSE") will return _____
A: - 1
B: 0
C: 1
D: null

Ans: C
QUESTION: how many types of expression in c++.
A: 5
B: 6
C: 7
D: 8

Ans: C

EXPLANATION: here are 7 types of expressions in c++. 1) Constant expression 2) Integer


expression 3) Float expression 4) Pointer expression 5) Logical expression 6) Relational
expression 7) Bitwise expression

QUESTION: Dragons have wings like a bird and scales like a lizard. In object oriented
verabage, we would say this is an example of ?
A: Multilevel Inheritance
B: Polymorphism
C: Multiple inheritance
D: Aggregation

Ans: C
QUESTION: Which of the following is false about object oriented ?
A: is block structured language
B: is not a block structured language
C: aids in object oriented programming
D: is an extension of C

Ans: A
QUESTION: Polymorphism is implemented through which mechanism in C++ ?
A: Late Interpretation
B: Late Binding
C: Early Binding
D: Overloading

Ans: C
QUESTION: Which of the following is not an extension associated during the creation of
a C++ program?
A: .cpp
B: .exe
C: .jpg
D: .bak

Ans: C
QUESTION: Why every program begins with main () in C++ ?
A: As this is from the compiler knows that program execution actually starts.
B: Because its name is main
C: Both A and B
D: None of above

Ans: A

EXPLANATION: As this is from the compiler knows that program execution

QUESTION: The wrapping up of data and functions into a single unit is called ?
A: Inheritance
B: Polymorphism
C: Encapsulation
D: Overloading

Ans: C
QUESTION: The process by which objects of one class acquire the attributes of another
class is known as............?
A: Inheritance
B: Polymorphism
C: Data Abstraction
D: Binding

Ans: A
QUESTION: The technique by which objects communicate with each other is called ?
A: information passing
B: function passing
C: message passing
D: none of above

Ans: B
QUESTION: Which of the following is false?
A: Variable has scope & visibility
B: Variables having scope may not be visible
C: Variables having visibility may not have scope
D: None of these

Ans: C
QUESTION: For a method to be an interface between the outside world and a class,it has
to be declared ?
A: private
B: protected
C: public
D: external

Ans: C
QUESTION: In C++, a function contained within the class is called ?
A: member function
B: a class function
C: a method
D: none of above

Ans: A
QUESTION: classes are useful because they
A: are removed from memory when not in use
B: permit data to be hidden from other classes
C: bring together all aspects of an entity in one place
D: can closely model objects in the real world

Ans: B
QUESTION: The public files in a class library usually contain ?
A: Constant definitions
B: member function definitions
C: class declarations
D: variable definition

Ans: C
QUESTION: class cannot be ?
A: Virtual
B: Generic
C: Inline
D: Friend

Ans: C
QUESTION: Objects of the same class share the values of ...... while they maintain
separate values for ........ .
A: Static variables, non static variables
B: Non static variables, static variables
C: Global variables, static variables
D: Static variables, register variables

Ans: A
QUESTION: Which of the following keywords cannot appear inside a class definition ?
A: friend
B: static
C: template
D: virtual
Ans: C
QUESTION: Which of the following is false with respect to inheritance?
A: When a base class is privately inherited,public members of the base class become private
members of the derived class
B: When a base class is publicly inherited,public members of the base class becomes public
members of derived class
C: When a base class is privately inherited,a private member of base class becomes private
member of derived class
D: When a base class is publicly inherited protected members of base class becomes protected
members of derived class

Ans: C
QUESTION: Which of the following is/are false
A: Inheritance is deriving new class from existing class
B: In an inheritance, all data and function members of base class are derived by derived class
C: We can specify which data and function members of base class will be inherited by derived
class
D: We can add new functions to derived class without recompiling the base class

Ans: B
QUESTION: A base class will offer
A: offer more specific objects than its derived classes
B: correspond to something in the rest world
C: behave badly when the chops are down
D: be a generalized version of its derived classes

Ans: D
QUESTION: If a base class member access is public, and an inherited class accesses
specifier is private, which of the following statement is true ?
A: The base class member can be accessed by derived class objects
B: The base class members cannot be accessed by the derived class members
C: The derived class members can be accessed by the base class objects
D: None of above

Ans: A
QUESTION: Choose most appropriate statement
A: An abstract base class can have pure virtual destructor
B: An abstract base class can have only virtual destructor
C: An abstract base class can have non virtual destructor
D: An abstract base class cannot have destructor

Ans: D
QUESTION: The conversion from basic data to class type can be done by .......
A: Writing constructor
B: Is not possible
C: overloaded casting operator
D: object of a class

Ans: A
QUESTION: When a base class pointer points to derived class object?
A: It can access only base class members
B: It can access only derived class members
C: Both base class & derived class members
D: None

Ans: A
QUESTION: 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

Ans: C
QUESTION: The signature of a function is its ..... ?
A: Function code
B: Prototype
C: Call
D: Parameter list

Ans: B
QUESTION: What is true about inline functions ?
A: It's a compulsion on the compiler to make function inline
B: It's a request to the compiler to make te function inline
C: It's the indication to the compiler that the function is recursive
D: It's the indication to the compiler that the function is member function

Ans: B
QUESTION: Which member function of class cannot modify its objects attributes ?
A: friend functions
B: Private member functions
C: Constant member functions
D: Static member functions

Ans: C
QUESTION: Which of the following parameter passing mechanism is/are supported by
C++ but not in C?
A: Pass by value
B: Pass by reference
C: Pass by value result
D: All of the above

Ans: B
QUESTION: Which of the following type of function is an ideal candidate for being
declared inline ?
A: A function that is small and is not called frequently
B A function that is small and is called frequently
C: A function that is not small and is not called frequently
D: A function that is not small and is called frequently

Ans: B
QUESTION: One of the disadvantage of pass by reference is that the called function may
inadvertently corrupt the called data.This is avoided by ?
A: passing pointers
B: declaring the formal parameters constant
C: declaring the actual parameters constant
D: all of above

Ans: B
QUESTION: The library function exit() causes an exit from ?
A: The loop in which it occurs
B: The block in which it occurs
C: The function in which it occurs
D: The program in which it occurs

Ans: D
QUESTION: The getche() library function
A: returns a character when any key is pressed
B: returns a character when ENTER is pressed
C: displays a character on the screen when any key is pressed
D: does not display a character on the screen

Ans: A
QUESTION: When an argument is passed by reference
A: a variable is created in function to hold the argument value
B: the function cannot access the argument value
C: a temporary variable is created in the calling program to hold arguments value
D: None of these

Ans: A
QUESTION: Overloaded function
A: are a group of functions,with the same value
B: all have the same number and types of arguments
C: make life simpler for programmers
D: may fail unexpectedly due to stress
Ans: C
QUESTION: A static function
A: should be called when an object is destroyed
B: is closely connected with an individual object of a class
C: can be called using the class name and function
D: is used when a dummy object must be created

Ans: C
QUESTION: Dividing a program into functions
A: is the key to object oriented programming
B: makes the program easier to conceptualize
C: makes the program run faster
D: both (B) and (C)

Ans: C
QUESTION: Static Member function
A: can access any other member function & member variables
B: can access only static member variables & member functions
C: can be only called through object of the class
D: Returns only static data

Ans: B
QUESTION: Which of the following statement is correct?
A: C++ enables to define functions that take constants as an argument.
B: We cannot change the argument of the function that that are declared as constant.
C: Both A and B.
D: We cannot use the constant while defining the function.

Ans: C
QUESTION: Which of the following statement is correct?
A: Overloaded functions can have at most one default argument.
B: An overloaded function cannot have default argument.
C: All arguments of an overloaded function can be default.
D: A function if overloaded more than once cannot have default argument.

Ans: C
QUESTION: Which of the following statement is correct?
A: Constructors can have default parameters.
B: Constructors cannot have default parameters.
C: Constructors cannot have more than one default parameter.
D: Constructors can have at most five default parameters.

Ans: A
QUESTION: Which of the following function declaration is/are incorrect?
A: int Sum(int a, int b = 2, int c = 3);
B: int Sum(int a = 5, int b);
C: int Sum(int a = 0, int b, int c = 3);
D: Both B and C are incorrect.
E: All are correct.

Ans: E
QUESTION: You can use C++ as a procedural, as well as an object-oriented, language

A: TRUE
B: FALSE

Ans: A

QUESTION: The address of a variable temp of type float is


A: *temp
B: &temp
C: float& temp
D: float temp&

Ans: B
QUESTION: What is the output of the following code

char symbol[3]={„a‟,„b‟,„c‟};
for (int index=0; index<3; index++)
cout << symbol [index];

A: a b c
B: “abc”
C: abc
D: „abc‟

Ans: C
QUESTION: The process of building new classes from existing one is called ______.
A: Polymorphism
B: Structure
C: Inheritance
D: Cascading

Ans: C
QUESTION: If a class C is derived from class B, which is derived from class A, all
through public inheritance, then a class C member function can access
A: protected and public data only in C and B.
B: protected and public data only in C.
C: private data in A and B.
D: protected data in A and B.

Ans: D
QUESTION: If the variable count exceeds 100, a single statement that prints “Too many”
is
A: if (count<100) cout << “Too many”;
B: if (count>100) cout >> “Too many”;
C: if (count>100) cout << “Too many”;
D: None of these.

Ans: C
QUESTION: Overloading the function operator
A: requires a class with an overloaded operator.
B: requires a class with an overloaded [ ] operator.
C: allows you to create objects that act syntactically like functions.
D: usually make use of a constructor that takes arguments.

Ans: A
QUESTION: In C++, the range of signed integer type variable is ________
A: ) 0 to 216
B: − 215 to 215 − 1
C: − 27 to 27 − 1
D: 0 to 28

Ans: B
QUESTION: The major goal of inheritance in c++ is:
A: To facilitate the conversion of data types.
B: To help modular programming.
C: To extend the capabilities of a class.
D: To hide the details of base class.

Ans: C
QUESTION: Consider the following class definitions: class a

{
};
class b: protected a
{
};
What happens when we try to compile this class?

A: Will not compile because class body of a is not defined.


B: Will not compile because class body of b is not defined.
C: Will not compile because class a is not public inherited.
D: Will compile successfully.

Ans: D

QUESTION: Which of the following statements are true in c++?


A: Classes can not have data as public members.
B: Structures can not have functions as members.
C: Class members are public by default.
D: None of these

Ans: B

Q1. The use of the break statement in a switch statement is


A) Optional
B) compulsory
C) to check an error
D) None of the above

Ans: A) Optional
Q2. To be called object-oriented, a programming language must allow________
A) functions that return only a single value
B) #include files
C) inheritance
D) All of the above

Ans: C) inheritance
Q3. Which is not object oriented concept?
A) Inheritance
B) Polymorphism
C) Class
D) Variable

Ans: D) Variable
Q4.The operator that releases previously allocated memory is ___
A) release
B) return
C) new
D) delete

Ans: D) delete
Q5. Inheritance occurs when a class adopts all the traits of ________
A) an object
B) a parent class
C) a variable
D) a function

Ans: B) a parent class


Q6. Encapsulation means____________
A) Binding of data and code together
B) To inherit properties of base class
C) To reduce code length
D) To define global variable

Ans: A) Binding of data and code together


Q7. To derive new class from existing class is known as ________
A) Inheritance
B) Polymorphism
C) Object
D) None of these

Ans: A) Inheritance
Q8. Which of the following statement is correct?
A) Class is an instance of object.
B) Object is an instance of a class.
C) Class is an instance of data type.
D) Object is an instance of data type

Ans: B) Object is an instance of a class.


Q9. An object consists of -----
A) State
B) Behavior
C) Both A and B
D) None of these

Ans: C) Both A and B


Q10. Which of the following provides a reuse mechanism?
A) Inheritance
B) Polymorphism
C) Abstraction
D) Encapsulation

Ans: A) Inheritance
Q11. Which of the following is correct about class and structure?
A) Class can have member functions while structure cannot
B) Class data members are public by default while that of structure are private
C) Pointer to structure or classes cannot be declared.
D) Class data members are private by default while that of structure are public by default.
Ans: D) Class data members are private by default while that of structure are public by default.
Q12. The major goal of inheritance in c++ is:
A) To facilitate the conversion of data types.
B) To help modular programming.
C) To extend the capabilities of a class.
D) To hide the details of base class.

Ans: C) To extend the capabilities of a class.


Q13. Class is __________
A) Built in data type
B) User defined data type
C) Both a& b
D) None of these

Ans: B) User defined data type


Q14. The break statement causes an exit
A) from the innermost loop only.
B) only from the innermost switch.
C) from all loops & switches.
D) from the innermost loop or switch.

Ans: D) from the innermost loop or switch.


Q15. Within a switch statement
A) continue can be used but break cannot be used
B) continue cannot be used but break can be used
C) Both continue and break can be used
D) Neither continue nor break can be used

Ans: B) continue cannot be used but break can be used


Q16. It is possible to declare as a friend
A) a member function
B) a global function
C) a class
D) all of the above

Ans: D) all of the above


Q17. A library function exit() causes an exit from
A) the loop in which it occurs
B) the block in which it occurs
C) the function in which it occurs
D) the program in which it occurs

Ans: D) the program in which it occurs


Q20. Which of the following statement is valid?
A) We can create new C++ operators.
B) We can change the precedence of the C++ operators.
C) We can change the associativity of the C++ operators.
D) We cannot change operator templates.

Ans: D) We cannot change operator templates.


Q21. Which of the following statements is correct? (2 Marks)
1. A reference is not a constant pointer.
2. A referenced is automatically de-referenced.
A. Only 1 is correct.
B. Only 2 is correct.
C. Both 1 and 2 are correct.
D. Both 1 and 2 are incorrect.

Ans: B
Q22. Which of the following statement is correct?
A. Once a reference variable has been defined to refer to a particular variable it can refer to any other variable.
B. A reference is indicated by using && operator.
C. Once a reference variable has been defined to refer to a particular variable it cannot refer to any other variable
D. A reference can be declared beforehand and initialized later.

Ans: C
Q23. Which of the following statement is correct?
A) A referenced has to be de-referenced to access a value.
B) A referenced does not need to be de-referenced to access a value.
C) A referenced has to be double de-referenced to access a value.
D) Whether a reference should be de-referenced or not depends on the type of the reference.

Ans: Option B
Q24. reference is like a _____.
A) pointer
B) structure
C) macro
D) enum

Ans: A
Q25. Which of the following statement is correct?
A) A reference is declared using * operator.
B) Once a reference variable has been defined to refer to a particular variable it can refer to any other variable.
C) A reference must always be initialized within classes.
D) A variable can have multiple references.

Ans: D
Q26. Identify the incorrect statement
A) reference is the alternate name of the object
B) A reference value once defined can be reassigned
C) A reference value once defined cannot be reassigned
D) none of the mentioned

Ans: C
Q27. What does a reference provide?
A) Alternate name for the class
B) Alternate name for the variable
C) Alternate name for the pointer
D) none of the mentioned

Ans: B
Q28. Which of the following statements is correct?
1. 1. Once a reference variable has been defined to refer to a particular variable it can refer to any other variable
2. 2. A reference is not a constant pointer.
A. Only 1 is correct.
B. Only 2 is correct.
C. Both 1 and 2 are correct.
D. Both 1 and 2 are incorrect.

Ans: D
Q29. Which of the following statement is correct?
A) The order of the default argument will be right to left.
B) The order of the default argument will be left to right.
C) The order of the default argument will be alternate
D) The order of the default argument will be random.

Ans: A
Q30. Which of the following statement is correct?
A) In C the global version of a variable cannot be accessed from within the inner block.
B) In C the global version of a variable can be accessed from within the inner block.
C) C introduces the scope resolution operator to access global variable.
D) All of these

Ans: A
Q30. Which of the following statement is correct?
A) In C the global version of a variable cannot be accessed from within the inner block.
B) In C the global version of a variable can be accessed from within the inner block.
C) C introduces the scope resolution operator to access global variable.
D) All of these

Ans: A
Q31. What is dynamic initialization of variables in C++?
A) In C ++ you have to declare variable anywhere.
B) C++ allows initialization of the variable at runtime.
C) C++ allows initialization of the variable at compile time
D) All of these

Ans: B
Q32. Which operator is having right to left associativity out of the following operators?
A) Array subscripting
B) Function call
C) Addition and subtraction
D) Type cast

Ans: D
Q33. Which of the following is the functionality of „Data Abstraction‟?
A) Reduce Complexity
B) Binds together code and data
C) Parallelism
D) None of the mentioned

Ans: A
Q34. Which of the following mechanisms is/are provided by Object Oriented Language to implement Obje
A) Encapsulation
B) Inheritance
C) Polymorphism
D) All of the mentioned

Ans: D
Q35. Which of the these is the functionality of „Encapsulation‟?
A) Binds together code and data
B) Using single interface for general class of actions.
C) Reduce Complexity
D) All of the mentioned

Ans: A
Q36. Which of the following is a mechanism by which object acquires the properties of another object?
A) Encapsulation
B) Abstraction
C) Inheritance
D) Polymorphism

Ans: C
Q37. The process of building new classes from existing one is called ______.
A) Polymorphism
B) Structure
C) Inheritance
D) Cascading

Ans: C
Q38. Which of the following is NOT a key component of object oriented programming?
A) Inheritance
B) Encapsulation
C) Polymorphism
D) Parallelism

Ans:: D
Q39. Which of these is TRUE of the relationship between objects and classes?
A) A class is an instance of an object.
B) An object is the ancestor of its subclass.
C) An object is an instance of a class.
D) An object is the descendant of its superclass.

Ans: C
Q40. The members of a class, by default, are
A) public
B) protected
C) private
D) mandatory to specify

Ans: C
Q41. Which of the following is the functionality of „Data Abstraction‟?
A) Reduce Complexity
B) Binds together code and data
C) Parallelism
D) None of the mentioned

Ans: A
Q42. Which of the following mechanisms is/are provided by Object Oriented Language to implement Obje
A) Encapsulation
B) Inheritance
C) Polymorphism
D) All of the mentioned

Ans: D
Q43. Which of the these is the functionality of „Encapsulation‟?
A) Binds together code and data
B) Using single interface for general class of actions.
C) Reduce Complexity
D) All of the mentioned

Ans: A
Q . In access control in a protected derivation, visibility modes will change as follows:
A) private, public and protected become protected
B) only public becomes protected.
C) public and protected become protected.
D) only private becomes protected.

Ans:C
Q44. A struct is the same as a class except that
A) there are no member functions.
B) all members are public.
C) cannot be used in inheritance hierarchy.
D) it does have a this pointer.

Ans: C
Q45. Which of the following statement is correct?
A) Class is an instance of object.
B) Object is an instance of a class.
C) Class is an instance of data type.
D) Object is an instance of data type

Ans: B
Q46. Which of the following header file includes definition of cin and cout?
A) iostream.h
B) stdio.h
C) alloc.h
D) inputoutout.h

Ans: A
Q47. Which of the following is correct about class and structure?
A) Class can have member functions while structure cannot
B) Class data members are public by default while that of structure are private
C) Pointer to structure or classes cannot be declared.
D) Class data members are private by default while that of structure are public by default.

Ans: D
Q48. Which of the following two entities (reading from Left to Right) can be connected by the dot operator
A) A class member and a class object.
B) A class object and a class.
C) A class and a member of that class.
D) A class object and a member of that class.

Ans: D
Q49. Which of the following can access private data members or member functions of a class?
A) Any function in the program.
B) All global functions in the program
C) Any member function of that class
D) Only public member functions of that class.

Ans: C
Q50. Which of the following type of data member can be shared by all instances of its class?
A) Public
B) Protected
C) Static
D) Inherited

Ans: C
Q51. Which of the following is the only technical difference between structures and classes in C++?
A) Member function and data are by default protected in structures but private in classes.
B) Member function and data are by default private in structures but public in classes.
C) Member function and data are by default public in structures but private in classes.
D) Member function and data are by default public in structures but protected in classes.

Ans: C
Q52. Which of the following concepts of OOPS means exposing only necessary information to client?
A) encapsulation
B) abstraction
C) data hiding
D) Data binding

Ans:C
Q53. Which type of class has only one unique value for all the objects of that same class?
A) This
B) Friend
C) static
D) Both a and b

Ans: C
Q54. In a class definition, data or functions designated private are accessible.
A) Outside the class
B) Outside the class, only if you know the password.
C) To member functions of that class.
D) Only to public members of the class.

Ans: C
Q55. Classes are useful because they
A) Can closely model objects in the real world.
B) Permit data to be hidden from other classes.
C) Bring together all aspects of an entity in one place.
D) Options A, B and C
Ans: D
Q56. The extraction operator (>>) stops reading a string when it encounters a space.
A) TRUE
B) FALSE

Ans: A
Q57. cout is a/an __________
A) operator
B) Function
C) object
D) Macro

Ans: C
Q58. How many objects can be created by a class?
A) 1
B) 2
C) 3
D) As Many as required

Ans: D
Q59. Default return type of C++ main( ) is .....
A) float
B) void
C) int
D) Pointer

Ans: C
Q60. Attributes of a class are called as ........
A) Member functions
B) Data members
C) Objects
D) All of above

Ans: B
Q61. Which of the following statements regarding inline functions is correct?
A) It speeds up execution
B) It slows down execution
C) It increases the code size.
D) Both A and C.

Ans: A
Q62. What is the meaning of reference variable?
A) It is call by reference technique to declare variable
B) It is call by value technique to declare variable
C) Technique to create multiple names to one variable
D) It provides alias for previously defined variable

Ans: D
Q63. How many access specifiers are there in C++?
A) 1
B) 2
C) 3
D) 4

Ans: C
Q64. How many types of polymorphisms are supported by C++?
A) 1
B) 2
C) 3
D) 4

Ans: B
Q65. Which one of the following is not a valid reserved keyword in C++?
A) virtual
B) public
C) implicit
D) private

Ans: C
Q66. Does Class acquire space in memory?
A) True
B) False

Ans: B
Q67. In object-oriented programming more importance is given to ------
A) Function
B) Procedure
C) Data
D) All of above

Ans: C
Q68. Which type is best suited to represent the logical values?
A) integer
B) boolean
C) character
D) all of the mentioned

Ans: B
Q69. Which of the following statements is false?
A) Every C++ program must have a main().
B) In C++, white spaces and carriage returns are ignored by the compiler.
C) C++ statements terminate with semicolon.
D) main() terminates with semicolon.

Ans: D
Q70. Which of the following feature of procedure oriented program is false?
A) Makes use of bottom up approach
B) Functions share global data
C) The most fundamental unit of program is function
D) All of these

Ans: A
Q71. Which of the following feature of object oriented program is false?
A) Data and Functions can be added easily
B) Data can be hidden from outside world
C) Object can communicate with each other
D) The focus is on procedures

Ans: D
Q72. Which of the following approach is adopted in C++?
A) Top down
B) Bottom up
C) Horizontal
D) Vertical

Ans: B
Q73. If particular software can be used in some other application than the one for which it is created then
A) data binding
B) data reusability
C) data encapsulation
D) none of these

Ans: B
Q74. Which of the following data type does not return anything?
A) int
B) short
C) long
D) void

Ans: D
Q75. Which one is not a correct variable type in C++?
A. float
B. real
C. int
D. double

Answer.B
Q76. An expression A.B in C++ means ____
A. A is member of object B
B. B is member of Object A
C. Product of A and B
D. None of these

Answer.B
Q77. A C++ code line ends with ___
A. A Semicolon (;)
B. A Fullstop(.)
C. A Comma (,)
D. A Slash (/)

Answer.A
Q78. You can use C++ as ____________
A. A procedural language
B. As an object-oriented language
C. Both A & B
D. None of These

Answer.C
Q79. The use of the break statement in a switch statement is
A. optional
B. compulsory
C. to check an error
D. None of the above

Answer.A
Q80. To be called object-oriented, a programming language must allow________
A. functions that return only a single value
B. #include files
C. inheritance
D. All of the above

Answer.C
Q81. Which of the following statements allows the user to enter data at the keyboard?
A. cin << input
B. cin >> input
C. cout << input
D. cout >> input

Answer.B
Q82. What does C++ append to the end of a string literal constant?
A. a space( )
B. a number sign (#)
C. an asterisk (*)
D. a null character(„\0‟)

Answer.D
Q83. An array name is a _____
A. subscript
B. formal parameter
C. memory address
D. prototype

Answer.C
Q84. To enter a single line comment in a C++ program, you begin the comment with _____
A. **
B. &&
C. //
D. \\

Answer.C

Q85. The compiler converts your C++ instructions into _____


A. edited code
B. object code
C. source code
D. translated code

Answer.B
Q86. The scope resolution operator is
A. a comma(,)
B. a semicolon(;)
C. a colon(:)
D. two colons(::)

Answer.D
Q Which is not object oriented concept?
A. Inheritance
B. Polymorphism
C. Class
D. Variable

Answer.D
Q Which of the following is the inequality operator?
A.

B. =
C. ==
D. -->
Answer.A
Q The operator that releases previously allocated memory is ___
A. release
B. return
C. new
D. delete

Answer.D
Q Which of the following statements will display the word "Hello" on the computer screen?
A. cin << "Hello";
B. cin >> "Hello";
C. cout << "Hello";
D. cout >> "Hello";

Answer.C
Q The preprocessor directive always starts with the symbol
A. %
B. #
C. &
D. “”

Answer.B
Q The last statement in a function is often ____
A. return
B. goodbye
C. finish
D. Endfunction

Answer.A
Q Which of the following is the insertion operator?
A. >>
B. <<
C. //
D. /*

Answer.A
Answer.B
Q Inheritance occurs when a class adopts all the traits of ________
A. an object
B. a parent class
C. a variable
D. a function

Answer.B
Q In c++ declare integer variable and accepting values from user which format specifier is used.
A. %d
B. %f
C. %c
D. None of these

Answer.D
Q Which of the following is not a keyword?
A. continue
B. default
C. volatile
D. main

Answer.D
Q Which reference modifier is used to define reference variable?
A. &
B. #
C. *
D. None of these

Answer.A
Q What will be output of following program?

#include<iostream>
using namespacestd;
int main ()
{
int a,b;
int result;
a=5;
b=2;
a=a+1;
result=a-b;
cout<<result;
return 0;
}

A. 4
B. 3
C. 2
D.5

Answer.A

Q What will be output of following program?

#include <iostream>
using namespace std;
int main ()
{
int a, b=3;
a = b;
a+=2;
cout << a;
return 0;
}

A. 5
B. 3
C. 2
D. None of these

Answer.A

Q What will be output of following program?

#include <iostream>
using namespace std;
void swap(int &a, int &b);
int main()
{
int a=5,b=10;
swap(a, b);
cout << "In main " << a << b;
return 0;
}
void swap(int &a, int &b)
{
int temp;
temp = a;
a = b;
b = temp;
cout << "In swap " << a << b;
}
A. In swap 105 In main 105
B. In swap 105 In main 510
C. In swap 510 In main 105
D. none of the mentioned

Answer.A

You might also like