Está en la página 1de 14

OOPs using C++

One Mark Questions

1. High Level Languages like C, Basic, Fortran are also known as Procedural
Languages
a) True
b) False

2. The Procedural Languages focused on organized program statements into


__________________ or ________________.
a) Procedure, Functions
b) Module, OOP
c) High, Low
d) None of these

3. More than one functions had to access data ______________ variables


were used.
a) Local
b) Automatic
C) Global
d) Static

4. __________is an OOPS Language.


a) C, Pascal, Fortran
b) C++, Small Talk, Java
c) .Net, VB, Oracle
d) None of these

5_____________is a Program representation of some real-world thing.


a) Object
b) Class
c) Attributes
d) Function

6 Objects are _______________of a class


a) Instances
b) Classes
c) Attributes
d) None of these

7. _____________features allows easy modification of existing code and also


reuse
code.
a) Inheritance
b) Polymorphism
c) Data Hiding
d) Overloading

8. Polymorphism is a feature of C++ where same functions behave differently


depending upon they are operating on .
a) True
b) False

9. Double data type takes 4 bytes in size.


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

12. _____________ operator acts like a shortcut for if else statement.


a) Unary
b)Conditional
c) Logical
d) Increment/Decrement

13. ____________ Loop executed the statements at least once


a) while
b) Do-while

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

15. _______________header file should be included to use exit function.


a) Process.h
b) conio.h
c) stdio.h
d) iostream.h
16. __________can be defined as data structures that allows to store group of
data of same datatype.
a) Array
b) Structure
c) Union
d) String

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

18) All the elements enclosed in an Array within _________ brackets.


a) flower
b) small
c) Large

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

21) cin.get (str,40);


To read multiple lines of text from the user. It reads 39 character maximum
a) True
b) False

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

25) In Passing the argument by _____________no copy of the variable is


created.
a) value
b) reference

26) ______________arguments are whose values need not be explicitly passed


during function call.
a) default
b) format
c) actual

27)___________functions enables programmers to save processing time by


reducing the overheads involved in function call.
a) inline
b) external
c) void

28)Classes are defined with the keyword ___________followed by the name of


the class.
a) class
b) object
c) c) public

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

32) a) Constructor can have arguments and can be overloaded. True/False


b) Destructor cannot have arguments and can not be overloaded.
True/False

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

35) Some of the Unary operators are ++, -- and minus(-)


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

39 Operator overloading feature helps to change the functionality of operators


with any data type.
a)True
b)False

40. It is necessary to overload operators for all classes.


a) True
b) False

Two Marks

1) Object oriented programming approach is bundling both data and _________


into one unit known as ______________.
a) functions, object
b) Procedure, class
c) information, procedure
d) None of these

2) Class and object support _____________and _________ which are


describing the terms of object oriented programming Languages.
a) data encapsulation, data hiding
b) data, function
c) inheritance, polymorphism
d) None of these

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

4)__________statement allow to choose a set of statements for execution


depending on a condition. If statement and ___________statement allows
selection in c++.
a) selection, switch
b) Iteration, conditional
c) selection, conditional
d)None of these.

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

7) char str[]; is a valid statement


a) True
b) False

8) Part 1. Every function has three components


a) return value
b) function name
c) set of arguments
d) None of these
Part 2. Every function may not return a value
a) 1) True 2) false
b) 1) True 2) True

9) Data can be passed to functions in Two ways _____________&


______________
a) Passing by value, Passing by reference
b) Pass by data, Pass by address

10) __________are member functions of a class which have same name as


class name. __________are called automatically whenever an object of the class
is created.
a) constructor, constructor
b) constructor, destructor
c) class, ~
d) ~, constructor
11) Constructor and Destructor is declared is ________________ and they
have no _____________ value
a) Private, void
b) Public, return

12. All Unary operators are implemented with _____________ arguments


a) Default
b) No

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

18. a) __________ operator is known as membership access operator


a)->
b) *
c) &
d) malloc

b) ________ is dynamic data structures which can be imagined as set of


nodes
a) Linked list
b) Queue Stack

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

1) There are three steps in executing a C++ Program


a) Compiling, Linking and Running
b) Linking, Loading, and Executing
c) Object code, Source code and Linking
d) None of These

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.

a) 1-a, 2-b, 3-d, 4-c


b) 1-c, 2-b, 3-c, 4-d
c) 1-b, 2-a, 3-c, 4-d
d)1-d, 2-c, 3-b, 4-a

5)Match Making

a Strlen 1) function is used to find the length of the string


b Strcmp 2) function arranges the characters in the string
variable in reverse order.
c Strrev 3)function is used to compare strings.
d Strcpy 4)function returns the destination string value after
coping.

1)a-1, b-3, c-2, d-4


2)a-2, b-1, c-4, d-3
3)a-1, b-2, c-3, d-4
4)a-2, b-3, c-1, d-4

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.

1) a-1, b-3, c-2


2) a-2, b-3, c-1
3) a-1, b-2, c-3
4) a-3, b-2, c-1

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

10. The loop for(j=0;j<100;j+=2)


Will be executed how many times.
a) 100
b) 50
c) 51
d) 49

11. x=1
do
{
cout<<x;
x++;
}
while(x>10);
will be executed how many times.

a) 1
b) 10
c) 0
d) 9

12. int x=1


{
switch(x)
{
case 0:cout<<”Zero”;
break;
case 1:cout<<”One”;
case 2:cout<<”Two”;
}}
What is the output of the above code.

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

15. Class distance


{private:
int feet;int inches;
public:
void setdistance(int a, int b)
{feet=a; inches=b;}
void display()
{cout<<feet<<”ft”<<inches<<”inches;}}
void main()
{distance d1;
d1.setdistance(10,20);
d1.display();}

What is the output of above code.

a) 12, 24
b) 30, 6
c) 14, 22
d) None of these

16) What is output of following Program

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

También podría gustarte