Đề thi trắc nghiệm lập trình c

115 843 1
Đề thi trắc nghiệm lập trình c

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

BÀI THI TRẮC NGHIỆM ĐỀ SỐ: 501 What value is stored in x after the following two statements are executed: int x; x = / * / 2; A B 0.0625 C D 1.0 Which of the following statements will correctly output the quote: Dan Quayle once said, "Who’s responsible for the riots? The rioters." A cout using namespace std; 12 Which of the following functions correctly returns the minimum of three integers passed in? A B C D 13 3223 B 3211 C 3212 D 3213 14 X =1 Y = B X =1 Y = C X =2 Y = D X =2 Y = 15 Which of the following function prototypes is equivalent to the following prototype? int min(int num1, int num2, int num3); A int min(long num1, long num2, long num3); B 31 A 03 B 13 C This program will crash because we did not initialize f1 D 33 32 Money m1(10,50), m2(10,50); A B C D 33 A In default constructor Printing Printing B In default constructor Printing In default constructor Printing C In default constructor In default constructor Printing Printing D Printing Printing 34 A val1=1 val2=1 val1=2 val2=2 val1=3 val2=2 B val1=2 val2=1 val1=2 val2=2 val1=2 val2=2 C val1=0 val2=1 val1=0 val2=2 val1=0 val2=2 D val1=2 val2=1 val1=2 val2=2 val1=3 val2=2 35 A Nothing B Num1 and Num3 are the same C Num1 and Num2 are the same D An error message We are not allowed to compare class objects using == 36 A 55 B 10 C 10 10 D An error message will result because we have not overloaded the = operator 37 Which of the following is not allowed in overloading a function? A Two functions have the same name and one takes parameters of type integer while another takes parameters of type long B Two functions have identical parameter lists but different return types C Two functions can have the same name D Two functions have the same name and the same type of parameters, but one function takes two parameters while the other takes only one parameter 38 How would we initialize the following structure to contain and upon declaring the variable of type Foo? struct Stuff { int val2; }; struct Foo { int num; Stuff val1; }; A Foo x = {1, 2}; B Foo x = {1, {2}}; C Foo x = {{1,2}}; D Foo x = {1, {2}}; 39 A The constructor must have a return type of void in the implementation B There should be no parentheses when declaring the variable f1 and invoking the default constructor C In the definition of the constructor, the return type of void should be specified D There should be no semicolon after the right curly brace in the definition of the Foo class 40 Which of the following is not a valid reason to declare a class parameter as const? e.g.: void someFunction(const FooClass &); A When you want to pass the class by reference.X B When you want to ensure the programmer does not change the contents of a class variable inside a function C It is more efficient to pass a class by value than by reference D When you would like an indicator that the intended use of the class variable is that it should not be changed inside the function 41 A B C D 42 A B C D 43 Which of the following is not a valid reason to use const in the declaration below? const Money operator +(const Money &, const Money &); A When we want to improve the efficiency of the program by passing the arguments as call by reference B When we would like the compiler to flag as errors subtle bugs that may result when class objects are changed C When we want to be able to directly modify the class that is returned D When we want to ensure that the programmer cannot change the objects within the function definition [...]... definition? struct BankAccount{ int ID; double amount; } "ID" cannot be all uppercase B The keyword "struct" should be "structure" C Different data types are not allowed in the struct D There is a semicolon missing after the right curly brace 30 Under the principle of information hiding, which class definition best encapsulated the variable named "x"? A B C D 31 Money m1(10,50), m2(10,50); A B C D 32 A... to use const in the declaration below? const Money operator +(const Money &, const Money &); A When we want to ensure that the programmer cannot change the objects within the function definition B When we want to improve the efficiency of the program by passing the arguments as call by reference C When we want to be able to directly modify the class that is returned D When we would like the compiler... definition? class BankAccount{ public: int ID; double amount; } A There are no methods B There are no private variables C There is a missing semicolon after the right curly brace D There are no public accessor methods 28 Given the following declaration, how do we access the x and y members of the structure? struct Point { int x; int y; }; A Point p; p->x = 10; p->y = 20; B Point p; p::x = 10; p::y = 20; C Point... val2=2 C val1=2 val2=1 val1=2 val2=2 val1=3 val2=2 D val1=1 val2=1 val1=2 val2=2 val1=3 val2=2 33 A void main(){ cout ... C There is a missing semicolon after the right curly brace D There are no public accessor methods 28 Given the following declaration, how we access the x and y members of the structure? struct... directly modify the class that is returned D When we would like the compiler to flag as errors subtle bugs that may result when class objects are changed 43 A B C D BÀI THI TR C NGHIỆM ĐỀ SỐ:... access functions such as abs, rand, or exit, what should be added to the top of the program? #include < iostream> using namespace std; B #include < cmath> using namespace std; C #include < cstdlib>

Ngày đăng: 04/12/2015, 01:40

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan