C Ques

  • Uploaded by: payu
  • 0
  • 0
  • December 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View C Ques as PDF for free.

More details

  • Words: 693
  • Pages: 5
C++ 1) How many arguments do destructors take? a) Two b) One c) Any number of d) None 2) When we pass arguments by reference, the formal arguments in the called function become aliases to the actual arguments in the calling function. a) True b) False 3) A constructor that accepts no parameters is called the ___________ a) Dynamic constructor b) Parameterized constructor c) Default constructor d) None of the above 4) The last character in a string must be_________ a) 0 (Zero) b) \0 (Null) c) Empty d) None of the above 5) A pure virtual function is a function that___________ a) has no body b) returns nothing c) is used in a base class d) takes no arguments 6) A _______________ function can access a class private data, even though it is not a member function of the class. a) Friend b) Static c) Virtual d) Abstract 7) What is the result of the following statement? cout<<sizeof(float);

a) b) c) d)

4.000000 2 4 8

8) What is the output of the following program? #include void x(int a,int &b) { a=a+b; a=a-b; b=b-a; } void main() { int a=4,b=10; x(a,b); cout<
4,10 10,4 4,4 4,6

9) Which one of the following is a bitwise operator? a) ! b) ~ c) == d) != 10)What is the output of the following code? int a=0; for(int I=1;I<=a;I++) cout<
0 1 Nothing will get displayed Error

11) Which one of the following is a valid method for accessing the 3rd element of the array cust? a) cust.3 b) cust[3] c) cust[2] d) cust(2) 12)Can class objects be passed to a function? a) Yes b) No 13)If p & q are int type variables, what will be the result of the expression p%q Where p=-16 and q=-3 a) b) c) d)

1 -1 5 -5

14)Opening a file in ios::out mode also opens it in the __________ mode by default. a) ios::app b) ios::in c) ios::trunc d) ios::nocreate 15)A function template definition begin with the keyword___________ a) template b) class c) namespace d) class template 16)A constructor’s name is same as __________ a) Function name b) Class name c) Function name or class name d) None of the above 17)Which manipulator is used to specify the required field size for displaying an output value? a) setfill()

b) setprecision() c) setw() d) setiosflags() 18)A pointer is a variable for storing a) Integer values b) Address of another variable c) Its own address d) None of the above 19)The default case is required in the switch selection structure. a) Yes b) No 20)The wrapping up of data & functions into a single unit is called _____________ a) Inheritance b) Abstraction c) Polymorphism d) Encapsulation 21)A c++ array can store values of different data types. a) True b) False 22)A datatype that allows different data types to be assigned to the same storage location is called_________ a) Enum b) Union c) Array d) None of the above 23)What is the value of a & b after the following two statements are executed? int a=10; int b=a++ * ++a; a) b) c) d)

132 110 120 None of the above

24)The following examples show that the class R id derived from classes P and Q. Which of them are legal? a) class R:public P: public Q b) class R:public P,Q c) class R:public P, public Q d) class R::public P: public Q 25)Which one of the following is overloading the function? int sum(int x,int y) {} a) b) c) d)

int sum(int x,int y,int z) {} float sum(int x,int y) {} int sum(int a,int b) {} All of the above

ANSWERS 1. (d) None 2. (a) True 3. (c) Default constructor 4. (b) \0 null 5. (a) has no body 6. (a) Friend 7. (c) 4 8. (d) 4,6 9. (b) ~ 10.(c) Nothing will get displayed 11.(c) cust[2] 12.(a) Yes 13.(b) –1 14.(c) ios::trunc 15.(a) template 16.(b) Class name 17.(c) setw() 18.(b) Address of another variable 19.(b) No 20.(d) Encapsulation 21.(b) False 22.(b) Union 23.(c) 120 24.(c) class R:public P, public Q 25.(a) int sum(int x,int y,int z) {}

Related Documents

C Ques
November 2019 12
C Ques
December 2019 20
C# Ques And Ans
May 2020 9
Ques
October 2019 27
Interview Ques
October 2019 15
Multiple Ques.
June 2020 10

More Documents from ""

C Ques
December 2019 20
A2
December 2019 37