Sei sulla pagina 1di 9

C++ Questions & Answers JECRC UNIVERSITY JAIPUR

SET-2
1) Procedure oriented Programs are called as
A Structured programming
B Object oriented programming
C Functional programming
D None of the above

2)A _____________ is a class whose instances themselves are classes.


A subclass
B abstarct class
C metaclass
D object class

3)_______________ enables you to hide, inside the object, both the data fields and the methods
that act on that data.
A Encapsulation
B Polymorphism
C Inheritance
D Overloading

4)For a 16 bit word length Integer data type values lie between ________________
A 32768 to 32767.
B 0 to 32767
C -128 to 128
D 0 to 128

5)The __________ operator is known as insertion operator


A >>
B >
C <<
D <

6)Which of the following is NOT a Relational Operator


A ==
B >
C %
D !=

7)A __________ is an abstract idea that can be represented with data structures and functions.
A class
B object

Question Prepared By : Shekhar (IT Dept ,JECRC University Jaipur)


C++ Questions & Answers JECRC UNIVERSITY JAIPUR
C loop
D data type

8)Automatic Initialization of object is carried out using a special member function called
____________________
A friend
B casting
C reference parameter
D constructor.

9)A class can allow non-member functions and other classes to access its own private data, by
making them as _________________.
A private
B protected
C Friend
D public

10)____________________ is the process of creating new classes, called derived classes, from
existing classes called base class
A Inheritance
B encapsulation
C Polymorphism
D overloading

11)A ___________ class can share selected properties of its base classes,
A abstarct
B derived
C subclass
D both b & c

12)A _______________ is the address of a memory location and provides an indirect way of
accessing data in memory.
A Constant
B variable
C Pointer
D object

13)To perform identical operations for each type of data compactly and conveniently we have to use
A Exception
B constant parameter
C function templates
D None of the above

Question Prepared By : Shekhar (IT Dept ,JECRC University Jaipur)


C++ Questions & Answers JECRC UNIVERSITY JAIPUR

14)_____________ function writes a string of text to a window.


A cputs ( )
B put ()
C gets ()
D tputs ()

15)In graphics mode the basic element is a __________


A character
B text
C table
D pixel

16)The ________________ objects have values that can be tested for various error conditions.
A osstream
B ofstream
C stream
D ifstream

17)Which function return the current position of the get or put pointer in bytes.
A tellg ()
B tellp ()
C tell ()
D Both A and B

18)________________ is a technique that allows the user considerable flexibility in the way the
programs are used
A Redirection
B manipulation
C Detecting
D None of the above

19)Operator such as ______________ cannot be overloaded.


A +
B ++
C ::
D ==

20)In c++ ___________ Operator is used for Dynamic memory allocation


A Scope resolution
B Conditional
C New

Question Prepared By : Shekhar (IT Dept ,JECRC University Jaipur)


C++ Questions & Answers JECRC UNIVERSITY JAIPUR
D Membership access

21)The advantages of OOP are , 1. increased programming productivity 2. decreased maintenance


costs. 3. less time to execute 4. easy to understand
A 1& 3
B 1& 2
C 3& 4
D 2& 3

22)Find the Hierarchy Of Data Types 1. Long double 2. Double 3. Float 4. Long 5. Int 6. Char
A 1-2-3-4-5-6
B 1-3-2-4-5-6
C 1-2-3-5-4-6
D 1-2-4-3-5-6

23)State True or False 1. A static member function cannot be declared virtual, whereas a non-static
member functions can be declared as virtual 2. A static member function cannot have access to the
'this' pointer of the class.
A 1-T,2-F
B 1-F,2-T
C 1-T,2-T
D 1-F,2-F

24)State True or False 1. The this pointer is used as a pointer to the class object instance by the
member function. 2. By using polymorphism, you cannot create new objects that perform the same
functions as the base object
A 1-T,2-F
B 1-T,2-T
C 1-F,2-F
D 1-T,2-T

25)Which functions return the maximum pixels in each row (number of columns) and each column
(number of rows) of the screen
A getmar() and getmac()
B maxx() and maxy()
C getmaxx() and getmaxy()
D getmayy() and getmaxy()

26)what does this program do # include <fstream.h> void main() { const int max = 80; char buffer[80];
ifstream infile ("out.txt"); while (infile) { infile.getline(buffer,max); cout << buffer; } }
A check a ACII charcter in a File.
B reads an String File.
C reads an Ascii String File.
D check a String File.

Question Prepared By : Shekhar (IT Dept ,JECRC University Jaipur)


C++ Questions & Answers JECRC UNIVERSITY JAIPUR

27)Find the output of the following program #include <iostream.h> Void main () { int age=15; if (age
> 12 && age < 20) cout<<You are a teen-aged person; else cout<<You are not teen-aged; }
A 15
B You are a teen-aged person
C 20
D You are not teen-aged

28)The first index number in an array starts with _________ and the last index number of an array of
size n will be ______
A 0 & n-1
B 1 & n-1
C 0&n
D 1&n

29)State True or False 1. Public data members can be accessed directly in the main function without
an object. 2. Constructors can be overloaded.
A 1-F, 2-F
B 1-F, 2-T
C 1-T, 2-T
D 1-T, 2-F
To overload an operator _____________keyword must be used along with the operator to be
overloaded.

30)To overload an operator _____________keyword must be used along with the operator to be
overloaded.
A Over
B Overload
C void
D Operator

31)Which one of the following declaration is invalid?


A int a[];
B int a[]={19, 21, 16, 1, 50};
C int a[5]={19, b, 16, c, 50};
D int a[5];

32) Define the relationshiphttp://i2.wp.com/www.jbigdeal.com/wp-


content/uploads/2013/07/Pic.jpg
A 1-is-a, 2. part-of 3.a-kind-of
B 1-is-a, 2.a-kind-of 3. Part-of
C 1 a-kind-of-2.is-a,3. Part-of
D None of the above

Question Prepared By : Shekhar (IT Dept ,JECRC University Jaipur)


C++ Questions & Answers JECRC UNIVERSITY JAIPUR
33)What is the output of the program # include <iostream.h> void main() { int n=1; cout
<<endl<<"The numbers are ;"<<endl; do { cout <<n<<"\t"; n++; } while (n<=100); cout<<endl; }
A print natural numbers 0 to 99
B print natural numbers 1 to 99
C print natural numbers 0 to 100
D print natural numbers 1 to 100

34)What is the output of the program # include <iostream.h> class counter { private : int count;
public : counter() { count = 0; cout<<"New Object Created\n"; } void inc_count () { count++; } int
getcount() { return count; } ~counter() { cout<<"One Object Deleted\n" ; } }; void main() { counter
c1,c2; }Output:
A New Object Created New Object Created One Object Deleted
B New Object Created New Object Created
C New Object Created One Object Deleted
D New Object Created New Object Created One Object Deleted One Object Deleted

35)What is the output of the program class Window // Base class for C++ virtual function example
{ public: virtual void Create() { cout <<"Base class Window"<<endl; } }; class CommandButton : public
Window { public: void Create() { cout<<"Derived class Command Button "<<endl; } }; void main()
{ Window *x, *y; x = new Window(); x->Create(); y = new CommandButton(); y->Create(); }
A Base class Window
B Base class Window Derived class Command Button
C Derived class Command Button
D ERROR

36)What is the output of the program #include <iostream.h> template <class T, int N> class array { T
memblock [N]; public: void setmember (int x, T value); T getmember (int x); }; template <class T, int
N> array<T,N>::setmember (int x, T value) { memblock[x]=value; } template <class T, int N> T
array<T,N>::getmember (int x) { return memblock[x]; } int main () { array <int,5> myints; array
<float,5> myfloats; myints.setmember (0,100); myfloats.setmember (3,3.1416); cout <<
myints.getmember(0) << '\n'; cout << myfloats.getmember(3) << '\n'; return 0; }
A 100 3.1416
B syntax error
C 100
D No output

37)What is the use of the this program # include <fstream.h> void main() { ofstream tstfile
("out.dat"); char text[ ] = "This is a text line"; int i=0; while (text[i]) tstfile. put(text[i++]); }
A to create a file
B to print a text on monitor
C to read a file
D None of the above

Question Prepared By : Shekhar (IT Dept ,JECRC University Jaipur)


C++ Questions & Answers JECRC UNIVERSITY JAIPUR
38)In the below Declaration how many copies of x does DC inherits ? Class BC { Private: int x; }; Class
BC1: virtual public BC { Private : Float y; }; Class BC2: virtual public BC { Private: float z; }; Class DC:
public BC1, Public Bc2 { };
A One
B Two
C Zero

39) The objects are ....... if all their attribute values are identical ?
A Identical
B Distinct
C Same
D None

1 40) Object is....... ?


A A concep
B Abstraction
C Thing
D All of above

41) The mechanism by which the data and functions are bound together with an object definition ?

A Inheritance
B Abstraction
C Polymorphism
D Encapsulation

42) The process of creating instances from classes ?


A Integrity
B Instantation
C Inheritance
D Generalization

1 43) Override is a method .... ?


A For an operation that replaces an inherited method for the same operatio
B For a data that replaces an inherited method for the same operation
C For an operation that takes argument from library function
D None of these

1 44) In C++, a function contained with in a class is called ?


A In built functio
B User defined function
C Member function
D None of these

1 45) In C++, setw is..... ?

Question Prepared By : Shekhar (IT Dept ,JECRC University Jaipur)


C++ Questions & Answers JECRC UNIVERSITY JAIPUR
A Initialization Operato
B Conditional Operator
C Memory allocation Operator
D Field with Operator

1 46) A template can be used to create a family of ?


A Classe
B Functions
C Class and function
D None of these

1 47) In C++, we can use the same function name to create functions that perform a variety of
different tasks. This is known as ?

A Global function
B Function overloading
C Inheritance
D All of above

1
2 48) Which of the following is an object oriented programming ?

A Real time syste


B AI and expert systems
C Neural networks and parallel programming
D All of above

49) Function overloading is a type of

A polymorphism
B inheritance
C classes
D data hiding

50) By-default members of a class are-


A private
B public
C both
D none of above

Answer Key-
1 A
2 C
3 A
4 A

Question Prepared By : Shekhar (IT Dept ,JECRC University Jaipur)


C++ Questions & Answers JECRC UNIVERSITY JAIPUR
5 C
6 C
7 A
8 D
9 C
10 A
11 D
12 C
13 C
14 A
15 D
16 D
17 B
18 A
19 C
20 C
21 B
22 A
23 C
24 A
25 C
26 C
27 B
28 A
29 B
30 D
31 C
32 C
33 D
34 D
35 B
36 A
37 A
38 A
39 C
40 D
41 D
42 A
43 B
44 D
45 C
46 A
47 D
48 B
49 A
50 A

Question Prepared By : Shekhar (IT Dept ,JECRC University Jaipur)

Potrebbero piacerti anche