D. Open file, set the position to the end.



31. How would you output to an open file named a_file?

A. a_file.out("Output");

B. a_file="Output";

C. a_file<<"Output";

D. a_file.printf("Output");

32. What header file contains C++ file I/O instructions?

A. iostream.h

B. fstream.h

C. infstream.h

D. outstream.h

 

33. What value must a destructor return?

A. A pointer to the class.

B. An object of the class.

C. A status code determining whether the class was destructed correctly

D. Destructors do not return a value.

34. Which of the following is a valid class declaration?

A. class A { int x; };

B. class B { }

C. public class A { }

D. object A { int x; };

 

35. Which functions will every class contain?

A. None

B. Constructor

C. Destructor

D. Both a constructor and a destructor

36. What purpose do classes serve?

A. data encapsulation

B. providing a convenient way of modeling real-world objects

C. simplifying code reuse

D. all of the above

37. What does your class can hold?

a) data

b) functions

c) both a & b

d) none of the mentioned

 

38. How many specifiers are present in access specifiers in class?

a) 1

b) 2

C) 3

d) 4

39. Constructors are used to:

A) initalize the objects

b) construct the data members

c) both a & b

d) none of the mentioned

 

40. Unless otherwise specified, entire arrays are passed __________ and individual array elements are passed __________.

a. By value, by reference.

B. By reference, by value.

c. By value, by value.

d. By reference, by reference.

 

41. Which statement would be used to declare a 10-element integer array c?

a. array c = int[ 10 ];

b. c = int[ 10 ];

c. int array c[ 10 ];

d. int c[ 10 ];

42. An array is not:

42.a. A consecutive group of memory locations.

b. Subscripted by integers.

c. Declared using braces, [].

D. Made up of different data types.

43. The inline keyword:

a. Increases function-call overhead.

b. Can reduce a function’s execution time but increase program size.

c. Can decrease program size but increase the function’s execution time.

D. Should be used with all frequently used functions.

44. The OR (||) operator:

a. Has higher precedence than the AND (&&) operator.

B. Stops evaluation upon finding one condition to be true.

c. Associates from right to left.

d. Is a ternary operator.

 

45. switch can be used to test:

A. int constants.

b. float constants.

c. string constants.

d. all types of constants

 

46. Which of the following for headers is not valid?

a. for ( int i = 0; i < 10; i++ )

b. int i = 0;

for ( ; i < 10; i++ )

c. for ( int i = 0; int j = 5; ; i++ )

d. All of the above

 

47. What is the final value of x after performing the following operations?

a. 8.25.

b. 5.5.

c. 5.

D. 8.

48. An uninitialized local variable contains:

A. The value last stored in the memory location reserved for that variable.

b. No value.

c. A value of zero.

d. A randomly assigned value.

 

49.  If grade has the value of 60, what will the following code display?

49.

a. nothing.

b. 60

C. Passed

d. cout << "Passed";

 

50. What is the result of the following code?

A. One

B. Zero

C. Hello World

D. ZeroHello World

51. What is required to avoid falling through from one case to the next?

A. end;

B. break;

C. Stop;

D. A semicolon.

 

52. Which is not a proper prototype?

A. int funct(char x, char y);

B. double funct(char x)

C. void funct();

D. char x();

 

53. What is the return type of the function with prototype: "int func(char x, float v, double t);"

A. char

B. int

C. float

D. double

 

54. Which of the following is a complete function?

A. int funct();

B. int funct(int x) {return x=x+1;}

C. void funct(int) {cout&tl;<"Hello"}

D. void funct(x) {cout<<"Hello"}

 

55. Which of the following shows the correct syntax for an if statement?

A. if expression

B. if { expression

C. if ( expression )

D. expression if

56. What is the correct value to return to the operating system upon the successful completion of a program?

A. -1

B. 1

C. 0

D. Programs do not return a value.

 

57. Which of the following is the correct operator to compare two variables?

A. :=

B. =

C. equal

D. = =

58. Which conversion is not possible?

A. int to float

B. float to int

C. char to float

D. All are possible

59. Which of the following is a valid inline for function foo?

A. inline void foo() {}

B. void foo() inline {}

C. inline:void foo() {}

D. None of the above

 

60. What is the output of this program?

 

A) execute

b) not execute

c) none of the mentioned

d) both a & b

 

61. What is the correct way to print integer sum to the screen?

a) cout<<sum<<endl;

b) cout"sum"<<endl;

c) cout>>sum>>endl;

d) cout<sum<endl;

 

62. Where does the object is created?

A) class

b) constructor

c) destructor

d) attributes

 

63. How to access the object in the class?

a) scope resolution operator

b) ternary operator


Дата добавления: 2018-05-12; просмотров: 251; Мы поможем в написании вашей работы!

Поделиться с друзьями:






Мы поможем в написании ваших работ!