Oops Using C++ One Mark Questions
Oops Using C++ One Mark Questions
Oops Using C++ One Mark Questions
1. High Level Languages like C, Basic, Fortran are also known as Procedural
Languages
a) True
b) False
10. ______________ is a header file used in C++ that handles input and output
functions.
a) stdio.h
b) iostream.h
c) conio.h
d) string.h
11. Break statement takes the control out of the switch statement.
a) True
b) False
14 All the parts of for Loop like Loop initialization, Loop termination, condition
statement for the next iteration are all included in one statement.
a) True
b) False
17 The index number starts with _____________ and the last index number of
an array of size n will be _______________
a) 0, n-1
b) 1,n
c) 0, n+1
d) 0,n
19 )An array with the declaration int a[4][5] can store _____________ numbers
a) 20
b) 9
c) 21
d) 19
20)String stores an extra _________character for every string to mark the end of
the
string
a) null
b) ‘\0’
c) /0
d) None of these
22) ____________ member function of cin allows user to input embedded blanks
and linefeed within the string
a) get
b) getline
c) gets
d) None of these
23) If there are no arguments in a function ____________should be specified
within the brackets.
a) void
b) int
c) ;
d) None of these
24) More than one user defined functions can have same name and perform
different operations. This feature of c++ is known as ________________.
a) Function overloading
b) operator overloading
c) overloading
d) None of these
29. __________ function are external function that can access the private data
members of a class.
a) Friend
b) Protected
c) getdata()
d) None of these
30) __________member function invoked automatically whenever the objects is
destroyed or expired
a) destructor ~
b) constructor ~
31) The data and functions are ____________by default, if no keyword can be
omitted.
a) Public
b) Private
c) Protected
33) __________data member of the class that is common for all the objects of
the class and are accessible for the class.
a) Static
b) Dynamic
c) Private
d) Public
34) Dot operator, scope resolution (::) operator, conditional operator (?:) can be
overloaded.
a) True
b) False
36) Member Function of a class can be defined outside the class using
___________ operator along with the class name.
a) binary
b) scope resolution (::) operator
c) relational
d) overloading
37) ____________ function can act as a bridge between two classes using a
single function to operate on multiple data type.
a) Friend
b) Operator
c) Public
d) Protected
38)Several operators such as dot operator, scope resolution (::), conditional
operator (?:) etc. can be overloaded
a)True
b)False
Two Marks
3) C++ program file is saved with an ___________ extension. The source code
has to be converted to an __________code with ____________extension is
created.
a) .cpp, object code, .obj
b) .c, source code, .link
c) .cpp, object code, .exe
d) All of the above
5)The For Statements can have multiple initialization and increment and
decrement statements:---.
For(I=0;j=0;I<=n;j++,I++)
{
statements;
}
a) true
b) false
6)char name[20]
name=”Good Morning”;
This is True or False
a) True
b) False
13. Arithmetic operators like +, * etc and relational operators like <, > etc. are
some example of ______________ Operator.
a) binary
b) Unary
14. Unary operator should have return value as ___________ and are
implemented with ____________ arguments.
a) Class data type, No
b) void, default
c) int data type, actual
d) binary no, formal
15. The derived class can have multiple parents is known as _________
inheritance and ____________inheritance where another class is derived from
the derived class
a) Multiple, Multilevel
b) Multilevel, Multiple
c) Hybrid, Hierarchical
d) None of these
16_______ are variables that stores the addressing of another variable . The
pointer variable are defined by prefixing a ___________ sign.
a) Pointer, *
b) Automatic, $
c) Local, &
d) Global, *
17. _____________ function request the memory of specifies size from the
system during runtime and return the address of the memory location of the first
element in the array.
a) malloc
b) calloc
c) deallocate
d) All of the above
19. In Multiple inheritance if the both parent class ( A & B) have same function
and child class (C) does not have any function then which function is called
a) Class A
b) Class B
c) have to be specified explicitly
d) No function will be called.
20 Two Child classes B and C are derived publicly from A. Class D is derived
from both B & C publicly. When the grand child class D tries to access the
member a of the parent class A. The ambiguity aries____________ class use to
solve this ambiguity.
a) Virtual base class
b) Scope resolution operator
Four Marks
2)Match Making
1 Syntax Error a) This errors occurs due to the flow in the logic
2 Logical Error b) This error occurs due to mistake in writing the
syntax of
a c++ Statement
3 Linker Error c) occurs if the programs encounter division by
zero
4 Runtime Error d) occurs when the files during linking are missing or
misspelt.
a) 1-b, 2-a, 3-d, 4-c
b) 1-a, 2-b, 3-c, 4-d
c) 1-b, 2-c, 3-a, 4-d
d) 1-a, 2-d, 3-c, 4-b
4 ) Match Making
1 Break a)function takes the control out of the program.
2 Exit b)statement transfer the control to the next statement after the loop and all
the remaining statements in the loop are skipped.
3 Continue c) Statement is used to take the control to the next
iteration of the loop.
4 Goto d) it takes the control to a particular statement.
5)Match Making
6)Match Maing
a)Automatic variable 1)Variables created only in a function or program
block.
b)External variable 2)They can retain their values after the function
execution is over.
c)Static variable 3)They can accessed by multiple functions.
7)Data and functions in a class can have any one access specifiers;
a)public, private, protected
b)class, object, inline
c)auto, scope, resolution operator
d) All of the above
8) Match making
a) public specifier 1) data and functions can be accessed only by the
member functions of the class
b) private specifier 2) data and functions can be accessed through the
objects of the class externally from any function.
1) a-2, b-1
2) a-1, b-2
9) class A
{
protected:
int a;};
class B:public parent
}}
class C:public parent
}}
class D:public B, public C
{
public:
int f1();
return a;
}
What is the output of following code
a) Error
b) Display the value of a
c) No Error
d) Ambiguous
11. x=1
do
{
cout<<x;
x++;
}
while(x>10);
will be executed how many times.
a) 1
b) 10
c) 0
d) 9
a) One
b) OneTwo
c) Zero
d) None of these
13. cin.get(str,40,$);
will allow users to enter a maximum of ___________character which can
include embedded blanks and linefeed.
a) 38
b) 40
c) 39
d) 44
14. a) strcpy(name,”ravi”);
b) name=”ravi”;
a) valid
b) invalid
a) 12, 24
b) 30, 6
c) 14, 22
d) None of these
class Sample
{
private:
int data;
public:
sample() { data=0;
cout<<” constructor invoked” <<endl;}
~sample()
{ cout<<” Destructor invoked”;}
void display()
{
cout<<” Data = “<<data <<endl;}
};
void main()
{
sample obj1;
obj1.display();
}
a) constructor invoked
Data=0
Destructor invoked
b) data=0
constructor invoked
Destructor invoked