You are on page 1of 14

BC0037

OBJECT Oriented Programming using C++


(1-MARK questions) a. Real constant can be represented in 2 forms: a. b. c. d. Decimal form, exponential form Integer, decimal form Exponential form , integer Decimal form, real form

b. Integer values lie between e. 30657,31658 f. 32768, 32767 g. 31757,31758 h. 32568,32768 c. The % operator gives the i. Quotient j. Remainder k. None l. Both d. The output of the following a>b? a : b+10; If A=10, b=5 m. 10 n. 15 o. 5 p. none of the above e. A character variable can at ime store q. 1 character r. 8 character s. 254 character t. none of the above f. If a is an integer variable , a=5/2; will return a value u. 2.5 v. 3 w. 2 x. 0 g. The expression , a=7/22*(3.14+2)*3/5; evaluates to y. 8.28 z. 6.288

aa. 3.14 bb. 0 h. The expression x=4+2%-8 evaluates to cc. 6 dd. 6 ee. 4 ff. none of the above i. A class is a ____________ for number of objects. gg. Function hh. Variable ii. Template jj. Data j. The multi-way branching can be achieved by kk. If-then-else ll. Switch case mm. For loop nn. Assignment operator k. Switch () is a oo. Iterative statement pp. Decision statement qq. Control statement rr. None of the above l. The goto statement ss. breaks the normal execution tt. continue the sequential execution uu. all the above vv. none of the above m. The for & while loops are ww. entry loop xx. exit loop yy. continue loop zz. none of the above n. The continue statement causes aaa. Loop to be continue , without executing rest of the statementss in the loop. bbb. Loop to be continue, with executing all the statements of the loop ccc. Breaks the loop and continue executing the rest of the program statements

ddd.

None of the above

o. For frequently used variables, efficiency gains can be obtained by keeping the variables as eee. static variable fff. register variable ggg. extern variables hhh. global variables p. The following code states that extern int size; iii. it is a variable declaration jjj. it is a variable definition kkk. both a and b lll. none of the above q. Out of which is not a keyword in C++ mmm. array nnn. if ooo. else ppp. extern r. When we pass array to a function that is passed as : qqq. Pass by value rrr. Pass by reference sss. Pass by constant ttt. Array cant be passed by function s. Which of the following set of operators cannot be overloaded uuu. Sizeof, ::, << vvv. Sizeof,:: www. ::,>> xxx. <<<,:: t. What math method, invoked this Math.method(x);would return the value 5 given the value of x to be 4.5 yyy. round() zzz. ceil() aaaa. floor() bbbb. a and c u. Structure elements are referenced through the : cccc. . , -> operator dddd. . , * eeee. [],. ffff. None of the above

v. User defined data types can be created using gggg. enum ,class hhhh. class, struct iiii. a and b jjjj. none of the above w. Which is not a feature of C++ : kkkk. data abstraction llll. data hiding mmmm. polymorphism nnnn. web connectivity x. The feature of combining data and functions together is called oooo. polymorphism pppp. encapsulation qqqq. overriding rrrr. none of the above y. Which of these are the assignment operators ssss. += tttt. == uuuu. >= vvvv. = z. The function consists of three entities: wwww. name, parameter, return type xxxx. name , prototype, return type yyyy. return type, parameter,signature zzzz. none of the above aa. The strcmp function returns aaaaa. 0 bbbbb. Negative ccccc. Positive ddddd. all of the above bb. Objects are eeeee. fffff. ggggg. hhhhh. function of a class prototype of a class instance of a class none of the above False

cc. Virtual functions are primarily used in Polymorphism.

dd. iostream.h header file has to be included for the file input and output. False ee. Pointers are variables that stores address values of other variables. True

ff. Unary operators overloaded for the class can differentiate between post and pre operators. False gg. Static data member of a class can be modified by all objects of the class. True hh. Array of structure can be created. True False

ii. Structure variables cantbe initialized during declaration.

jj. If the function does not have any return value, the return statement can be skipped. True kk. char str[]; is a valid statement. False

ll. In array every data should be separated by comma and all elements enclosed within flower bracket while initializing during declaration. True mm. The static variables of the class have to be explicitly initialized outside the class name followed by scope resolution operator (: : ) and static variable name True nn. Static data need not be initialized. False

(2-MARKS questions)
oo. The ________ is used to access the public members of the class with a ________ of an object ({arrow}, Pointer) pp. The operator ______ When placed before a variable, returns the memory address of its operand and the ____________ returns the data value stored in the area being pointed to by the pointer following it (&, *) qq. When amount of memory is predicated and the memory is allocated during compiletime (When the program is being compiled, it is referred to as _______ But when amount of memory to be allocated is not prebnown, and the memory is allocated during runtime (when the program is running as when required, it is referred to as) _________ (Static memory allocation, dynamic memory allocation) rr. The process of invoking a function through its own body is known ______ (Recession) ss. The variables or values passed to a function are called __________ or ______ (Actual parameters, arguments)

tt. There are two default variables ___________of type int and _________ predefined for storing command line arguments which are usually defined as arguments to the main functions. (argc, argv(array of strings)). uu. Three classes istream_withassign, _______________ and _______________ are inherited from istream, ostream, iostream respectively.( ostream_withassign, iostream_withassign vv. cin is a predefined object of __________ class, while cout is a predefined object of __________ class.(fstream.h, ostream_withassign). ww.The class istream is derived from _________ class which contains all the necessary ___________for handling input. (ios, functions). xx. Objects can have both ___________ and ______________(attributes, behaviour). yy. C++ programs goes through two phases _________ and ________ before execution. (Compiling, linking). zz. Object constitute of ________ and ___________(Data, Functions) aaa.________ is the extension of C++ program source files and _________ is the extension of C++ object code.(.cpp, .obj) bbb. _________ is the loop variable in the loop (for(int k=0;k<n;k++) and will be executed till the statement ____ becomes false. (k, k<n) ccc. _____________ header file should be included to use exit function.. The syntax of this function is _________(process.h, exit(integer)). ddd.External variables are also known as _____________ and automatically initialized tlo _____________. (global, zero) eee. Static variables are a mix of ______and __________variables (external, automatic) fff. The loop (for (j=0;j<100;j=j+2) will be executed how many times a) 100 b) 50 c) 51 d)49

ggg.What output does the above code fragment produce? Int ch =20; Cout <<ch <<++ch<<ch, Ans a. 21 b. 20 21 20 20 21

c. 20 d. 21

21 20

20 21

Hint Because when multiple values are cascaded without, calculations tabe place from right-to-left but printing tabe place from left-to-right. hhh.Name the header file to be included for the use of following built-in- functions: a. Isupperc b. Gets c. Strlen d. Log () iii. Ctype.h b. stdio.h c. string.h d. math.h)

(4-MARKS questions)
61. Inheritance has many forms as : jjj. Single inheritance kkk.multiple inheritance lll. Hierarchical inheritance mmm.Multilevel inheritance nnn.Hybrid inheritance a) ALL b) Only 1 ,2 and 3 c) Only 1, 3 and 5 d) Only 1, 3 and 4 62. i. Global variable last for the duration of program execution. ii. Local variables are created when their scope is entered and destroyed when their scope is exited. a. Both i and ii are true b. Only i is true c. Both i and ii are false d. Only ii is true 63. i. The memory space for global variables is reserved prior to program execution ii. The memory space for local variables is allocated on the fly during program execution. a. Both are false b. i is false ii is true c. i is true ii is false

d. both are true 64. Function overloading is appropriate for: i) Definition functions which essentially do the same thing , but operate on different data types. ii) providing alternate interfaces to the same function. a. Only i is true b. Only ii is true c. Both are true d. Both are false 65. i) this pointers are not accessible for static member functions. ii) this pointer are not modifiable. a. only i is true b. only ii is true c. both a and b d. none of the above 66. i) Function templates are not implemented like regular functions. ii)Function templates are prefixed with the keyword template a. i is true and ii is false b. i is false and ii is true c. both are false d. both are true 67. A file can be opened in C++ by i)Using the constructor of the stream class ii)Using the open() function of the stream a. Only i) is true b. Only ii) is true c. Both are true d. None is true 68.The output of the following will be : int k,num=30; k=(num>5?(num<=10?100:200):500); cout<<num; a. 500 b. 100 c. 200 d. none of the above 69. The output of the following will be :

void main() { int s1,s2,num; s1=s2=0; for(x=0;x<11;x++) { cin<<num; if(num>0)s1+=num;else s2=/num; } cout<<s1<<s2; } a. runtime error b. compilation error c. 1,1 ooo.0,1 70. The output of the following will be : int x=20; void main() {int x=10; x=x+15; ::x=::x+15; cout<<x<<::x; } output of the program is: a. error b. 35,25 c. 25,35 d. 35,35 71. The output of the code is: void strfn(char * *s) { char *n=INDIA; *s=n; } void main() { char *str=Bharat; strfn(&str); for(int x=0; str[x]>0;x++) { for(int y=0;y<=x;y++) cout<<str[y]; cout<<endl;

} } a) INDIA b) Bharat c) I IN IND INDI INDIA d) none of the above 72. What storage class would you use for the following situations? a. a1 is a formal argument to a function - auto b. b1 is a variable to be shared by three files exterm c. c1 Variable is to be shared by the function in one file but hidden from other files static global d. d1 deeps track of how many times the function containing it has been called? static local 73. The output of the following: public: per(char *s, float a) { strcpy(name,s); age=a; } per &GR(per&x) { if(x.age>=age) return x; else return *this; } void display() { cout<<name<<name<<\n; cout<<age<<age<<\n; } }; void main() { per P1(RAMU,27.5),

P2(RAJU,53), P3(KALU,40); per P(\0,0); P=P1.GR(P3);P.display(); P=P2.GR(P3);P.display(); } a) nameKALU age40 nameRAJU age53 nameRAMU age27.5 nameRAJU age53 nameRAMU age27.5 nameKALU age40 none of the above

b)

c)

d)

74. The output of following will be void main() { int b = 2 ; switch (b) { case 1: cout<<"one"; case 2: cout<<"two"; case 3: cout<<"three"; default :cout<<"invalid"; } } a. two b. two three invalid c. erro r d. invalid 75. The output of following will be void main() { int y , x = 12 ; y = ++x ; cout<<y; cout<< x;

} a. 13 13 b. 13 12 c. 12 13 d. 12 12 76. The output of the following code is: void main() { char s[]=Churchgate:no church no gate; char t[25]; char *ss , *tt; ss=s; while(*ss!=\0) ss++=tt++; cout<<t getch(); } a. no display b. error c. Churchgate:no church no gate d. Churchgate 77. Output of the following code is: #include<iostream.h> class myclass { int a; public: myclass(); ~myclass(); void show(); }; myclass::myclass() { cout<<In constructor\n; a=10; } myclass::~myclass() { cout<<destructor:; } void myclass::show()

{ cout<<a<<\n; } void main() { myclass ab; ab.show(); getch(); } a) In contructor 10 b) 10 destructor c) In constructor 10 Destructor d) None of the above 78. What will be the output of the following: #include<iostream.h> class integer { int m,n; public: integer(int , int); void display(void) { cout<<m=<<m<<\n; cout<<n=<<n<<\n; } }; integer::integer(int x, int y) { m=x; n=y; } main() { integer int1(0,100); integer int2=integer(25,75); cout<<\n Object1<<\n; int1.display(); cout<<\n OBJECT2<<\n; int2.display(); } a) b) Object1 m=0 n=10 OBJECT2

m=25 n=75 c) Object1 m=25 n=75 d) None of the above 79. The output of the following is #include<iostream.h> struct PLAY { int score,bonus;}; void Calculate(PLAY &P,int N=10) { P.score++; P.bonus+=N; } void main() { PLAY PL={10,15}; Calculate(PL,5); cout<<PL.score<<;<<PL.bonus< <endl Calculate(PL); cout<<PL.Score<<;<<PL.bonus <<endl; Calculate(PL,15); cout<<PL.score<<;<<PL.bonus< <endl; } a) 11:20 12:30 13:45 b) 11:40 12:30 13:45 c) 11:20 12:30 13:30 d) none of the above

You might also like