High Level Programming MCQ - 240427 - 171534

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

lOMoAR cPSD| 23221915

HIGH LEVEL PROGRAMMING MCQ HIGH LEVEL PROGRAMMING MCQ

8) A variable defined within a block is visible


1) Which of the following is not a type A. From the point of definition onward in
of constructor? the program
A. Copy constructor B. From the point of definition onward in
B. Friend constructor the function
C. Default constructor C. From the point of definition onward in
D. Parameterized constructor the block
Answer: B D. Throughout the function
Answer: C
2) Which of the following is not the member
of class? 9) Which of the following term is used for
A. Static function a function defined inside a class?
B. Friend function A. Member Variable
C. Const function B. Member function
D. Virtual function C. Class function
Answer: B D. Classic function
Answer: B
3) Which of the following concepts
means determining at runtime what 10) Which of the following concept of
method to invoke? oops allows compiler to insert arguments
A. Data hiding in a function call if it is not specified?
B. Dynamic Typing A. Call by value
C. Dynamic binding B. Call by reference
D. Dynamic loading C. Default arguments
Answer: C D. Call by pointer
Answer: C
4) The friend functions are used in
situations where: 11) How many instances of an abstract
A. We want to have access to unrelated classes class can be created?
B. Dynamic binding is required A. 1
C. Exchange of data between classes to B. 5
take place C. 13
D. None of the above D. 0
Answer: D Answer: D

5) The keyword friend does not appear in 12) Which of the following cannot be friend?
A. The class allowing access to another class A. Function
B. The class desiring access to another class B. Class
C. The private section of a class C. Object
D. The public section of a class D. Operator function
Answer: C Answer: C

6) The term __________ means the ability to 13) Which of the following concepts of OOPS
take many forms. means exposing only necessary information
A. Inheritance to client?
B. Polymorphism A. Encapsulation
C. Member function B. Abstraction
D. Encapsulation C. Data hiding
Answer: B D. Data binding
Answer: C
7) C++ was originally developed by
A. Clocksin and Melish
B. Donald E.Knuth
C. Sir Richard Hadlee
D. Bjarne Stroustrup
Answer: D
lOMoAR cPSD| 23221915

14) In structured programming, the problem 21) Preventing direct access of data-members
is divided into various ______. of the class from outside world is known as
A. modules ____.
B. functions (A)Polymorphism
C. structures (B)Encapsulation
D. objects (C)Data Hiding
Answer: B (D) scope resolution.
15) In Object-oriented programming, Answer: C
the problem is divided into _____.
A. classes & objects 22) What are cin and cout?
B. functions (A) pointers
C. structures (B) functions
D. modules (C) operator
Answer: A (D) stream objects
Answer: C
16) A class is ____ datatype.
A. primitive 23) Which header file must be included for
B. derived cin and cout?
C. user-defined (A) stdio.h
D. All of these (B) conio.h
Answer: C (C) iostream.h
(D) Both iostream.h and conio.h
17) A class is a collection of ____ and_____. Answer: C
(A)data-members & member functions
(B)data-members, member functions 24) Creating a new class using one or
and main() more existing classes is known as ____.
(C) data-members, member (A)Polymorphism
functions,main() and include statements (B)Encapsulation
(D)None of these (C)overloading
Answer: A (D)inheritance
Answer: D
18) An object is ......
(A)a variable of class datatype. 25) Ability of an operator or function call
(B)same as a class. to take different forms is known as ____.
(C)just like a global variable. (A) Polymorphism
(D)collection of data-members and (B) Encapsulation
member functions. (C) overloading
Answer: A (D)inheritance
Answer: A
19) Wrapping up of data & functions 26) cout is a/an __________ .
together in a class is known as _____. A. operator
(A)Overloading B. function
(B) Data Abstraction C. object
(C) Polymorphism D. macro
(D)Encapsulation Answer: C
Answer: D
27) Which of the following concepts
20) Including only necessary details and provides facility of using object of one class
ignoring additional details while defining inside another class?
a class is known as ____. A. Encapsulation
(A) Overloading B. Abstraction
(B) Data Abstraction C. Composition
(C) Polymorphism D. Inheritance
(D) Encapsulation Answer: C
Answer: B
lOMoAR cPSD| 23221915

34) Which of the following is correct


28) How many types of polymorphisms about class and structure?
are supported by C++? A. class can have member functions
A. 1 while structure cannot.
B. 2 B. class data members are public by
C. 3 default while that of structure are private.
D. 4 C. Pointer to structure or classes cannot
Answer: B be declared.
D. class data members are private by default
29) Which of the following is an abstract while that of structure are public by default.
data type? Answer: D
A. int
B. double 35) Which of the following concepts means
C. string wrapping up of data and functions together?
D. Class A. Abstraction
Answer: D B. Encapsulation
C. Inheritance
30) A __________ is a special method used to D. Polymorphism
initialize the instance variable of a class. Answer: B
A. Member function
B. Destructor 36) Which of the following concepts
C. Constructor means waiting until runtime to determine
D. Structure which function to call?
Answer: C A. Data hiding
B. Dynamic casting
31) Which of the following concepts C. Dynamic binding
means adding new components to a D. Dynamic loading
program as it runs? Answer: C
A. Data hiding
B. Dynamic typing 37) Which of the following operator
C. Dynamic binding is overloaded for object cout?
D. Dynamic loading A. >>
Answer: D B. <<
C. +
32) Which of the following statement D. =
is correct? Answer: B
A. A constructor is called at the time
of declaration of an object. 39) Which of the following is the correct
B. A constructor is called at the time of use class of the object cout?
of an object. A. iostream
C. A constructor is called at the time B. istream
of declaration of a class. C. ostream
D. A constructor is called at the time of use of D. ifstream
a class. Answer: C
Answer: A
40) Which of the following cannot be used
33) Which of the following approach is with the keyword virtual?
adapted by C++? A. class
A. Top-down B. member functions
B. Bottom-up C. constructor
C. Right-left D. destructor
D. Left-right Answer: C
Answer: B
lOMoAR cPSD| 23221915

41) Which of the following functions


are performed by a constructor? 47) Which one of the following options
A. Construct a new class is correct?
B. Construct a new object A. Friend function can access public
C. Construct a new function data members of the class.
D. Initialize objects B. Friend function can access protected
Answer: D data members of the class.
C. Friend function can access private
42) Which of the following is the correct way data members of the class.
of declaring a function as constant? D. All of the above.
A. const int ShowData(void) { /* statements */ Answer: D
}
B. int const ShowData(void) { /* statements */ 48) Which of the following statements
} is correct in C++?
C. int ShowData(void) const { /* statements */ A. Classes cannot have data as
} D. Both A and B protected members.
Answer: C B. Structures can have functions as members.
C. Class members are public by default.
43) Which of the following statement D. Structure members are private by default.
is correct? Answer: B
A. C++ allows static type checking.
B. C++ allows dynamic type checking. 49) Which of the following access specifier
C. C++ allows static member function be is used as a default in a class definition?
of type const. A. protected
D. Both A and B. B. public
Answer: D C. private
D. friend
44) Which of the following header file Answer: C
includes definition of cin and cout?
A. istream.h 50) What is correct about the static
B. ostream.h data member of a class?
C. iomanip.h A. A static member function can access
D. iostream.h only static data members of a class.
Answer: D B. A static data member is shared among all
the object of the class.
45) What will happen if a class is not C. A static data member can be
having any name? accessed directly from main().
A. It cannot have a destructor. D. Both A and B.
B. It cannot have a constructor. Answer: D
C. It is not allowed.
D. Both A and B. 51) Which of the following provides a
Answer: D reuse mechanism?
A. Abstraction
46) Which one of the following is correct B. Inheritance
about the statements given below? C. Dynamic binding
All function calls are resolved at compile- D. Encapsulation
time in Procedure Oriented Programming. Answer: B
All function calls are resolved at
compile-time in OOPS. 53) Which of the following statement
A. Only II is correct. is correct?
B. Both I and II are correct. A. Class is an instance of object.
C. Only I is correct. B. Object is an instance of a class.
D. Both I and II are incorrect. C. Class is an instance of data type.
Answer: C D. Object is an instance of data type.
Answer: B

Downloaded by William Turkson Sam (willturksam@gmail.com)


lOMoAR cPSD| 23221915

59) Inline Functions are invoked


53) The process of building new classes at A. Run time
from existing one is called B. Compile time
A. Structure C. Depends on how it is
B. Inheritance invoked D. Both b and c above
C. Polymorphism Answer: B
D. Template
Answer: B 60) which of the following operator is used to
define member function outside the class?
54) In a class, member variables are often A. ::
called its _________, and its member functions B. ?
are sometimes referred to as its behaviour, or C. :?
____________. D. %
A. attributes, methods Answer: A
B. none of these
C. values, morals 61) function call mechanism that passes
D. data, activities arguments to a function by passing a copy
Answer: A of the values of the arguments is __________
(A)call by name
55) Which of these keywords are (B)call by value
access specifiers? (C)call by reference
A. near and far (D)call by value result
B. opened and closed Answer: B
C. table and row
D. private and public 62) Data members which are static
Answer: D (A)cannot be assigned a value (B)can
only be used in static functions
56) An Object can be declared prior to the (C)cannot be defined in a Union
class definition (D) can be accessed outside the class
A. True Answer: B
B. False:
Answer: False 63) Which of the following is false for
cin? (A)It represents standard input.
57) Use of __________ protects data (B)It is an object of istream class.
from inadvertent modifications (C)It is a class of which stream is an object.
A. protect() member function (D)Using cin the data can be read from
B. private access specifier user’s terminal
C. class protection operator, @ Answer: C
D. none of these
Answer: B 64) It is possible to declare as a friend
(A) a member function
58) A suitable place to store Class (B) a global function
declarations is _______. (C) a class
A. none of these (D) all of the above
B. their own header files Answer: D
C. Auxiliary .cpp file
D. main .cpp files, along with 65) Given a class named Book, which of
function definitions the following is not a valid constructor?
(A)Book ( ) { }
Answer: B (B)Book ( Book b) { }
(C)Book ( Book &b) { }
(D)Book (char* author, char* title) { }
Answer: B
lOMoAR cPSD| 23221915

66) How many constructors can a class have? 71) Which of the following statements are
(A) 0 true in c++?
(B) 1 (A) Classes cannot have data as
(C) 2 public members
(D) any number (B) Structures cannot have functions
Answer: D as members
(C) Class members are public by default
66) The new operator (D) None of these
A) returns a pointer to the variable Answer: B
B) creates a variable called new
C) obtains memory for a new variable 72) The following can be declared as friend in
D) tells how much memory is available a class
Answer: C (A) an object
(B) a class
67) A static function (C) a public data member
A. should be called when an object is (D) a private data member
destroyed B. is closely connected with and Answer: B
individual object of a class
C. can be called using the class name 73) A copy constructor takes
and function name (A) no argument
D. is used when a dummy object must (B) one argument
be created (C) two arguments
Answer: C (D) arbitrary no. of arguments
Answer: B
68) We can output text to an object of
class ostream using the insertion 74) Which can be passed as an argument to
operator<< because a function?
(A) the ostream class is a stream (A) constant
(B) the insertion operator works with (B) expression
all classes (C) another function
(C) we are actually outputting to cout (D) all of the above.
(D) the insertion operator is overloaded Answer: A
in ostream
Answer: D 75) Member functions, when defined
within the class specification:
69) Which of the following is not (A) are always inline.
the characteristic of constructor ? (B) are not inline.
(A) They should be declared in the (C) are inline by default, unless they are too
public section. big or too complicated.
(B) They do not have return type. (D) are not inline by default.
(C) They can not be inherited. Answer: A
(D) They can be virtual.
Answer: D 76) An entity representing
some characteristics and
70) A class defined within another class is: behaviour is-a) object
(A) Nested class b) class
(B) Inheritance c) struct
(C) Containership d) none of the above
(D) Encapsulation Answer: A
Answer: A
lOMoAR cPSD| 23221915

77) Which of the following is not the feature 84) Which of the following features of
of OOPs? object oriented programming is false?
a) Data Encapsulation a) Data is hidden and is not available
b) Inheritance to external functions.
c) Polymorphism b) New data & functions can be added
d) None of the above easily. c) Objects may communicate with
Answer: D each other through functions.
d) Emphasis is on the procedure rather
78) The wrapping up of data and functions than data.
into a single unit is Answer: D
a) Data Abstraction b)
Data Encapsulation c) 85) The following is the C++ style
Both (a) & (b) comment a) //
d) None of the above b) /*..*/
Answer: B c) –
d) None of the above
79) Which of the following feature supports Answer: A
reusability and extensibility of classes?
a) Inheritance b) 86) Which of the following statements is
Overloading c) false? a) Every C++ program must have a
Polymorphism main(). b) In C++, white spaces and carriage
d) None of the above returns are ignored by the compiler.
Answer: A c) C++ statements terminate with semicolon.
d) Main() terminates with semicolon.
80) Inheritance is ………..in nature. Answer: D
a) Intransitive
b) Transitive 87) An identifier in C++
c) Both (a) & (b) a) Must begin with a letter only
d) None of the above b) Is not differentiated by cases
Answer: B c) Contains all characters as significant
81) ………… is the ability for a message or d) None of the above
data to be processed in more than one form Answer: C
a) Class
b) Abstraction 88) ………. Provides a value for a
c) Polymorphism variable a) declaration statement
d) None of the above b) assignment statement
Answer: C c) definition statement
d) None of the above
82) The smallest individual unit in a program is Answer: B
………
a) Keyword 89) A collection of variables referred under
b) Identifier one name
c) Token a) Structure
d) None of the above b) Class
Answer: C c) Union
d) None of the above
83) Which of the following features of Answer: A
procedure oriented programming is false
a) Large programs are divided into small 90) A memory location shared by two or
or units called functions. more different variables
b) Employs bottom-up approach in a) Structure
program design. b) Class
c) Most of the functions share global c) Union
data. d) None of the above. d) None of the above
Answer: B Answer: C
lOMoAR cPSD| 23221915

91) The constants defined using 98) << operator is


enum keyword are a) stream insertion operator
a) Symbols b) stream extraction operator
b) Enumerators c) left shift operator
c) Keywords d) None of the above
d) None of the above Answer: A
Answer: B
99) “H” is an example
92) The operator ?: is of a) character literal
a) Logical operator b) string literal
b) Relational operator c) variable
c) Conditional operator d) None of the above
d) Arithmetic operator Answer: B
Answer: C
100) Which of the following statements
93) A loop containing other loop regarding comments is false?
is a) Nested a) /*..*/
b) Inner b) Comment beginning with // extends to
c) Outer the end of the line
d) None of the above c) Comments may be nested
Answer: A d) Comments are used to describe a program
Answer: C
94) The following statement forces the
next iteration of the loop to take place 101) C++ is
a) break b) a) Procedural programming language
continue b) Structural programming language
c) goto c) Object oriented programming language
d) None of the above d) None of the above
Answer: B Answer: C

95) gets() function is available in 102) y=x=2; in C++ will result


a) stdio.h in a) compilation error
b) string.h b) runtime error
c) ctype.h c) assignment of value to x then to
d) stdlib.h y d) None of the above
Answer: A Answer: C

96) In C++, the statements are enclosed 103) 31. In C++, ………. is the
within a) parenthesis statement terminator
b) square brackets a) semicolon
c) curly brackets d) b) colon
None of the above c) new line
Answer: C d) None of the above
Answer: A
97) The following tells the compiler where
the program begins 104) Modules operator (%) has
a) Function prototype higher precedence than
b) Forward declaration of a) Divide (/) operator b)
class c) main() Multiply (*) operator c)
d) None of the above Negation (unary minus) d)
Answer: C Bitwise left shift operator
Answer: C
lOMoAR cPSD| 23221915

105) The result of the following statement 110) Data members and member functions
is int y = 7; are enclosed within
int ans = ++y; a) class
cout<<”ans=”<<ans; b) structure
cout<<”y”<<y; c) union
a) ans=7, y=7 d) None of the above
b) ans=8,y=7 Answer: A
c) ans=8,y=8;
d) none of the above 111) Inline functions are
Answer: C a) Declared in the class defined outside
the class
106) Consider the following if b) Defined outside the class using
construct If(x=0) keyword intime
cout<<”Inside loop!”; c) Defined inside the class using keyword inline
cout<<”Outside loop”; d) None of the above
The result of the above code segment Answer: B
is. a) inside loop
b) outside loop 112) The default class access scope
c) both (a) & (b) is a) Private
d) none of the above b) Public
Answer: B c) Protected
d) None of the
107) The result of 2 & 3 is above Answer: A
a) 2
b) 3 113) The default scope for a structure
c) 5 is a) Private
d) none of the above b) Public
Answer: A c) Protected
d) None of the above
108) Which of the following statements Answer: B
regarding enumerators is false?
a) Enumeration is an alternative method 114) The private data members of a class
for naming integer constants/ are accessible
b) An enumerator value can’t be changed in a) Directly to objects of that class
a program b) Only to the member functions
c) An integer value may be assigned to c) To any function defined outside a
an enumerated variable class d) None of the above
d) An enum defined within a structure is Answer: B
local to the structure
Answer: C 115) The objects can directly access
a) Public members
109) Which of the following statements b) Private members
is false? c) Both (a) & (b)
a) typedef defines new data types d) None of the
b) Using typedef does not replace the standard above Answer: A
C++ data type name with the new name
c) The new name defined by typedef, can 116) The following is a valid statement in
be used as a type for another typedef C++ a) int x=(int)2.50;
d) None of the above b) int x=int(2.50);
Answer: A c) Both (a) & (b)
d) None of the above
Answer: C
Downloaded by William Turkson Sam (willturksam@gmail.com)
lOMoAR cPSD| 23221915

117) Which of the following operator can 123) When a member function of a class
be overloaded call another member function, it is
a) Member access operator ( . & a) Nesting of classes b)
.*) b) Conditional operator (?:) Nesting of functions c)
c) Scope resolution operator Nesting of objects d)
(::) d) None of the above None of the above
Answer: D Answer: B

118) Using same function name to 124) A function defined inside a class is
perform different tasks is called a) A class function
a) Function polymorphism b) A friend function c)
b) Runtime polymorphism A member function d)
c) Function prototype None of the above
d) None of the above Answer: C
Answer: A
125) Information is made shareable
119) Default argument is through a) inheritance
a) Specified in function definition b) data encapsulation
b) Specified in function declaration c) data abstraction d)
c) Specified from left to right none of the above
d) None of the above Answer: A
Answer: B
126) Functions can returns
120) What is wrong with the a) arrays
following statement? b) reference
float s_interest (float principal, int c) object
rate=0.25, int time); d) all of the above
a) variables must not be specified in Answer: D
function prototype
b) arguments may only be defaulted from 127) The memory for date members
right to left is allocated
c) the default value must be specified a) When a class is defined
when making a function call b) When an object is initialized
d) none of the above c) When an object is created d)
Answer: B None of the above
Answer: B
121) Which of the following statements
regarding function overloading is not true. 128)The memory for member functions
a) If is used to handle different data types is allocated
at one place a) When a class is defined
b) When making a function call, if no exact b) When a object is created
match is found, promotion is the only c) When an object is initialized
criteria to find a match. d) None of the above
c) The default arguments can not be Answer: A
used instead of overloading
d) Unrelated functions should not 129) The dot operator relates
be overloaded a) A class member and a class object
Answer: C b) A class object and a class
122) The private members of a class c) A class and a member of that class
implement the OOP concept of d) A class object and member of that class
a) Data abstraction Answer: D
b) Data hiding
c) Message passing
d) None of the above
Answer: B

Downloaded by William Turkson Sam (willturksam@gmail.com)


lOMoAR cPSD| 23221915

130) A class having another class definition 137) new operator is used
is a) Nested class a) to define a new variable
b) Subordinate class b) to create a new data type
c) Enclosing class d) c) to allocate memory
None of the above dynamically d) none of the above
Answer: C Answer: C

131) A class whose member functions 138) A constructor function is


are friends of other class is generally defined
a) Friend class a) In the public section of a class
b) Abstract class b) In the private section of a class
c) Virtual class c) In the protected section of a
d) None of the above class d) None of the above
Answer: A Answer: A

132) The data members of a class 139) A class having no public constructors
are initialized is a) A private class
a) in class definition b) A public class c)
b) by a non-member function An abstract class d)
c) through constructor function when a None of the above
class object is created Answer: A
d) none of the above
Answer: C 140) If a constructor function is defined
in private section of a class, then
133) A constructor function is a) The object cannot be created
a) A friend function to a class b) Only member functions and friends
b) A member function with the same name may declare objects of the class
as its class c) Both (a) & (b)
c) A non-member function d) None of the above
d) None of the above Answer: C
Answer: B
141) A constructor with no argument is
134) An enumerated type is composed of a) Default constructor
a) Integer values with user defined name b) Parameterized constructor
b) Variables of different data types c) Copy constructor
c) Constant numeric values d) None of the above
d) None of the above Answer: A
Answer: A
142) If default arguments are provided to
135) In C++, the arguments by default a constructor function, then it becomes
are passed by a) Default constructor
a) call be reference b) Copy instructor
b) call be value c) Parameterized constructor
c) both (a) & (b) d) None of the above
d) none of the above Answer: A
Answer: B
143) The class of which the objects are
136) is an example of not instantiated is
a) unary operator a) Abstract class
b) binary operator b) Virtual class
c) ternary operator c) Static class
d) none of the above d) None of the above
Answer: C Answer: A

Downloaded by William Turkson Sam (willturksam@gmail.com)


lOMoAR cPSD| 23221915

144) && denotes 151) Which of the following statements


a) logical OR b) regarding constructor is false?
logical AND c) a) A constructor may be defined static
Bitwise AND b) Constructor can have default
d) None of the above arguments c) Member functions may be
Answer: B invoked from within a constructor
d) None of the above
145) The parameterized constructor Answer: A
a) Needs initial values as arguments
during creation of an object 152) The antonym of constructor is
b) Can be invoked explicitly only a) Creator
c) Can be invoked implicitly only b) Destructor
d) None of the above c) Destroyer
Answer: A d) None of the above
Answer: B
146) Explicit call to a constructor means
a) Providing the constructor name explicitly 153) Variable …………. of void
to invoke it type a) May be declared
b) Not providing the construction name at all b) Cannot be declared
c) Is the shorthand method c) Can be initialized
d) None of the above d) None of the above
Answer: A Answer: B

147) Classes in C++ are 154) A destruction function


a) Fundamental data a) Takes no argument and has no return
type b) Primitive data type not even void
type c) Desired data type b) Has name similar to that of class,
d) None of the above preceded by tilde(~) symbol
Answer: C c) Is used to destruct an object,
constructed through constructor function
148) A copy constructor is called d) All of the above
a) When an object is defined and Answer: D
initialized with another object
b) When an object is passed by value 155) Which of the following statements
c) When a function returns an object regarding destructor function is false?
d) All of the above a) Destructors do not accept any
Answer: D arguments, nor do they return any values
b) Destructors can be inherited
149) Which of the following regarding c) Member functions may be called from
constructor function is false? within a destructor
a) Constructor functions don’t have d) Destructor functions are called
return type, not even void automatically when an object is destroyed
b) Constructors can’t be inherited Answer: B
c) We can refer to their addresses
d) Constructors cannot be virtual 156) Function overloading
Answer: C a) Involves several function definitions under
one name, but different argument types
150) If new operator is used, then b) Implements polymorphism
the constructor function is c) Reduces the number of comparison in a
a) Parameterized constructor program, hence increases the execution
b) Copy constructor speed of a program
c) Dynamic constructor d) All of the above
d) Default constructor Answer: D
Answer: C

Downloaded by William Turkson Sam (willturksam@gmail.com)


lOMoAR cPSD| 23221915

157) The signature of function is a)


The number & type of arguments b)
The return type of a function
c) The class definition
d) None of the above
Answer: A

158) Overloading of constructor function


a) is similar to function overloading
b) different from an overloaded function as
it can’t return a value
c) not permitted in C++
d) none of the above
Answer: B

159) The binding of a function call at runtime


is a) Static binding
b) Early binding
c) Late binding
d) Runtime binding
Answer: C

160) The process of giving special meaning


to an operator is
a) Operator overloading
b) Operator mechanism
c) Operator definition d)
None of the above
Answer: A

161) What is a comment in c++?


a) comments are parts of the source
code disregarded by the compiler
b) comments are executed by compiler to
find the meaning of the comment
c) comments are executable
d) none of the mentioned
Answer: a

162) What type of comments does


c++ support?
a) single line
b) multi line
c) single line and multi line
d) none of the mentioned
Answer: C

163) What is the use of the indentation in


c++? a) distinguishes between comments and
code b) r distinguishes between comments
and outer data
c) both a and b
d) none of the mentioned
Answer: A

You might also like