Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

c__test2

.docx
Скачиваний:
22
Добавлен:
25.02.2016
Размер:
455.72 Кб
Скачать

  1. What is the output?

A.120;

B.240;

C.310;

D.70;

E.550;

  1. Structure definition

a)

b)

c)

d)

  1. Keyword of structure

a)Struct

b)Structure

c)Str

d)Strctur

  1. Which keyword doesn’t exist?

a)Struct

b)Class

c)That

d)This

  1. Which of this keyword isn’t access specifier?

a)Private

b)Public

c)Protected

d)Defended

  1. What type of access have class members by default?

a)Private

b)Public

c)Protected

d)Defended

  1. Which of this statement used to define a member of a class from outside the class definition itself?

a)::

b)>>

c)<<

d)/*

  1. What will be output of this code?

a) area: 12

b) area=12

c) Area:12

d) area:34

  1. What will be output of this code?

a) area: 1

b) area: -1

c) Area: -1

d) area:-1

  1. What will be output of this code?

a) area: 12

b) There will be an error.

c) Area:12

d) area:12

  1. What will be output of this code?

a) area: 155

b) area: 25

c) area: 75

d) area: 225

  1. What will be output of this code?

a) area: 12

b) area: 0

c) Area:12

d) area: 16

  1. What is the difference between array and structure?

a) only in their declaration

b) they haven't any differences

c) structure can include members of different types of data

d) structures are more powerful

e) array incudes only integers

  1. Which code outputs the member "name" of object student? (student is object of any structure)

a. cout<<struct.name

b. cout<<student[name]

c. cout<<student.name

d. cout<<struct.student.name

  1. What is the difference between classes and structures?

a.we can have functions in classes

b. they are similar

c. structures have only public access specifier

d. classes include characters;

e. structures include protected access specifier

  1. In classes, if we declare object without keywords like public, which type will it be of?

a. private

b. public

c. protected

d. it won't have access specifier

e. friend

  1. How could you call in main the function input in object school of some class?

a. input()

b. input

c. school::input()

d. school::input

  1. class student {string name, surname} Aibar; What is underlined?

a. object of class student

b. member of class student

c. member of object student

d. parameter of class student

  1. Which access specifier means that the member can be used only by the functions of this class?

a. private

b. public

c. protected

d. this specifier doesn't exist

  1. Which is the right declaration of the object of structure student:

a. struct Aibar

b. struct student:Aibar

c. student Aibar

d. student.Aibar

e. struct student=Aibar

  1. There is one mistake in code, in which line?

a.1

b.2

c.3

d.4

e.5

  1. Which of the following correctly declares an array?

A. int anarray[10];

B. int anarray;

C. anarray{10};

D. array anarray[10];

  1. What is the index number of the last element of an array with 29 elements?

A. 29

B. 28

C. 0

D. Programmer-defined

  1. Which of the following is a two-dimensional array?

A. array anarray[20][20];

B. int anarray[20][20];

C. int array[20, 20];

D. char array[20];

  1. Which of the following correctly accesses the seventh element stored in foo, an array with 100 elements?

A. foo[6];

B. foo[7];

C. foo(7);

D. foo;

  1. Which of the following gives the memory address of the first element in array foo, an array with 100 elements?

A. foo[0];

B. foo;

C. &foo;

D. foo[1];

  1. When does the code block following while(x<100) execute?

A. When x is less than one hundred

B. When x is greater than one hundred

C. When x is equal to one hundred

D. While it wishes

  1. Which of the following classes handles file input?

A. ofstream

B. ifstream

C. instream

D. inputfile

  1. Which of the following is not a valid ofstream argument?

A. ios::app

B. ios::trunc

C. ios::noreplace

D. ios::create

  1. What does ios::ate mean as an argument to ofstream?

A. Open file, but do not create.

B. Open file, create.

C. Open file for read access only.

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

  1. 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");

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

A. iostream.h

B. fstream.h

C. infstream.h

D. outstream.h

  1. 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.

  1. 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; };

  1. Which functions will every class contain?

A. None

B. Constructor

C. Destructor

D. Both a constructor and a destructor

  1. 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

  1. What does your class can hold?

a) data

b) functions

c) both a & b

d) none of the mentioned

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

a) 1

b) 2

c) 3

d) 4

  1. Constructors are used to:

a) initalize the objects

b) construct the data members

c) both a & b

d) none of the mentioned

  1. 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.

  1. 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 ];

  1. An array is not:

  2. a. A consecutive group of memory locations.

b. Subscripted by integers.

c. Declared using braces, [].

d. Made up of different data types.

  1. 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.

  1. 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.

  1. switch can be used to test:

a. int constants.

b. float constants.

c. string constants.

d. all types of constants

  1. 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

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

a. 8.25.

b. 5.5.

c. 5.

d. 8.

  1. 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.

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

a. nothing.

b. 60

c. Passed

d. cout << "Passed";

  1. What is the result of the following code?

A. One

B. Zero

C. Hello World

D. ZeroHello World

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

A. end;

B. break;

C. Stop;

D. A semicolon.

  1. Which is not a proper prototype?

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

B. double funct(char x)

C. void funct();

D. char x();

  1. 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

  1. 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"}

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

A. if expression

B. if { expression

C. if ( expression )

D. expression if

  1. 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.

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

A. :=

B. =

C. equal

D. = =

  1. Which conversion is not possible?

A. int to float

B. float to int

C. char to float

D. All are possible

  1. 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

  1. What is the output of this program?

a) execute

b) not execute

c) none of the mentioned

d) both a & b

  1. 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;

  1. Where does the object is created?

a) class

b) constructor

c) destructor

d) attributes

  1. How to access the object in the class?

a) scope resolution operator

b) ternary operator

c) direct member access operator

d) none of the mentioned

  1. What is the output of the following program?

a) 210

b) 213

c) 215

d) 217

  1. How many objects can present in a single class?

a) 1

b) 2

c) 3

d) as many as possible

  1. What is the output of this program?

a) 10

b) 11

c) 20

d) 22

  1. Void pointer can point to which type of objects?

a) int

b) float

c) double

d) all of the mentioned

  1. What is the output of this program?

a) 6

b) 5

c) 4

d) 7

  1. How to declare operator function?

a) operator operator sign

b) operator

c) operator sign

d) None of the mentioned

  1. What is the output of this program?

a) 10 10

b) 11 11

c) error

d) runtime error

  1. Operator overloading is

a) making c++ operator works with objects

b) giving new meaning to existing operator

c) making new operator

d) both a & b

  1. What is the output of this program?

a) 8, memory address

b) 8.14

c) memory address

d) none of the mentioned

  1. Which refrence modifier is used to define reference variable?

a) &

b) $

c) #

d) none of the mentioned

  1. What is the output of this program?

a) In swap 105 In main 105

b) In swap 105 In main 510

c) In swap 510 In main 105

d) none of the mentioned

  1. What is the output of this program?

a) 15 18 21

b) 21 21 21

c) 24 24 24

d) Compile time error

  1. Which can be can be used to create a random number without duplication?

a) Character

b) Time

c) Both a & b

d) None of the mentioned

  1. Which character is used to terminate the string?

a) $

b) Null

c) Empty

d) None of the mentioned

  1. What is the output of this program?

a) Steve Jobs

b) Apple

c) Jobs Apple Steve

d) None of the mentioned

  1. How many sizes do integers come in?

a) 1

b) 2

c) 3

d) 4

  1. In which type does the enumerators are stored by the compiler?

a) string

b) integer

c) float

d) none of the mentioned

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]