Вы находитесь на странице: 1из 10

7262-23-352

e-Quals Diploma for IT Practitioners (Software Development)


Develop software using C++
Sample paper

This paper contains


40 questions.

© The City and Guilds of London Institute 2004


Develop software using C++

Outcome 1 – Interpret program specifications to develop software

1. The syntax for a comment is


a) (*This is a comment *)
b) //This is a comment
c) /This is a comment /
d) */This is a comment/*.

2. Programs are designed


a) to provide user documentation
b) after testing has been completed
c) before a specification is written
d) to improve the reliability of the code.

3. Validation is performed to prevent


a) invalid input data
b) logical errors
c) invalid output data
d) compilation errors.

4. Indentation is used in code to


a) improve its readability
b) increase compilation time
c) comply with the design specification
d) improve its appearance.

5. Iteration is achieved using


a) if
b) cout
c) switch
d) while.

6. When coding a program


a) the design can be adapted
b) there should be consistency
c) the test plan must be written
d) iterations should be avoided.

Outcome 2 – Develop software components

7. An array of structures
a) must always be declared globally
b) cannot be declared locally
c) never uses the structure name in the declaration
d) uses a variable name in the declaration.

2 See next page


8. A switch statement
a) performs iteration on every selection
b) must always include a default statement
c) uses selection to perform one or more tasks
d) can only be used for a maximum of 4 selections.

9. char addressLine[45];

Refer to the figure above. The maximum number of characters that could be
stored in the string variable addressLine is

a) 43
b) 44
c) 45
d) unlimited.

10. The array cost holds the following data.

25.99 14.55 33.65 25.25 45.99 4.99 17.85

What is the value in the variable costnum after the following statement is
executed?
costnum = cost[4];

a) 4.99
b) 25.25
c) 33.65
d) 45.99.

11. int a=35;


a /= 5;
cout << "a is " << a << endl;

Refer to the figure above. The output from the code is


a) a is 0
b) a is 5
c) a is 7
d) a is 35.

12. To retain its value between function calls, a local variable must be declared as
a) extern
b) persistent
c) auto
d) static.

3 See next page


Outcome 3 – Use functions

13. A variable passed by value to a function means the function is passed


a) the address of the variable
b) the address of a pointer to the variable
c) a copy of the name of the variable
d) a copy of the variable value.

14. The reference operator & is used in a function prototype to


a) specify an address for an array is to be passed
b) specify a memory address is to be passed
c) specify a value is to be passed
d) concatenate two parameters.

15. char search(char[], int);

Refer to the figure above. The type of the function prototype is


a) long
b) float
c) char
d) int.

16. int funcB(float, int);

Refer to the figure above. Which one of the following is an INVALID function
prototype to overload the function?
a) float funcB(float, int);
b) float funcB(double, float);
c) int funcB(float);
d) int funcB(short);

17. void printlist(const int list[]);

Refer to the figure above. The list parameter is passed so that


a) the address of each element is passed
b) the data values cannot be altered
c) all the data elements are passed separately
d) the data values can be altered.

18. The correct syntax for a function prototype for calcSum that returns an integer
and is passed a float and an integer is
a) calcSum(int, float, int);
b) int calcSum(float, int);
c) void calcSum(float, int);
d) int calcSum(int, float);

4 See next page


Outcome 4 – Use pre-defined functions

19. char town[31] = {"Horsham"};


char street[20] = {"Church Road "};
strcat(street,town);
cout << street;

Refer to the figure above. The output after executing the code is
a) HorshamChurch Road
b) Horsham Church Road
c) Church Road Horsham
d) Church RoadHorsham.

20. char play[25] = {"Hamlet"};


int len;
len = strlen(play);

Refer to the figure above. The value in len after executing the code is
a) 0
b) 5
c) 6
d) 7.

21. A #define directive can be used to declare


a) a function
b) a variable
c) enumeration types
d) a constant

22. The correct declaration of a constant named RATE is


a) const int RATE = 10;
b) const RATE 10;
c) const int RATE 10;
d) const int=10;

23. A user defined header file can be delared as


a) #include <”c:\customer.lib”>
b) #include ‘c:\customer.h’
c) #include <c:\customer.h>
d) #include ”c:\customer.h”

24. A data item of type const is declared


a) as an attribute of a class
b) with no initial value
c) within a function or outside a class
d) with a value defined by the C++ language.

5 See next page


Outcome 5 – Save and retrieve data from disc

25. An access mode of "ios::out" is used to


a) open a new output file
b) open a new input file
c) add data to the end of an input file
d) add data to the end of an output file.

26. Which file stream is used to output data to disk?


a) Instream
b) outstream
c) istream
d) ostream.

27. In the hierarchy of file streams


a) all file streams are the same level
b) fstream is of higher hierarchy than ifstream and ofstream
c) both ifstream and ofstream include fstream
d) instream takes precedence for all output files.

28. A file object is required as


a) it holds the file mode only
b) the file will close without it
c) it holds the file location and mode
d) only the file location is referenced.

Outcome 6 – Use object orientated programming (OOP)

29. An inline function


a) can be accessed only by a friend class
b) has its code inserted for every call made to it
c) is never executed
d) has its code held only once in memory.

30. The declaration for the constructor for a class named checkValid, which takes
two integer parameters, is
a) void checkValid(int, int);
b) int checkValid(int, int);
c) checkValid(int, int);
d) checkValid(int);

31. The main components of an object consist of


a) attributes / destructors / methods
b) interfaces / attributes / methods
c) interfaces / attributes / destructors
d) constructors / attributes / methods

6 See next page


32. The following segment of code shown is a class

class equals
{

public:
void validate( );
};

a) declaration
b) description
c) instance
d) structure.

33. Attributes listed in the private area of a class declaration


a) must be initialised by a constructor
b) cannot be accessed by friend functions
c) can be used by all methods of this class
d) are available to any derived classes.

34. Object orientated programming


a) allows existing code modules to be reused
b) does not include encapsulation
c) makes all of its data available
d) allows encapsulation into multiple entities.

Outcome 7 – Describe the principles of software testing and management

35. Which one of the following lines of code will cause a syntax error?
a) num = ++count1;
b) int a=195, b=2;
c) float x=10.56, y =5.75;
d) a = b+3+;

36. Which one of the following is TRUE?


a) Components that pass data correctly to each other are integrated.
b) Components that pass data correctly to each other are interfaced.
c) Interfacing and integration serve the same purpose.
d) Integration provides a single interface description.

37. Which one of the following will cause a run-time error?


a) Omitting comments from code.
b) Opening a non-existent file.
c) Addressing inside the bounds of an array.
d) Reading an existing file.

38. A dry run is performed to


a) check the design specification is correct
b) check the logic of software without a computer
c) test that software interfaces correctly
d) test that software integrates correctly.

7 See next page


Outcome 8 – Produce documentation

39. Technical documentation is required to


a) aid reusability
b) make software run faster
c) provide user instructions
d) decrease development time.

40. End user instructions should always


a) include the results of testing
b) aid program maintenance
c) be compiled during testing
d) be clear and unambiguous.

8 See next page


ANSWER KEY
Paper number: 7262-23-352
Paper title: Develop software using C++

Question Correct answer


1. B
2. D
3. A
4. A
5. D
6. B
7. D
8. C
9. B
10. D
11. C
12. D
13. D
14. B
15. C
16. A
17. B
18. B
19. C
20. C
21. D
22. A
23. D
24. C
25. A
26. D
27. B
28. C

9 See next page


29. B
30. C
31. B
32. A
33. C
34. A
35. D
36. B
37. B
38. B
39. A
40. D

10 See next page

Вам также может понравиться