0% found this document useful (0 votes)
88 views17 pages

CSC201 Past Questions and Answers

Uploaded by

bundlevibes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
88 views17 pages

CSC201 Past Questions and Answers

Uploaded by

bundlevibes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 17

NNAMDI AZIKIWE UNIVERSITY AWKA

FACULTY OF PHYSICAL SCIENCES


DEPARTMENT OF COMPUTER SCIENCE

COURSE CODE: CSC 201


COURSE TITLE: INTRODUCTION TO COMPUTER PROGRAMMING I
ITEM: PAST QUESTIONS & ANSWERS

1. A Translator which is used to convert codes written in high level languages to a machine
language is known as ____________
(A). Assembler
(B). Debugger
(C). Compiler
(D). Converter
(Ans) C
2. Errors in a computer program are referred to as ________
(A). Mistakes
(B). Bugs
(C). None of the above
(D). Crash
(Ans) B
3. What is the size of int data type in C++?
(A). 2 Bytes
(B). 4 Bytes
(C). 1 Byte
(D). 8 Bytes
(Ans) A
4-6 In C++, assume variable A holds 2 and variable B holds7 then arithmetic operation
4. B*A gives _______________
(A) 9
(B) 14
(C) 49
(D) -14
(Ans) B
5. B%A gives ____________
(A) 0
(B) 3
(C) 1
(D) 2
(Ans) C

6. (A+B)*2 gives _____________


(A) 18
(B) 49
(C) -81
(D) 63
(Ans) A
7. Which of the following lines of C++ code correctly takes input and stores into the menu
variable?
(A). cout << “menu: ”<< menu<< endl;
(B). cin >> menu;
(C). cin >> “menu” >> endl;
(D). cout << menu << endl;
(Ans) B
8. A C++ code line ends with _______________
(A) Fullstop(.)
(B) Semicolon (;)
(C) Slash (/)
(D) Comma (,)
(Ans) B
9. A variable is a symbol that represents ___________
(A) a number
(B) a string
(C) a storage location in the computer memory
(D) an expression
(Ans) C
10. _______________ is the language that is directly understood by a computer.
(A) Machine Language
(B) Assembly Language
(C) Modelling Language
(D) High-level Language
(Ans) A
11. ________ is a step by step procedure designed to solve a given problem in a finite time.
(A) Algorithm
(B) Computer
(C) Modelling
(D) Flowchart
(Ans) A
12. ___________ is a predefined object in C++ that corresponds to the standard input stream.
(A) cout
(B) input
(C) iostream
(D) cin
(Ans) D
13. The following are valid variable names in C++ except
(A) age
(B) s+um
(C) sum
(D) agesum
(Ans) B
14. __________ is the process of finding errors and fixing them within a program.
(A) Compiling
(B) Executing
(C) Debugging
(D) Scanning
(Ans) C

15-17. In C++, assume C = 20, then the assignment operation


15. C+=25 will give out C as___________
(A) 40
(B) 20
(C) 45
(D) 25
(Ans) C
16. C%=2 will give out C as___________
(A) 40
(B) 0
(C) 45
(D) 10
(Ans) B
17. C*=25 will give out C as___________
(A) 500
(B) 20
(C) 400
(D) 50
(Ans) A
18. Which of the following is used for comments in C++?
(A) /* comment */
(B) // comment */
(C) // comment
(D) both // comment or /* comment */
(Ans) D

19. Which of the following is a correct identifier in C++?


(A) VAR_1234
(B) var+name
(C) 7VARNAME
(D) 7var_name
(ANS) A
20. Which of the following symbol is used to declare the preprocessor directives in C++?
(A) $
(B) ^
(C) #
(D) *
(ANS) C
21. Who invented C++?
(A) Dennis Ritchie
(B) Ken Thompson
(C) Brian Kernighan
(D) Bjarne Stroustrup
(ANS) D
22. C++ is superset of which langauge?
(A) BASIC
(B) VB
(C) PASCAL
(D) C
(ANS) D
23. What is size of void in C++?
(A) 2 Bytes
(B) 4 Bytes
(C) Undefined
(D) 0
(ANS) D
24. What is Inheritance in C++?
(A) Deriving new classes from existing classes
(B) Overloading of classes
(C) Classes with same names
(D) Wrapping of data into a single class
(ANS) A
25. Which of the following type of class allows only one object of it to be created?
A. Virtual class
B. Abstract class
C. Singleton class
D. Friend class
Ans. C
26. Which of the following is not a type of constructor?
A. Copy constructor
B. Friend constructor
C. Default constructor
D. Parameterized constructor
Ans. B
27. Which of the following statements is correct?
A. Base class pointer cannot point to derived class.
B. Derived class pointer cannot point to base class.
C. Pointer to derived class cannot be created.
D. Pointer to base class cannot be created.
Ans. B
28. Which of the following is not the member of class?
A. Static function
B. Friend function
C. Const function
D. Virtual function
Ans. B
30. Which of the following concepts means determining at runtime what method to invoke?
A. Data hiding
B. Dynamic Typing
C. Dynamic binding
D. Dynamic loading
Ans. C
31. Which of the following term is used for a function defined inside a class?
A. Member Variable
B. Member function
C. Class function
D. Classic function
Ans. B
32. Which of the following concept of oops allows compiler to insert arguments in a function call if it is
not specified?
A. Call by value
B. Call by reference
C. Default arguments
D. Call by pointer
Ans. C
33. How many instances of an abstract class can be created?
A. 1
B. 5
C. 13
D. 0
Ans. D
34. Which of the following cannot be friend?
A. Function
B. Class
C. Object
D. Operator function
Ans. C
35. Which of the following concepts of OOPS means exposing only necessary information to client?
A. Encapsulation
B. Abstraction
C. Data hiding
D. Data binding
Ans. C
36. Why reference is not same as a pointer?

A. A reference can never be null.


B. A reference once established cannot be changed.
C. Reference doesn't need an explicit dereferencing mechanism.
D. All of the above.
Ans. D
37. cout is a/an __________ .
A. operator
B. function
C. object
D. macro
Ans. C
38. Which of the following concepts provides facility of using object of one class inside another class?
A. Encapsulation
B. Abstraction
C. Composition
D. Inheritance
Ans. C
39. How many types of polymorphisms are supported by C++?
A. 1
B. 2
C. 3
D. 4
Ans. B
40. Which of the following is an abstract data type?
A. int
B. double
C. string
D. Class
Ans. D
41. Which of the following concepts means adding new components to a program as it runs?

A. Data hiding
B. Dynamic typing
C. Dynamic binding
D. Dynamic loading
Ans. D
42. Which of the following statement is correct?

A. A constructor is called at the time of declaration of an object.


B. A constructor is called at the time of use of an object.
C. A constructor is called at the time of declaration of a class.
D. A constructor is called at the time of use of a class.
Ans. A
43. Which of the following correctly describes overloading of functions?
A. Virtual polymorphism
B. Transient polymorphism
C. Ad-hoc polymorphism
D. Pseudo polymorphism
Ans. C
44. Which of the following approach is adapted by C++?
A. Top-down
B. Bottom-up
C. Right-left
D. Left-right
Ans. B
45. Which of the following is correct about function overloading?
A. The types of arguments are different.
B. The order of argument is different.
C. The number of argument is same.
D. Both A and B.
Ans. D
46. 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.
Ans. D
47. Which of the following concepts means wrapping up of data and functions together?
A. Abstraction
B. Encapsulation
C. Inheritance
D. Polymorphism
Ans. B
48. Which of the following concepts means waiting until runtime to determine which function to call?
A. Data hiding
B. Dynamic casting
C. Dynamic binding
D. Dynamic loading
Ans. C
49. How "Late binding" is implemented in C++?

A. Using C++ tables


B. Using Virtual tables
C. Using Indexed virtual tables
D. Using polymorphic tables
Ans. B
50. Which of the following operator is overloaded for object cout?
A. >>
B. <<
C. +
D. =
Ans. B
51. Which of the following is the correct class of the object cout?
A. iostream
B. istream
C. ostream
D. ifstream
Ans. C
52. Which of the following cannot be used with the keyword virtual?
A. class
B. member functions
C. constructor
D. destructor
Ans. C
53. Which of the following functions are performed by a constructor?
A. Construct a new class
B. Construct a new object
C. Construct a new function
D. Initialize objects
Ans. D
54. 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.
Ans. D
55. 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
Ans. B
56. Which of the following is the correct way of declaring a function as constant?
A. const int ShowData(void) { /* statements */ }
B. int const ShowData(void) { /* statements */ }
C. int ShowData(void) const { /* statements */ }
D. Both A and B
Ans. C
57. Which of the following concepts is used to implement late binding?
A. Virtual function
B. Operator function
C. Const function
D. Static function
Ans. A
58. Which of the following statement is correct?

A. C++ allows static type checking.


B. C++ allows dynamic type checking.
C. C++ allows static member function be of type const.
D. Both A and B.
Ans. D
59. Which of the following factors supports the statement that reusability is a desirable feature of a
language?

A. It decreases the testing time.


B. It lowers the maintenance cost.
C. It reduces the compilation time.
D. Both A and B.
Ans. D
60. Which of the following ways are legal to access a class data member using this pointer?

A. this->x
B. this.x
C. *this.x
D. *this-x
Ans. A
61. Which of the following is correct about the statements given below?

All operators can be overloaded in C++.


We can change the basic meaning of an operator in C++.
A. Only I is true.
B. Both I and II are false.
C. Only II is true.
D. Both I and II are true.
Ans. B
62.
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.
Ans. D
63. Which of the following are available only in the class hierarchy chain?

A. Public data members


B. Private data members
C. Protected data members
D. Member functions
Ans. C
64. Which of the following is not a type of inheritance?

A. Multiple
B. Multilevel
C. Distributive
D. Hierarchical
Ans. C
65. Which of the following operators cannot be overloaded?

A. []
B. ->
C. ?:
D. *
Ans. C
66. In which of the following a virtual call is resolved at the time of compilation?

A. From inside the destructor.


B. From inside the constructor.
C. From inside the main().
D. Both A and B.
Ans. D
67. Which of the following statements regarding inline functions is correct?

A. It speeds up execution.
B. It slows down execution.
C. It increases the code size.
D. Both A and C.
Ans. D
68. 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;
Ans. C
69. Which of the following header file includes definition of cin and cout?

A. istream.h
B. ostream.h
C. iomanip.h
D. iostream.h
Ans. D
70. Which of the following keyword is used to overload an operator?

A. overload
B. operator
C. friend
D. override
Ans. B
71. What will happen if a class is not having any name?

A. It cannot have a destructor.


B. It cannot have a constructor.
C. It is not allowed.
D. Both A and B.
Ans. D
72. Which inheritance type is used in the class given below?
class A : public X, public Y
{}

A. Multilevel inheritance
B. Multiple inheritance
C. Hybrid inheritance
D. Hierarchical Inheritance
Ans. B
73. Which one of the following is correct about the statements given below?

All function calls are resolved at compile-time in Procedure Oriented Programming.


All function calls are resolved at compile-time in OOPS.
A. Only II is correct.
B. Both I and II are correct.
C. Only I is correct.
D. Both I and II are incorrect.
Ans. C
74. Which of the following is an invalid visibility label while inheriting a class?

A. public
B. private
C. protected
D. friend
Ans. D
75. 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);
Ans. A
76. 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.
Ans. C
77. 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.
Ans. C
78. Which of the following statement is correct?

A. Two functions having same number of argument, order and type of argument can be overloaded
if both functions do not have any default argument.
B. Overloaded function must have default arguments.
C. Overloaded function must have default arguments starting from the left of argument list.
D. A function can be overloaded more than once.
Ans. D
79. 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.
Ans. A
80. Which of the following statement is incorrect?

A. Default arguments can be provided for pointers to functions.


B. A function can have all its arguments as default.
C. Default argument cannot be provided for pointers to functions.
D. A default argument cannot be redefined in later declaration.
Ans. C
81. Which of the following statement is correct?

A. Constructors can have default parameters.


B. Constructors cannot have default parameters.
C. Constructors cannot have more than one default parameter.
D. Constructors can have at most five default parameters.
Ans. A
82. Which of the following function / type of function cannot be overloaded?

A. Member function
B. Static function
C. Virtual function
D. Both B and C
Ans. C
83. Which of the following function declaration is/are incorrect?

A. int Sum(int a, int b = 2, int c = 3);


B. int Sum(int a = 5, int b);
C. int Sum(int a = 0, int b, int c = 3);
D. Both B and C are incorrect.
E. All are correct.
Ans. D
84. Which of the following statement is incorrect?

A. The default value for an argument can be a global constant.


B. The default arguments are given in the function prototype.
C. Compiler uses the prototype information to build a call, not the function definition.
D. The default arguments are given in the function prototype and should be repeated in the
function definition.
Ans. D
85. Where the default value of parameter have to be specified?
A. Function call
B. Function definition
C. Function prototype
D. Both B or C
Ans. C
86. Which of the following statement is correct?

A. The default value for an argument cannot be function call.


B. C++ allows the redefinition of a default parameter.
C. Both A and B.
D. C++ does not allow the redefinition of a default parameter.
Ans. D
87. Which of the following statement is correct?

A. Only one parameter of a function can be a default parameter.


B. Minimum one parameter of a function must be a default parameter.
C. All the parameters of a function can be default parameters.
D. No parameter of a function can be default.
Ans. C
88. Which of the following statement is incorrect?

A. A default argument is checked for type at the time of declaration and evaluated at the time of
call.
B. We can provide a default value to a particular argument in the middle of an argument list.
C. We cannot provide a default value to a particular argument in the middle of an argument list.
D. Default arguments are useful in situations where some arguments always have the same value.
Ans. B
89. Which of the following statement is correct?

A. Overloaded functions can accept same number of arguments.


B. Overloaded functions always return value of same data type.
C. Overloaded functions can accept only same number and same type of arguments.
D. Overloaded functions can accept only different number and different type of arguments.
Ans. A
90. Which of the following function / types of function cannot have default parameters?

A. Member function of class


B. main()
C. Member function of structure
D. Both B and C
Ans. B
91. Which of the following statement is correct?

A. The order of the default argument will be right to left.


B. The order of the default argument will be left to right.
C. The order of the default argument will be alternate.
D. The order of the default argument will be random.
Ans. A
92. 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.
Ans. B
93. Which of the following statements is correct?

Once a reference variable has been defined to refer to a particular variable it can refer to any other
variable.
A reference is not a constant pointer.
A. Only 1 is correct.
B. Only 2 is correct.
C. Both 1 and 2 are correct.
D. Both 1 and 2 are incorrect.
Ans. D
94. Functions can be declared to return a reference type. There are reasons to make such a
declaration/Which of the following reasons are correct?

The information being returned is a large enough object that returning a reference is more efficient than
returning a copy.
The type of the function must be a R-value.
A. Only 1 is correct.
B. Only 2 is correct.
C. Both 1 and 2 are correct.
D. Both 1 and 2 are incorrect.
Ans. C
95. Which of the following statements is correct?

Change a reference changes the referent.


We can create an array of references.
A. Only 1 is correct.
B. Only 2 is correct.
C. Both 1 and 2 are correct.
D. Both 1 and 2 are incorrect.
Ans. A
96. Which of the following statement is correct about the references?

A. A reference must always be initialized within functions.


B. A reference must always be initialized outside all functions.
C. A reference must always be initialized.
D. Both A and C.
Ans. C
97.
A reference is declared using the _____ symbol.

A. &&
B. &
C. ||
D. !
Ans. B
98. 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.
Ans. C
99. Which of the following statements is correct?

A reference is not a constant pointer.


A referenced is automatically de-referenced.
A. Only 1 is correct.
B. Only 2 is correct.
C. Both 1 and 2 are correct.
D. Both 1 and 2 are incorrect.
Ans. B
100. Which of the following statement is correct?

A. A referenced has to be de-referenced to access a value.


B. A referenced does not need to be de-referenced to access a value.
C. A referenced has to be double de-referenced to access a value.
D. Whether a reference should be de-referenced or not depends on the type of the reference.
Ans. B
101.

You might also like