Tuesday, December 8, 2009

c++

UNIT I - Introduction To OOP
Functions are also called as __________.
a) Subroutines b) subprograms c) Procedures d) All
POP stands for _______
a) Procedure Oriented Programs b) Program oriented procedure
c) Procedural oriented programs d) None
OOP stands for _______
a) Object oriental programming b) Object oriented programming
c) Optical Object programs d) None
____ is a feature which we can change the data structure of an object without affecting the
operation of the program.
a) Data encapsulation b) Data abstraction/hiding c) Reusability d) None
_________ is generally shorter because objects are small and contain independent code.
a) Application debug b) Application implementation c) Application testing d) None
C++ was developed by _________.
a) Denis Ritchie b) Bjarne Stroustrup c) James Gosling d) None
It was developed in which year ____
a) 1980 b) 1986 c) 2000 d) 1886
______ was the first release of C++.
a) 1.0 b) 1.1 c) 1.2 d) 2.0
It was released by ________ company.
a) Microsoft b) AT&T c) IBM d) Oracle
C++ is superset of _____.
a) C b) Java c) VB d) None
_____ is said to be an instance of a class.
a) Variable b) Object c) Both a & b d) none
______ is single unit of data and functions that operate on the data.
a) Object b) Class c) Both a & b d) None
________ describes the data and its behavior or functionality.
a) Object b) Class c) Both a & b d) None
The method of ________ is the process of dividing into subclasses.
a) Inheritance b) Polymorphism c) Both a & b d) None
A _______ is a data type defined by user describing the data it represents.
a) Object b) Class c) Both a & b d) None
In inheritance the main class is said to be ____
a) Parent class b) super class c) Base class d) None
The concept of _____ provides an important extension to the idea of reusability.
a) Inheritance b) Polymorphism c) Both a & b d) None
______ allows to create multiple definitions for operators and functions and at run – time depending on the context a particular definition will be used.
a) Inheritance b) Polymorphism c) Both a & b d) None
___________ is a kind of polymorphism.
a)Overloading b) Overriding c) Both a & b d) None
_____ is a feature by which the operators +,-,etc., can be made to work with our class.
a) Operator overloading b) Function overloading c) Both a & b d) None
The extension of C++ is _____.
a) C b) CPP c) .CP d) None

On compilation, of C++ source code we get ____ file.
a) . CPP b) .EXE c) .OBJ d) None
On linking, of C++ source code we get ____ file.
a) . CPP b) .EXE c) .OBJ d) None
________ functions saves memory space as the code is not repeatedly compiled.
a) Normal b) Inline c) Static d) None
The local variables are stored in ______
a) Data segment b) Stack Segment c) Hash Segment d) None
The static and global variables are stored in ______
a) Data segment b) Stack Segment c) Hash Segment d) None
The " #include" is said to be a ___________
a) Empty statement b) preprocessor directive c) Pragma d) None
____ is the object used to display information on standard output device.
a) cin b) printf c) cout d) None
>> is said to be _____ operator.
a) Insertion b) Extraction c) Put d) None
<< is said to be _____ operator.
a) Insertion b) Extraction c) get d) None
______ is the manipulator.
a) endl b) setw c) Both a & b d) None
_____ is the maximum number of characters in a variable name.
a) 5 b) 32 c) 256 d) 1024
________ is a fixed value throughout the program.
a) Variables b) Constants c) Both a & b d) None

____ is exponent form
a) –14E-2 b) –14-E+2 c) –14-E2 d) None
________ specifies what the variable name is and what type it will hold.
a) Data Type b) Data Declaration c) Both a & b d) None
An array is collection of _____ data.
a) Homogeneous b) Heterogeneous c) Both d) None
The position in array is represented by ____
a) Subscript b) Indicator c) Both d) None
The index of an array starts with __
a) 1 b) 0 c) –1 d) None
The maximum number of dimensions depends on ____.
a) Interpreter b) Compiler c) Operating system d) None
________ defines the set of all names that will be permissible values of the type.
a) Structures b) Enum c) Both d) None
______ is a datatype which is used to define heterogeneous set of data types.
a) Structures b) enum c) Array d) None
The assignment statement is called ____ statement.
a) Static b) Dynamic c) Put d) None
____ is modulus operator.
a) / b) ^ c) % d) &
Type _____ is implicitly done.
a) Casting b) Conversion c) Both a& b d) None
Type _____ is explicitly done.
a) Casting b) Conversion c) Both a & b d) None
The conditional operators return _____
a) true, false b) 0, 1 c) yes, no d) None
The set of compound statements enclosed within { } is said to be _____.
a) Group b) Block c) Stack d) Heap
____ is said to be statement terminator.
a) . b) ; c) : d) –
_____ is said to be unconditional branching.
a) If b) Switch c) Goto d) None
The loops perform the task until expression evaluates to ______.
a) true b) false
In ____ loop , the statements are to be executed atleast once for condition to be verified.
a) While b) DO.. WHILE c) For d) None
The functions associated with a class are called.
a) functions b) procedure c) methods d) All
The _____ feature ties data and procedures logically together.
a) data hiding b) data encapsulation c) Both d) None
The ____ feature is that the data is concealed within a class.
a) Data Hiding b) Data Abstraction c) Both d) None
The ____ refers to calls to member functions.
a) Messages b) Overloading c) Both a & b d) None
The default access specifier for structures is _____
a) Public b) Private c) Protected d) None
The default access specifier for class is ___
a) public b) private c) friendly d) None
Automatic initialization is carried out using a special member function called the ____.
a) Starter b) Initialiser c) constructor d) None
_______ is invoked when the compiler returns to the calling function.
a) Constructor b) Destructor c) Both a & b d) None
_____ is said to be scope resolution operator.
a) : b) :: c) ?: d) None
_____ is said to be scope conditional operator.
a) : b) :: c) ?: d) None
If a data item in a class is defined as ____, then only one such item is created for entire class.
a) Private b) Static c) Extern d) None

Two mark Questions
Which of the following are true for POP:
1) Data is given secondary status.
2) There is data-hiding concept
3) More emphasis is on doing things by functions
4) There is data-encapsulation concept
a) I, ii b) I, iii c) ii, iv d) None
Which of the following are true for OOP.
i) Data is given primary status
ii) There is data-hiding concept
iii) More emphasis is on doing things by functions
iv) There is data-encapsulation concept
a. I, ii only b. ii, iii, iv c) I, ii, iv d) None
In which of the two categories OOP fall:
a) Increased programming, decreased maintenance cost
b) Decreased programming, increased maintenance cost
c) Increased speed, decreased maintenance cost
d) None
Which of the following are principles of Inheritance.
i) Each subclass shares common characteristics
ii) Each subclass can have its own particular characteristics.
a) I only b) ii only c) Both I, ii d. None
The term ____ and ____ are used interchangeably.
a) Overloading, polymorphism b) Overloading, inheritance
c) Reusability, inheritance d) Reusability, Polymorphism
The functions are overloaded means:
i) Their names are different
ii) They can have same number of arguments, but data types different
iii) They can have different number of arguments
iv) They have same names
a) I, iii b) ii, iii, iv c) All d) None
Specify the order in which the source code is converted to executable file.
i) Source text file
ii) Verify
iii) Link
iv) Compile
v) Testing
vi) Execute
a) I, iv, iii, vi b) ii, iv, iii, vi c) iv, I, ii, v d) ii, iii, iv, v
Which of the following are valid access specifiers for members of the class:
i) Global
ii) Private
iii) auto
iv) extern
v) protected
vi) public
vii) static viii) final
a) ii, iv, v, viii b) ii, vi, v c) I, iii, vi, v d) All
What is the range of integer values
a) –32768,32767 b) 0, 32768 c) 32768,0 d) None
Which of the following are true for structures:
i) The template must be terminated with semicolon
ii) The tag-name can be used to declare structure variables.
iii) The structure members cannot be initialized inside the template
a) I only b) ii, iii c) All d) ii only
Which of the following are valid expressions:
i) A signed or unsigned variable
ii) A signed or unsigned constant
iii) Variables connected by ,(comma) operator
iv) A variable or constant in parenthesis
a) I, ii, iv b) I, iv only c) All d) None
______ are the statements used only within a loop.
a) Break b) Continue c) Exit d Both a,b
Match the access specifiers:
1) Private I) can be accessed outside the class
2) Public ii) can be accessed only by parent and child classes
3) Protected iii) can be accessed only within the class
a) 1- I, 2- ii , 3 – iii b) 1- iii, 2- I , 3- ii c) 1- ii, 2- iii, 3- I d) 1-iii, 2- ii, 3 – I
Which of the following are true for constructors:
i) They have same name as that of the class
ii) they have (~) preceding the name.
iii) They are automatically called at the time of creating the object
iv) They cannot be overloaded.
a) I, iii b) I, ii c) ii, iv d) iii, iv
Which of the following are true for destructors:
i) They have same name as that of the class
ii) they have (~) preceding the name.
iii) They are automatically called at the time of creating the object
iv) They cannot be overloaded.
a) I, ii, iii b) I, ii c) ii, iv d) iii, iv
Four mark Questions
Which of the following are the features of C++
i) Multiple inheritance ii) Implicit support for abstract classes
iii) pointers to class members iv) Operator overloading
a) All b) I, ii only c) I, iii, iv d) None
Match the following:
Escape Sequence Character
1) \a I) Tab
2) \x add ii) bell(beep)
3) \t iii) backslash
4) \\ iv) Hexadecimal representation
v) Backspace
a) 1- ii; 2- iv; 3- I; 4- iii b) 1 – iii; 2- iv ; 3- v; 4 – I c) 1- v; 2- iv; 3- I; 4- iii d) None
What is the O/P:
struct ss
{
int sno,age;
float fee;
char name[30];
};
void main()
{
cout<}
a) 36 b. 38 c) 30 d) 4
Give the o/p:
void main()
{
int I=10;
cout<<++I<<"\t"<}
a) 12 11 10 b) 11 11 11 c) 10 10 10 d) 11 10 10

Arrange the operators from higher at top to lowest is bottom:
i) *,-,/,%,+
ii) < , >, ==, !=, >=, <=
iii) ?:
iv) ( )
v) &&,
vi) !, ++, - -, -
vii) =,+=,-=,*=,/=,%=
a) ii, iv, iii, I, vii, v, vi b) iv, vi, I, ii, v, iii, vii c) iv, vi, ii, I, v, vii, iii d) I, iii, ii, v, vi, vii, ii, iv
What does the following program do :
void main()
{
char x;
cout<<"\n enter a character ";
cin>>x;
switch(x)
{
case ‘A’: case ‘a’:
case ‘E’: case ‘e’:
case ‘I’: case ‘i’:
case ‘O’: case ‘o’:
case ‘U’: case ‘u’:
cout<<"\n vowel"; break;
default:
cout<<"\n consonant"’;
}
}
a) Accepts a character and displays Vowel or consonant
b) Accepts a string and checks characters which are vowel or not
c) Error
d) None
Give the O/P:
for(I=0;I<5 br="">{
if(I==3) continue;
cout<<"\n"<}
a) 1 2 4 5 b) 0 1 2 4 5 c) 0 1 2 3 5 d) 1 2 3 5
Give the O/p :
class myclass
{
int num;
public:
myclass(){num=0;}
myclass(int n){num=n;}
void sh(){
cout<<"\n num="<};
void main()
{
num n1, n2(30);
n1.sh();
n2.sh();
}
a) num = 0 num = 30 b) num=" " num=30 c) num=junkvalue num=30 d) error

Give the O/p :
class myclass
{
int num;
public:
myclass(int n){num=n;}
void sh(){
cout<<"\n num="<};
void main()
{
num n1, n2(30);
n1.sh();
n2.sh();
}
a) num = 0 num = 30 b) num=" " num=30 c) num=junkvalue num=30 d) error
Discuss the O/P:
class try
{
int id,tot;
public:
try(){tot=0; tot++; id=tot;}
void print()
{
cout<<"\n id is "<}
static void printcount()
{
cout<<"\n number of instances "<}
};
int try::tot=0;
void main()
{
try ss1,ss2;
try::printcount();
}
a) 1 b) 2 c) 0 d) None


What does the following program do:
void main()
{
int c;
for(c=65;c<=122;c++)
{
if(c>90 && c<97 br="">continue;
cout<}
}
a) Displays numeric set b) displays alphabet set c) displays char., set d) Error
What does the following program do:
void main()
{
int n[10],I,j,temp;
cout<<"\n Enter 10 numbers:";
for(I=0;I<10 br="">cin>>n[I];
for(I=0;I<9 br="">{
for(j=I+1;j<10 br="" j="">{
if(n[I]>n[j])
{
temp=n[I];
n[I]=n[j];
n[j]=temp;
}
}
}
for(I=0;I<10 br="">cout<<"\n"<}
a) Displays the entered numbers in ascending order
b) Displays the entered numbers in descending order
c) Both a & b
d) None
Which of the one is the correct logic for reversing the string:
i) void main() ii) void main()
{ {
char ss[80]; char ss[80],ss1[80];
cout<<"\n enter a string";
cout<<"\n enter a string:"; cin.getline(ss,80);
cin.getline(ss,80); strcpy(ss1,ss);
int l=strlen(ss); strrev(ss1);
for(l=l-1;l>=0; l- -) cout<<"\n reverse is "<cout<}
a) I only b) ii only c) Both I, ii d) None

What is the O/P of :
class A
{
int a;
A()
{a=0;}
public:
void show()
{
cout<<"\n a="<}
};
void main()
{
A ss;
ss.show();
}
a) 0 b) Junk value c) error d) None
Match the following:
Operators Category
++ A) binary
+= B) ternary
?: C) unary
a) 1- A, 2- B, 3- C b) 1- C, 2- A, 3- B c) 1- C, 2- B, 3- A d) a. 1- B, 2- A, 3- C


*************************


Key for One mark
1 d 2 a 3 b 4 b 5 c
6 b 7 b 8 c 9 b 10 a
11 b 12 a 13 b 14 a 15 b
16 c 17 a 18 b 19 c 20 a
21 b 22 c 23 b 24 b 25 b
26 a 27 b 28 c 29 b 30 a
31 c 32 b 33 b 34 a 35 b
36 a 37 a 38 b 39 b 40 b
41 a 42 b 43 c 44 b 45 a
46 b 47 b 48 b 49 c 50 a
51 b 52 c 53 b 54 a 55 a
56 a 57 b 58 c 59 b 60 b


Key for two marks questions
1 b 2 c 3 a 4 C 5 a
6 b 7 a 8 b 9 a 10 c
11 a 12 d 13 b 14 a 15 a



Key for four marks questions
1 c 2 a 3 b 4 a 5 b
6 a 7 b 8 a 9 d 10 a
11 b 12 b 13 a 14 c 15 c
16 b