Thursday, December 10, 2009

c++ part 1

UNIT I - Introduction To OOP

1) Functions are also called as __________.
a) Subroutines b) subprograms c) Procedures d) All

2) POP stands for _______
a) Procedure Oriented Programs b) Program oriented procedure
c) Procedural oriented programs d) None

3) OOP stands for _______
a) Object oriental programming b) Object oriented programming
c) Optical Object programs d) None

4) ____ 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

5) _________ is generally shorter because objects are small and contain independent code.
a) Application debug b) Application implementation c) Application testing d) None

6) C++ was developed by _________.
a) Denis Ritchie b) Bjarne Stroustrup c) James Gosling d) None

7) It was developed in which year ____
a) 1980 b) 1986 c) 2000 d) 1886

8) ______ was the first release of C++.
a) 1.0 b) 1.1 c) 1.2 d) 2.0

9) It was released by ________ company.
a) Microsoft b) AT&T c) IBM d) Oracle

10) C++ is superset of _____.
a) C b) Java c) VB d) None

11) _____ is said to be an instance of a class.
a) Variable b) Object c) Both a & b d) none

12) ______ is single unit of data and functions that operate on the data.
a) Object b) Class c) Both a & b d) None

13) ________ describes the data and its behavior or functionality.
a) Object b) Class c) Both a & b d) None

14) The method of ________ is the process of dividing into subclasses.
a) Inheritance b) Polymorphism c) Both a & b d) None

15) A _______ is a data type defined by user describing the data it represents.
a) Object b) Class c) Both a & b d) None

16) In inheritance the main class is said to be ____
a) Parent class b) super class c) Base class d) None

17) The concept of _____ provides an important extension to the idea of reusability.
a) Inheritance b) Polymorphism c) Both a & b d) None

18) ______ 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

19) ___________ is a kind of polymorphism.
a)Overloading b) Overriding c) Both a & b d) None

20) _____ 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

21) The extension of C++ is _____.
a) C b) CPP c) .CP d) None


22) On compilation, of C++ source code we get ____ file.
a) . CPP b) .EXE c) .OBJ d) None

23) On linking, of C++ source code we get ____ file.
a) . CPP b) .EXE c) .OBJ d) None

24) ________ functions saves memory space as the code is not repeatedly compiled.
a) Normal b) Inline c) Static d) None

25) The local variables are stored in ______
a) Data segment b) Stack Segment c) Hash Segment d) None

26) The static and global variables are stored in ______
a) Data segment b) Stack Segment c) Hash Segment d) None

27) The “ #include” is said to be a ___________
a) Empty statement b) preprocessor directive c) Pragma d) None

28) ____ is the object used to display information on standard output device.
a) cin b) printf c) cout d) None

29) >> is said to be _____ operator.
a) Insertion b) Extraction c) Put d) None

30) << is said to be _____ operator.
a) Insertion b) Extraction c) get d) None

31) ______ is the manipulator.
a) endl b) setw c) Both a & b d) None

32) _____ is the maximum number of characters in a variable name.
a) 5 b) 32 c) 256 d) 1024

33) ________ is a fixed value throughout the program.
a) Variables b) Constants c) Both a & b d) None


34) ____ is exponent form
a) –14E-2 b) –14-E+2 c) –14-E2 d) None

35) ________ specifies what the variable name is and what type it will hold.
a) Data Type b) Data Declaration c) Both a & b d) None

36) An array is collection of _____ data.
a) Homogeneous b) Heterogeneous c) Both d) None

37) The position in array is represented by ____
a) Subscript b) Indicator c) Both d) None

38) The index of an array starts with __
a) 1 b) 0 c) –1 d) None

39) The maximum number of dimensions depends on ____.
a) Interpreter b) Compiler c) Operating system d) None

40) ________ defines the set of all names that will be permissible values of the type.
a) Structures b) Enum c) Both d) None

41) ______ is a datatype which is used to define heterogeneous set of data types.
a) Structures b) enum c) Array d) None

42) The assignment statement is called ____ statement.
a) Static b) Dynamic c) Put d) None

43) ____ is modulus operator.
a) / b) ^ c) % d) &

44) Type _____ is implicitly done.
a) Casting b) Conversion c) Both a& b d) None

45) Type _____ is explicitly done.
a) Casting b) Conversion c) Both a & b d) None

46) The conditional operators return _____
a) true, false b) 0, 1 c) yes, no d) None

47) The set of compound statements enclosed within { } is said to be _____.
a) Group b) Block c) Stack d) Heap

48) ____ is said to be statement terminator.
a) . b) ; c) : d) –

49) _____ is said to be unconditional branching.
a) If b) Switch c) Goto d) None

50) The loops perform the task until expression evaluates to ______.
a) true b) false

51) In ____ loop , the statements are to be executed atleast once for condition to be verified.
a) While b) DO.. WHILE c) For d) None

52) The functions associated with a class are called.
a) functions b) procedure c) methods d) All

53) The _____ feature ties data and procedures logically together.
a) data hiding b) data encapsulation c) Both d) None

54) The ____ feature is that the data is concealed within a class.
a) Data Hiding b) Data Abstraction c) Both d) None

55) The ____ refers to calls to member functions.
a) Messages b) Overloading c) Both a & b d) None

56) The default access specifier for structures is _____
a) Public b) Private c) Protected d) None

57) The default access specifier for class is ___
a) public b) private c) friendly d) None

58) Automatic initialization is carried out using a special member function called the ____.
a) Starter b) Initialiser c) constructor d) None

59) _______ is invoked when the compiler returns to the calling function.
a) Constructor b) Destructor c) Both a & b d) None

60) _____ is said to be scope resolution operator.
a) : b) :: c) ?: d) None

61) _____ is said to be scope conditional operator.
a) : b) :: c) ?: d) None

62) 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

1) 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

2) 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
3) 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

4) 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

5) The term ____ and ____ are used interchangeably.
a) Overloading, polymorphism b) Overloading, inheritance
c) Reusability, inheritance d) Reusability, Polymorphism

6) 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

7) 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

8) 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

9) What is the range of integer values
a) –32768,32767 b) 0, 32768 c) 32768,0 d) None

10) 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

11) 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

12) ______ are the statements used only within a loop.
a) Break b) Continue c) Exit d Both a,b

13) 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

14) 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

15) 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

1) 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

2) 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

3) 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

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


5) 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

6) 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

7) Give the O/P:
for(I=0;I<5;I++)
{
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

8) 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


9) 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

10) Discuss the O/P:
class try
{
int id,tot;
public:
try(){tot=0; tot++; id=tot;}
void print()
{
cout<<”\n id is “< }

};
void main()
{
try ss1,ss2;
ss1.print();
ss2.print();
}
a) id=1 count=1 b) junk values c) Error d) None

11) Discuss the O/P:
class try
{
int id;
static int tot
public:
try(){ 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



12) What does the following program do:
void main()
{

int c;
for(c=65;c<=122;c++)
{
if(c>90 && c<97)
continue;
cout< }
}
a) Displays numeric set b) displays alphabet set c) displays char., set d) Error

13) What does the following program do:
void main()
{

int n[10],I,j,temp;
cout<<”\n Enter 10 numbers:”;
for(I=0;I<10;I++)
cin>>n[I];

for(I=0;I<9;I++)
{
for(j=I+1;j<10;j++)
{
if(n[I]>n[j])
{
temp=n[I];
n[I]=n[j];
n[j]=temp;
}
}
}
for(I=0;I<10;I++)
cout<<”\n”<
}
a) Displays the entered numbers in ascending order
b) Displays the entered numbers in descending order
c) Both a & b
d) None

14) 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


15) 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

16) Match the following:
Operators Category
1) ++ A) binary
2) += B) ternary
3) ?: 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