c++ Objective
-
Upload
vidhu-vohra -
Category
Documents
-
view
210 -
download
0
description
Transcript of c++ Objective
C++ Objective Questions
1) C++ was developed bya) Clocksin and mellish b) Donald E.Knuthc) Sir Richard Hadloc d) Bjarne Stroustrup
Answer: Option d
2) cfronta) is the front end of a C Compilerb) is the pre-processor of a C Complilerc) is a tool that translates a C++ code to its equivalent C coded) none of the above.
Answer: Option c
3)The following Program fragment int i=10; void main() { int i=20; { int i=30; cout<<i<<::i; }}a) prints 3010 b) prints 3020c) will results in a run time error d) none of the above. Answer: Option a
4) Which of the following are procedural languages?a) Pascal b) Java c) C++ d) C
Answer: Option a
5) A function abc is defined as void abc(int x=0, int y=0) { cout << x << y; } Which of the following calls is/are illegal? ( Assume h,g,are declared as integers) a) abc(); b) abc(h); c) abc(h,h); d) none of the above
Answer: Option d
6) The following C++ code results in #include “iostream.h” void main(void) { cout << (int i=5) << (int j=6); }
a) Compilation errorb) Run time errorc) Link time errord) None of the above.
Answer: Option a
7) Reusability is a desirable feature of a language as ita) Decreases the testing time b) increases the maintenance costc) Reduces the compilation time d) reduces the execution time
Answer: Option a
8) Which of the following statements is incorrect?a) Friend keyword can be used in the class to allow access to another class.b) Friend keyword can be used for a function in the public section of a class.c) Friend keyword can be used for a function in the private section of a class.d) Friend keyword can be used on main().
Answer : Option d
9) Which of the following statement is correct regarding destructor of base class?
a) Destructor of base class should always be static.b) Destructor of base class should always be virtual.c) Destructor of base class should not be virtual.d) Destructor of base class should always be private.
Answer : Option b
10) How can we make a class abstract?
a) By making all member functions constant.b) By making at least one member function as pure virtual function.c) By declaring it abstract using the static keyword.d) By declaring it abstract using the virtual keyword.
Answer : Option b
11 ) What happens when a class with parameterized constructors and having no default constructor is used in a program and we create an object that needs a zero-argument constructor?
a) Compile-time error.b) Preprocessing error.c) Runtime error.d) Runtime exception.
Answer : Option a
12) Destructor has the same name as the constructor and it is preceded by ______ .
a) !b) ?c) ~d) $
Answer : Option c
13) For automatic objects, constructors and destructors are called each time the objects
a) enter and leave scopeb) inherit parent classc) are constructedd) are destroyed
Answer : Option a
14) Which of the following cannot be declared as virtual?
a) Constructorb) Destructorc) Data Membersd) Both A and C
Answer : Option d
15) Which of the following are NOT provided by the compiler by default?
a) Zero-argument Constructorb) Destructorc) Copy Constructord) Copy Destructor
Answer : Option d
16) Which of the following statement is correct?
a) C++ enables to define functions that take constants as an argument.b) We cannot change the argument of the function that that are declared as constant.c) Both A and B.d) We cannot use the constant while defining the function.
Answer : Option c
17) Which of the following statement will be correct if the function has three arguments passed to it?
a) The trailing argument will be the default argument.b) The first argument will be the default argument.c) The middle argument will be the default argument.d) All the argument will be the default argument.
Answer : Option a
18) Which of the following concepts means determining at runtime what method to invoke?
a) Data hidingb) Dynamic Typingc) Dynamic bindingd) Dynamic loading
Answer : Option c
19) Which of the following is correct about class and structure?
a) class can have member functions while structure cannot.b) class data members are public by default while that of structure are private.c) Pointer to structure or classes cannot be declared.d) class data members are private by default while that of structure are public by default.
Answer : Option d
20) Which of the following is a mechanism of static polymorphism?
a) Operator overloadingb) Function overloadingc) Templatesd) All of the above
Answer : Option d
19) Which of the following concepts means wrapping up of data and functions together?
a) Abstractionb) Encapsulation
c) Inheritanced) Polymorphism
Answer: Option b
20) How "Late binding" is implemented in C++?
a) Using C++ tablesb) Using Virtual tablesc) Using Indexed virtual tablesd) Using polymorphic tables
Answer: Option B
21)Which of the following cannot be used with the keyword virtual?
a) class b) member functions c) constructor d) destructor
Answer: Option c
22) Which one of the following options is correct about the statement given below? The compiler checks the type of reference in the object and not the type of object.
a) Inheritance b) Polymorphism c) Abstraction d) Encapsulation
Answer: Option b
23) Which of the following problem causes an exception?
a) Missing semicolon in statement in main().b) A problem in calling function.c) A syntax error.d) A run-time error.
Answer: Option d
24) Which of the following concepts is used to implement late binding?
a) Virtual functionb) Operator function
c) Const functiond) Static function
Answer: Option a
25) Which of the following ways are legal to access a class data member using this pointer?
a) this->xb) this.xc) *this.xd) *this-x
Answer: Option a
26) Which of the following is a mechanism of static polymorphism?
a) Operator overloadingb) Function overloadingc) Templates d) All of the above
Answer: Option d
27) What happens if the base and derived class contains definition of a function with same prototype?
a) Compiler reports an error on compilation.b) Only base class function will get called irrespective of object.c) Only derived class function will get called irrespective of object.d) Base class object will call base class function and derived class object will call derived class function.
Answer: Option d
28) Which of the following are available only in the class hierarchy chain?
a) Public data membersb) Private data membersc) Protected data membersd) Member functions
Answer: Option c
29) Which of the following is not a type of inheritance?
a) Multiple b) Multilevel c) Distributive d) Hybrid
Answer: Option c
30) Which of the following operators cannot be overloaded?
a) []b) ->c) ?:d) *
Answer: Option c
31) Which one of the following is the correct way to declare a pure virtual function?a) virtual void Display(void){0};b) virtual void Display = 0;c) virtual void Display(void) = 0;d) void Display(void) = 0;
Answer: Option c
32) Which of the following statement is correct?
a) A reference is stored on heap.b) A reference is stored on stack.c) A reference is stored in a queue.d) A reference is stored in a binary tree.
Answer: Option b
33) Which of the following statement is correct?
a) Once a reference variable has been defined to refer to a particular variable it can refer to any other variable.b) A reference is indicated by using && operator.c) Once a reference variable has been defined to refer to a particular variable it cannot refer to any other variable.d) A reference can be declared beforehand and initialized later.
Answer: Option c
34) Reference is like a _____.
a) Pointer b) Structure c) Macro d) Enum
Answer: Option a
35) Which of the following statement is correct?
a) A reference is a constant pointer.b) A reference is not a constant pointer.c) An array of references is acceptable.d) It is possible to create a reference to a reference.
Answer: Option a
36) Which of the following statement is correct?
a) A reference is declared using * operator.b) Once a reference variable has been defined to refer to a particular variable it can refer to any other variable.c) A reference must always be initialized within classes.d) A variable can have multiple references.
Answer: Option d
37) Which of the following statement is correct about the program given below?
#include<iostream.h> int main(){ int x = 80; int y& = x; x++; cout << x << " " << --y; return 0;}
a) The program will print the output 80 80.b) The program will print the output 81 80.c) The program will print the output 81 81.d) It will result in a compile time error.
Answer: Option d
38) Which of the following statement is correct about the program given below?
#include<iostream.h> enum number{ a=1, b, c
};int main(){ int x = c; int &y = x; int &z = x; y = b; cout<< z--; return 0; }
a) It will result in a compile time error.b) The program will print the output 1.c) The program will print the output 2.d) The program will print the output 3.
Answer: Option c
39) Which of the following statement is correct about the program given below?
#include<iostream.h> class number{ int x; public: number(); ~number(); void Show() const;};number::number(){ x = 25;}void number::Show() const{ cout<< x;}int main(){ number objB; objB.Show(); return 0; }
a) The program will print the output 25.b) The program will print the output Garbage-value.c) The program will report compile time error.d) The program will report runtime error.
Answer: Option c
40) Which of the following function prototype is perfectly acceptable?
a) int Function(int Tmp = Show());b) float Function(int Tmp = Show(int, float));c) Both A and B.d) float = Show(int, float) Function(Tmp);
Answer: Option a
41) Which of the following statement is correct?
a) Overloaded functions can have at most one default argument.b) An overloaded function cannot have default argument.c) All arguments of an overloaded function can be default.d) A function if overloaded more than once cannot have default argument.
Answer: Option c
42) Which of the following statement will be correct if the function has three arguments passed to it?
a) The trailing argument will be the default argument.b) The first argument will be the default argument.c) The middle argument will be the default argument.d) All the argument will be the default argument.
Answer: Option a
43) Where the default value of parameter have to be specified?
a) Function callb) Function definitionc) Function prototyped) Both b or c
Answer: Option c
44) Which of the following function / types of function cannot have default parameters?
a) Member function of classb) main()c) Member function of structured) Both b and c
Answer: Option b
45) What will be the output of the following program?
#include<iostream.h>int BixFunction(int a, int b = 3, int c = 3){ cout<< ++a * ++b * --c ; return 0;}int main(){ BixFunction(5, 0, 0); return 0;}a) 8b) 6c) -6d) -8
Answer: Option c
46) What will be the output of the following program?
#include<iostream.h> void MyFunction(int a, int b = 40){ cout<< " a = "<< a << " b = " << b << endl;}int main(){ MyFunction(20, 30); return 0; }a) a = 20 b = 40b) a = 20 b = 30c) a = 20 b = Garbaged) a = Garbage b = 40
Answer: Option b
47) Which of the following decides if a function that is declared inline is indeed going to be treated inline in the executable code?
a) Compilerb) Linkerc) Loaderd) Preprocessor
Answer: Option a
48) One of the disadvantages of Pass-by-reference is that the called function may inadvertently corrupt the caller’s data. This can be avoided by
a) Passing Pointers b) Declaring the formal parameters constantc) Declaring the actual parameters constantd) all of the above
Answer: Option b
49) Which of the following remarks about the differences between constructors and destructors are correct?a) Constructors can take arguments but destructors cannotb) Constructors cannot be overloaded but destructors cannot be overloadedc) Destructors can take arguments but constructors cannotd) Destructors can be overloaded but constructors cannot be overloaded
Answer: Option a
50) Forgetting to include a file(like emath or math.h) that is necessary will result in
a) Compilation errorb) Warning when the program is runningc) error at link timed) Warning when the program is compiled
Answer: Option c
51) The members of a class by default are
A Public
B Protected
C Private
D Mandatory to specify
Answer C
52) Exception handling is targeted at
A Run-time error
B Compile time error
C Logical error
D All of the above
Answer A
____________________________________________________________________
53) It is possible to declare as a friend
A A member function
B A global function
C A class
D All of the above
Answer D
_____________________________________________________________________________
54) You separated a derived class name from its access specifier with
A A colon
B Two colons
C Atleast one space
D A semi colon
Answer B
_____________________________________________________________________
55) An exception is caused by
A A hardware problem
B A problem in the operating system
C A syntax error
D A run-time error
Answer D
__________________________________________________________________________________
56) The following can be declared as friend in a class
A An object
B A class
C A public data member
D A private data member
Answer B
__________________________________________________________________________________
57) Which of the following statements is NOT valid about operator overloading?
A Only existing operators can be overloaded
B Overloaded operator must have at least one operand of its class type
C The overloaded operators follow the syntax rules of the original operator
D None of the above
Answer D
___________________________________________________________________________________
58) A copy constructor takes
A No argument
B One argument
C Two arguments
D Arbitrary no. of arguments
Answer B
___________________________________________________________________________________
59) An object is
A One instance of a class
B Another word for a class
C A class with static method
D A method that accesses class
Answer A
______________________________________________________________________________
60) A class defined within another class is
A Nested class
B Inheritance
C Containership
D Encapsulation
Answer A
_____________________________________________________________________________________
61 ) A blueprint for a software object is called a
A Object
B Class
C Instance
D None of these
Answer B
_________________________________________________________________________________
62) At which point of time a variable comes into existence in memory is determined by its
A Scope
B Storage class
C Data type
D All of the above
Answer B
63) A virtual class is the same as
A An abstract class
B A class with a virtual function
C A base class
D None of the above
Answer D
_______________________________________________________________________________________64) A static data member is given a value
A Within the class definition
B Outside the class definition
C When the program is exeuted
D Never
Answer D
_______________________________________________________________________________________
65) Which of the following is false for cin?
A It represents standard input
B It is an object of istream class.
C It is a class of which stream is an object
D Using cin the data can be read from user's terminal
Answer C
______________________________________________________________________________________
65) Member functions, when defined within the class specification
A Are always inline
B Are not inline
C Are inline by default, unless they are too big or too complicated
D Are not inline by default.
Answer A
_______________________________________________________________________________________
66) Access to private data
A Restricted to methods of the same class
B Restricted to methods of other classes
C Available to methods of the same class and other classes
D Not an issue because the program will not compile
Answer B
_______________________________________________________________________________________
67) C++ was originally developed by
A Clocksin and Melish
B Donald E.Knuth
C Sir Richard Hadlee
D Bjarne Stroustrup
Answer D
_______________________________________________________________________________________
68) Use of virtual functions implies
A Overloading
B Overriding
C Static binding
D Dynamic binding
Answer D
_______________________________________________________________________________________
69) Which of the statements is true in a protected derivation of a derived class from a base class?
A Private members of the base class become protected members of the derived class
B Protected members of the base class become public members of the derived class
C Public members of the base class become protected members of the derived class
D Protected derivation does not affect private and protected members of the derived class
Answer C
_______________________________________________________________________________________
70) The keyword friend does not appear in
A The class allowing access to another class
B The class desiring access to another class
C The private section of a class
D The public section of a class
Answer C
_______________________________________________________________________________________
71) Data members which are static
A Cannot be assigned a value
B Can only be used in static functions
C Cannot be defined in a Union
D Can be accessed outside the class
Answer B
_______________________________________________________________________________________
72) Which can be passed as an argument to a function?
A Constant
B Expression
C Another function
D All of the above
Answer A
______________________________________________________________________________________
73) Function templates can accept
A Any type of parameters
B Only one parameter
C Only parameters of the basic type
D Only parameters of the derived type
Answer C
______________________________________________________________________________________
74) In which case is it mandatory to provide a destructor in a class?
A Almost in every class
B Class for which two or more than two objects will be created
C Class for which copy constructor is defined
D Class whose objects will be created dynamically
Answer D
_______________________________________________________________________________________
75) A pointer to the base class can hold address of
A Only base class object
B Only derived class object
C Base class object as well as derived class object
D None of the above
Answer C
_______________________________________________________________________________________
76) Member of a class specified as _______ are accessible only to method of the class.
A private
B public
C protected
D derive
Answer A
______________________________________________________________________________________
77) When a child class function is called,the compiler looks first for a matching function name in the
A Class of the object using the function name
B Immediate ancestor class
C Base class
D Descendant class
Answer A
_______________________________________________________________________________________
78) Maximum number of template arguments in a function template is
A One
B Two
C Three
D Many
Answer D
_______________________________________________________________________________________
79) If you wanted to sort many large objects or structures, it would be most efficient to
A Place them in an array and sort the array.
B Place pointers to them in an array and sort the array.
C Place them in a linked list and sort the linked list.
D Place references to them in an array and sort the array.
Answer C
______________________________________________________________________________________
80) Match the following :
(a) Garbage collection in 1. Java
(b) Nameless object 2. generic programming
(c) Template support 3. defines a class
(d) A forward reference 4. member function
(e) Derived class inherits
from base class
A 1 5 4 2 3
B 1 5 2 3 4
C 5 1 2 3 4
D 5 4 3 1 2
Answer B
_______________________________________________________________________________________
81) A struct is the same as a class except that
A There are no member functions
B All members are public
C Cannot be used in inheritance hierarchy
D It does have a this pointer
Answer C
_______________________________________________________________________________________
82) Which of the following is not the characteristic of constructor?
A They should be declared in the public section.
B They do not have return type.
C They can not be inherited.
D They can be virtual.
Answer D
_______________________________________________________________________________________
83) The friend functions are used in situations where:
A We want to have access to unrelated classes
B Dynamic binding is required
C Exchange of data between classes to take place
D None of the above
Answer D
_______________________________________________________________________________________
84) A template class
A Is designed to be stored in different containers
B Works with different data types
C Generates objects which must be identical
D Generates classes with different numbers of member functions
Answer B
_______________________________________________________________________________________
85) Pure virtual functions
A Have to be redefined in the inherited class
B Cannot have public access specification
C Are mandatory for a virtual class
D None of the above
Answer A
_______________________________________________________________________________________
86) Overloading a postfix increment operator by means of a member function takes
A No argument
B One argument
C Two arguments
D Three arguments
Answer A
_______________________________________________________________________________________
87) A class which can use all the features of an established class,is
A A static class
B A super class
C A subclass
D Overloaded
Answer C
_______________________________________________________________________________________
88) A friend function to a class, C cannot access
A Private data members and member functions
B Public data members and member functions
C Protected data members and member functions
D The data members of the derived class of C
Answer D
_______________________________________________________________________________________
89) In access control in a protected derivation, visibility modes will change as follows
A Private, public and protected become protected
B Only public becomes protected
C Public and protected become protected
D Only private becomes protected
Answer C
_______________________________________________________________________________________
90) Which of the following cannot be legitimately passed to a function
A A constant
B A variable
C A structure
D A header file
Answer D
_______________________________________________________________________________________
91) When the compiler cannot differentiate between two overloaded constructors, they are called
A Overloaded
B Destructed
C Ambiguous
D Dubious
Answer C
_______________________________________________________________________________________
92) If a base class destructor is not virtual, then
A It can not have a function body
B It can not be called
C It can not be called when accessed from pointer
D Destructor in derived class can not be called when accessed through a pointer to the base class
Answer D
_______________________________________________________________________________________
93) A function call mechanism that passes arguments to a function by passing a copy of the values of the arguments is __________
A Call by name
B Call by value
C Call by reference
D Call by value result
Answer B
_______________________________________________________________________________________
94) A variable defined within a block is visible
A From the point of definition onward in the program
B From the point of definition onward in the function
C From the point of definition onward in the block
D Throughout the function
Answer C
_______________________________________________________________________________________
95) RunTime polymorphism is achieved by ___________
A Friend function
B Virtual function
C Operator overloading
D Function overloading
Answer B
_______________________________________________________________________________________
96) This pointer
A Implicitly points to an object
B Can be explicitly used in a class
C Can be used to return an object
D All of the above
Answer D
_______________________________________________________________________________________
97) A __________ is a special method used to initialize the instance variable of a class.
A Member function
B Destructor
C Constructor
D Structure
Answer C
_______________________________________________________________________________________
98) Additional information sent when an exception is thrown may be placed in
A The throw keyword
B The function that caused the error
C The catch block
D An object of the exception class
Answer C
_______________________________________________________________________________________
99) The members of a class, by default, are
A Public
B Protected
C Private
D Mandatory to specify
Answer C
_______________________________________________________________________________________
100) The actual source code for implementing a template function is created when
A The declaration of function appears.
B The function is invoked.
C The definition of the function appears.
D None of the above.
Answer B
_______________________________________________________________________________________
101) A default catch block catches
A All thrown objects B No thrown objects
C Any thrown object that has not been caught by an earlier catch block
D All thrown objects that have been caught by an earlier catch block Answer C
_______________________________________________________________________________________
102)You may override the class access specifiers
A Public members
B Public and protected members
C Any specific class members you choose
D No class members
Answer C
_______________________________________________________________________________________
103) Within a switch statement
A Continue can be used but Break cannot be used
B Continue cannot be used but Break can be used
C Both Continue and Break can be used
D Neither Continue nor Break can be used
Answer B
_______________________________________________________________________________________
104) A friend function has access to all private and protected members of the class for which it is a friend
A Only private
B Private and protected
C Only protected
D None of the above
Answer B
_______________________________________________________________________________________
105) What features make C++ so powerful ?
A Easy implementation
B Reusing old code
C Reusing old code
D All of the above
Answer D
_______________________________________________________________________________________
106) A pure virtual function is a virtual function that
A Has no body
B Returns nothing
C Is used in base class
D Both (A) and (C)
Answer D
_______________________________________________________________________________________
107) In a class specifier ,data or function designated private are accessible
A To any function in the program
B Only if you the password
C To member functions of that class
D Only to public members of the class
Answer C
_______________________________________________________________________________________
108) Real world objects contain
A State and behavior
B Date and time
C Data and information
D None of these
Answer A
_______________________________________________________________________________________
109) Mechanism of deriving a class from another derived class is known as____
A Polymorphism
B Single Inheritance
C Multilevel Inheritance
D Message Passing
Answer C
_______________________________________________________________________________________
111) The concept of hierarchical classification is related to
A Abstraction
B Inheritance
C Function overloading
D None
Answer B
_______________________________________________________________________________________
112)The process of extracting the relevant attributes of an object is known as
A Polymorphism
B Inheritence
C Abstraction
D Data hiding
Answer B
_______________________________________________________________________________________
113) If a class C is derived from class B, which is derived from class A, all through public inheritance, then a class C member function can access
A Protected and public data only in C and B
B Protected and public data only in C
C Private data in A and B
D Protected data in A and B
Answer D
_______________________________________________________________________________________
114) The process of building new classes from existing one is called ______.
A Polymorphism B Structure
C Inheritance D Cascading
Answer C
_______________________________________________________________________________________
115) This type of inheritance is a mixture of multiple inheritance and hierarchical inheritance
A Single inheritance
B Multiple inheritance
C Hierarchical inheritance
D Hybrid inheritance
Answer D
_______________________________________________________________________________________
116) The base class access specification determines how ___________ members in the base class may be accessed by derived classes.
A Private B Public
C Protected D A,Band C
Answer D
_______________________________________________________________________________________
117) A base class may also be called a
A Child class
B Subclass
C Derived class
D Parent class
Answer D
_______________________________________________________________________________________
118)In multiple inheritance
A The base classes must have only default constructors
B Cannot have virtual functions
C Can include virtual classes
D None of the above
Answer C
______________________________________________________________________________________
119)Which of the statements are true ?
I. Function overloading is done at compile time.
II. Protected members are accessible to the member of derived class.
III. A derived class inherits constructors and destructors.
IV. A friend function can be called like a normal function.
V. Nested class is a derived class.
A I, II, III B II, III, V
C III, IV, V D I, II, IV Answer D
_______________________________________________________________________________________
120)_________ members of a base class are never accessible to a derived class.
A Public
B Private
C Protected
D A,B and C
Answer B
_______________________________________________________________________________________
121) Assume that we have constructor functions for both base class and derived class. Now consider the declaration in main( ). Base * P = New Derived; in what sequence will the constructor be called ?
A Derived class constructor followed by Base class constructor.
B Base class constructor followed by derived class constructor.
C Base class constructor will not be called.
D Base class constructor will not be called.
Answer B
_______________________________________________________________________________________
122) The term __________ means the ability to take many forms.
A Inheritance
B Polymorphism
C Member function
D Encapsulation
Answer B
_______________________________________________________________________________________
123) Usually a pure virtual function
A Has complete function body
B Will never be called
C Will be called only to delete an object
D Is defined only in derived class
Answer D
______________________________________________________________________________________
124) Encapsulation is
A Dynamic binding
B A mechanism to associate the code and data.
C Data abstraction
D Creating new class
Answer B
______________________________________________________________________________________
125) Identify the operator that is NOT used with pointers
A ->
B &
C *
D >>
Answer D
_______________________________________________________________________________________
126) Consider the following statements
char *ptr;
ptr = “hello”;
cout << *ptr;
What will be printed?
A first letter
B entire string
C it is a syntax error
D last letter
Answer A
_______________________________________________________________________________________
127) Which of the following operator can be overloaded through friend function?
A ->
B =
C ( )
D *
Answer D_______________________________________________________________________________________128) What will be the output of the following program?#include<iostream.h>void main(){float x=5,y=2;int result;result=x % y;cout<<result;}A 1B 1.0C Error messageD 2.5
Answer C_______________________________________________________________________________________
129) Which of the following declarations are illegal?
A void *ptr;B char *str = “hello”;C char str = “hello”;D const *int p1;
Answer C_______________________________________________________________________________________130) If we create a file by 'ifstream', then the default mode of the file is _________A ios :: out
B ios :: inC ios :: appD ios :: binary
Answer B_______________________________________________________________________________________131) If the variable count exceeds 100, a single statement that prints “Too many” isA if (count<100) cout << “Too many”;B if (count>100) cout >> “Too many”;C if (count>100) cout << “Too many”;D None of these.
Answer C_______________________________________________________________________________________132) What is the following code segment doing?void fn( ){char c;cin.get(c);if (c != '\n') {fn( );cout.put(c);}}A The string entered is printed as it is.B The string entered is printed as it is.C It will go in an infinite loop.D It will print an empty line.
Answer B_______________________________________________________________________________________133) Which of the following will produce a value 10 if x = 9.7?A floor(x)B abs(x)C log(x)D ceil(x)
Answer D
134) The address of a variable temp of type float isA *tempB &tempC float& tempD float temp&
Answer B
135) To access the public function fbase() in the base class, a statement in a derived class function fder() uses the statement.fbase();A fbase();B fder();C base::fbase();D der::fder();
Answer A_______________________________________________________________________________________
136) What will be the output of following program?#include<iostream.h>void main(){float x;x=(float)9/2;cout<<x;}A 4.5 B 4.0C 4D 5
Answer A_______________________________________________________________________________________137) The operator << when overloaded in a classA must be a member functionB must be a non member functionC can be both (A) & (B) aboveD cannot be overloaded
Answer C______________________________________________________________________________________
138) Which of the following is the valid class declaration header for the derived class d with base classes b1 and b2?
A class d : public b1, public b2B class d : class b1, class b2C class d : public b1, b2D class d : b1, b2
Answer A_______________________________________________________________________________________
139) In C++, dynamic memory allocation is accomplished with the operator ____
A newB thisC malloc( )D delete
Answer A_______________________________________________________________________________________
140) What is the error in the following code?
class t{virtual void print();}A No errorB Function print() should be declared as static.C Function print() should be defined.