0% found this document useful (0 votes)
108 views

Principles of Programming Languages MCA50317

This document contains 57 multiple choice questions about programming language principles and concepts. The questions cover topics such as types of programming languages, advantages of high-level languages over machine code, object-oriented programming concepts like encapsulation and inheritance, control structures, data types, arrays, functions, comments, and specific languages like BASIC, FORTRAN, COBOL, C, and more. The answers to each question are also provided.

Uploaded by

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

Principles of Programming Languages MCA50317

This document contains 57 multiple choice questions about programming language principles and concepts. The questions cover topics such as types of programming languages, advantages of high-level languages over machine code, object-oriented programming concepts like encapsulation and inheritance, control structures, data types, arrays, functions, comments, and specific languages like BASIC, FORTRAN, COBOL, C, and more. The answers to each question are also provided.

Uploaded by

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

PRINCIPLES OF PROGRAMMING LANGUAGES

MCA50317

1. What is the only language that a computer understands directly?


(a)English, as spoken in Boston, Mass.
(b)BASIC, the Beginners' All-purpose Symbolic Instruction Code
(c) machine language, different for every type of CPU
Answer : c

2.What are the three main types of computer programming languages?


(a) machine language, assembly language, high level language
(b) imperative language, functional language, declarative language
(c)COBOL, Fortran-77, C++
Answer : a

3. From the point of view of the programmer what are the major
advantages of using a high-level language rather than internal machine
code or assembler language?
(a)Program portability
(b) Easy development
(c)Efficiency
Answer : b
4. Which of the following is the functionality of ‘Data Abstraction’?
(a)Reduce Complexity
(b)Binds together code and data
(c)Parallelism
(d)None of the mentioned
Answer : a
5. Which of the following mechanisms is/are provided by Object
Oriented Language to implement Object Oriented Model?
(a)Encapsulation
(b)Inheritance
(c)Polymorphism
(d)All of the mentioned
Answer : d

6. Which of the these is the functionality of ‘Encapsulation’?


(a) Binds together code and data
(b) Using single interface for general class of actions.
(c) Reduce Complexity
(d) All of the mentioned
Answer : a

7.What is ‘Basis of Encapsulation’?


(a) object
(b) class
(c) method
(d) all of the mentioned
Answer : a
8. How will a class protect the code inside it?
(a) Using Access specifiers
(b) Abstraction
(c) Use of Inheritance
(d) All of the mentioned
Answer : a
9. What is the output of this program?
(a) Compilation error
(b) Run time error
(c) Output : a, b and c 10 20 30
(d) None of the mentioned
Answer : c
10. Which of the following is a mechanism by which object acquires the
properties of another object?
(a) Encapsulation
(b) Abstraction
(c) Inheritance
(d) Polymorphism
Answer : c
11. Which of the following supports the concept of hierarchical
classification?
(a) Polymorphism
(b) Encapsulation
(c) Abstraction
(d) Inheritance
Answer : d
12. Which Keyword from the following is used to inherit properties from
one class into another?
(a) extends
(b) subclasses
(c) native
(d) all of the mentioned
Answer : a
13. Which of the following concept is often expressed by the phrase,
‘One interface, multiple methods’?
(a) Abstraction
(b) Polymorphism
(c) Inheritance
(d) Encapsulation
Answer : b
14. Data types are differed on basis of
(a) way of storage
(b) type of operations
(c) type of operators used
(d) both a and b
Answer : a
15. Loop statement which is repeated to some given number of times is
classified as
(a) FOR loop
(b) GO loop
(c) REPEAT loop
(d) GO REPEAT loop
Answer : a
16. In high-level language Pascal, area is calculated as
(a) 100 Area = Width*Length
(b) 100 Area = Width*Length
(c) Area = Width*Length;
(d) length 100 : area*20width
Answer : c
17.Type of statement written in sequence and are repeated until
conditions met is classified as
(a) format
(b) loop
(c) case
(d) condition
Answer : b
18. Size of an array is declared by
(a) programmer
(b) program users
(c) software
(d) declared automatically
Answer : a
19. An instruction which tells assembler how to deal with whole program
is classified as
(a) direction
(b) directive
(c) director
(d) compiler
Answer : d
20. Sequence of instructions that are carried out for a particular task is
classified as
(a) routine
(b) subroutine
(c) procedure
(d) function
Answer : c
21. In repeat-until loop 'UNTIL Option>0 and Option<8 AND
INT(Option) = Option' , INT function is classified as
(a) option
(b) function
(c) format option
(d) format function
Answer : b
22. A program which interprets each line of high level program at time of
execution is called
(a) instructor
(b) interpreter
(c) translator
(d) executor
Answer : b
23. Functions used in programs that are defined by programmers are
called
(a) program layout
(b) program procedure
(c) built-in functions
(d) user-defined function
Answer : d
24. An assembler translates
(a) machine code into assembly code
(b) assembly code into machine code
(c) processing time into manual time
(d) routine into subroutine
Answer : b
25. Name given by a programmer to some data is classified as
(a) identifier
(b) identification
(c) exponent
(d) mantissa
Answer : a
26. When variable used in program is whole number, variable is stored as
(a) fixed string
(b) integers
(c) negative whole numbers
(d) positive whole numbers
Answer : b
27. In line "100 INPUT NUM" of a BASIC program, 'INPUT NUM' is
(a) line statement
(b) single instruction
(c) reserved words
(d) expression
Answer : b
28. Set of data whose items are organized together is classified as
(a) data structure
(b) variable structure
(c) string structure
(d) positive structure
Answer : a
29. Comments used to make program easier are also called as
(a) marked variables
(b) narrative
(c) unmarked strings
(d) unmarked variable
Answer : b
30. Programming language which is used for scientific purposes and
work is to be done in batches is
(a)PASCAL
(b)FORTRAN
(c) LOGO
(d) COMAL
Answer : a
31. To made program more easier to understand, programmers can
(a) add comments to it
(b) declare variable names
(c) use secure data
(d) both a and b
Answer : a
32. In line '300 IF NAMEINR="***" THEN Average= Total Mark/N' of
BASIC program, "***" is classified as
(a) rational string
(b) string variable
(c) irrational string
(d) string constant
Answer : d
33. In programming, programmers used comments to
(a) highlight program modules
(b) explain module functions
(c) explain used variables
(d) all of above
Answer : d
34. In line '200 IF NAMEINR="***" THEN Average= Total Mark/N' of
BASIC program,NAMEINR is classified as
(a) string variable
(b) string constant
(c) rational string
(d) irrational string
Answer : a
35. Variable which uses same name in whole program and in its all
routines thus best classified as
(a) middle variable
(b) default variable
(c) local variable
(d) global variable
Answer : d
36.Statement used to made choice between different options and only
option is to be performed is written as
(a) if then statement
(b) if else statement
(c) then else statement
(d) else one statement
Answer : b
37. In programming language BASIC, statement ends with REM are
considered as
(a) narrative
(b) unmarked strings
(c) unmarked variable
(d) marked variables
Answer : a
38. In high level programming language Pascal, each program statement
ends with the
(a) comma
(b) semicolon
(c) double quotation marks
(d) single quotation marks
Answer : b
39. Type of program which can be run on different types of computer by
making little changes into it is classified as
(a) portable program
(b) fixed program
(c) standard program
(d) compiled program
Answer : a
40. In unstructured programming language BASIC, program can be
divided into the
(a) different modules
(b) different arrays
(c) different dimensions
(d) different procedures
Answer : d
41. When there is range of numbers involved in a program, it can be
stored as
(a) real numbers
(b) original numbers
(c) rational numbers
(d) irrational numbers
Answer : a
42.Technique of using fixed words for machine code functions is
classified as
(a) mnemonics
(b) mechanics
(c) compiler
(d) translator
Answer : a
43. Type of program which can be run on different types of computer by
making little changes into it is classified as
(a) portable program
(b) fixed program
(c) standard program
(d) compiled program
Answer : a
44. Which of the following is not true of FORTRAN?
(a) it was developed for scientific and mathematical applications
(b) it is one of the oldest high-level languages
(c) it is a problem oriented language
(d) it requires extensive internal documentation
(e) all of above
Answer : b
45. Overloading the function operator
(a) requires a class with an overloaded operator.
(b) requires a class with an overloaded [ ] operator.
(c) allows you to create objects that act syntactically like functions.
(d) usually make use of a constructor that takes arguments.
Answer : a
46. Main type of functions does not includes
(a) built-in function
(b) top down procedures
(c) programmer defined function
(d) user-defined function
Answer : b
47. Programming language 'BASIC' is used for the
(a) beginners
(b) commercial programs
(c) household user interface
(d) student applications
Answer : a
48. 'object program' is also called
(a) program code
(b) machine code
(c) assembler
(d) compiler
Answer : b
49. When source program is translated it is classified as
(a) object program
(b) featured program
(c) detailed program
Answer : a
50. In high level programming language, instructions used to supply
value in an expression are classified as
(a) program function
(b) program argument
(c) program routine
(d) program default exponents
Answer : b
51. Data structure in which all elements have similar name is considered
as
(a) string structure
(b) positive structure
(c) array
(d) data structure
Answer : c
52. Number of subscript which is attached to every element in array is
classified as
(a) number of subscript
(b) number of superscripts
(c) number of dimensions
(d) number of high scripts
Answer : c
53. In programming language COBOL, symbol of '//' is used instead of
(a) unmarked variable
(b) unmarked strings
(c) remarks
(d) marked structure
Answer : c
54. COBOL language statement '//PROGRAM : Input three numbers and
print average//' shows
(a) defined function
(b) entered variables
(c) string variables
(d) real numbers
Answer : c
55. Program used for interactive computing is
(a) translator
(b) executor
(c) instructor
(d) interpreter
Answer : d
56. In programming language BASIC, area is calculated as
(a) 100 Area=Width*Length
(b) 100 Area : = Width*Length
(c) Area : = Width*Length
(d) area 100 : length*width
Answer : a
57. First component in algorithms is
(a) character structure
(b) repetition
(c) selection
(d) sequence
Answer : d
58. Loop which is tested at least once in case condition does not fulfilled
is classified as
(a) FOR loop
(b) GO loop
(c) REPEAT loop
(d) REPEAT UNTIL loop
Answer : d
59. To perform stream I/O with disk files in C++, you should
(a) open and close files as in procedural languages.
(b) use classes derived from ios.
(c) use C language library functions to read and write data.
(d) include the IOSTREAM.H header file.
Answer : b
60. All numbers including decimals are classified as
(a) composite numbers
(b) real numbers
(c) integers
(d) prime numbers
Answer : b
61. Loop statement used in program to continue repetition until some
condition is met is classified as
(a) GO loop
(b) REPEAT UNTIL loop
(c) GO WHILE loop
(d) WHILE loop
Answer : b
62. Group of all special characters such as digits and letters are classified
as
(a) strings
(b) negative numbers
(c) odd numbers
(d) even numbers
Answer : a
63. In programming a single instruction is classified as
(a) set of instructions
(b) statement
(c) set of codes
(d) set of formula
Answer : b
64. Program style and must be written in
(a) well structured manner
(b) easy modification format
(c) easily understandable
(d) all of above
Answer : d
65. Usually a pure virtual function
(a) has complete function body.
(b) will never be called.
(c) will be called only to delete an object.
(d) is defined only in derived class.
Answer : d
66. If the variable count exceeds 100, a single statement that prints “Too
many” is
(a) if (count<< “Too many”;
(b) if (count>100) cout >> “Too many”;
(c) if (count>100) cout << “Too many”;
(d) None of these. 2 Code: AC11 Subject: OBJECT ORIENTED
PROGRAMMING
Answer : c
67. In programming language, 'identifier' can be
(a) variable
(b) constant
(c) array
(d) all of above
Answer : d
68. Type of subroutines which are available to users of computer as
default part of software is classified as
(a) default routine
(b) library subroutine
(c) default subroutine
(d) local subroutine
Answer : b
69. Translation of assembly language into machine code is a task of
(a) assembler
(b) programmer
(c) analysts
(d) financer
Answer : a
70. Loop which does not executed at all if it is tested at beginning is
classified as
(a) REPEAT loop
(b) GO REPEAT loop
(c) WHILE loop
(d) DO loop
Answer : c
71. Special character symbol '/' is used to indicate
(a) director
(b) direction arrows
(c) direction
(d) directive
Answer : d
72. Rogue value in statement "140 PRINT "For each one type in name.
Type '***,0,0' to finish" is
(a) asterisk
(b) print command
(c) numerical values
(d) alphabetic statement
Answer : a
73. Complier is used when data is to be processed in
(a) whole at one time
(b) one line in one minute
(c) four pages in five minutes
(d) batches
Answer : d
74. Examples of program routine are
(a) complete short program
(b) part of a program
(c) set of instructions used
(d) all of above
Answer : d
75. One or more numbers which helps distinguish elements in array is
classified as
(a) superscript
(b) subscript
(c) low script
(d) high script
Answer : b
76. A name which has some special meaning and significance for
programmer is called
(a) reserved words
(b) changing words
(c) files
(d) data array
Answer : a
77. Items of data help making its structure is classified as
(a) variable structure
(b) elements
(c) data structure
(d) string structure
Answer : b
78. A special value placed at end of items data list is called
(a) vague values
(b) numerical values
(c) rogue value
(d) decimal values
Answer : c
79. Prolog comes under ___________
a) Logic Programming
b) Procedural Programming
c) OOP
d) Functional
Answer: a
80. Java is procedural programming.
a) True
b) False
Answer: b
81. A program that can execute high-level language programs.
a) Compiler
b) Interpreter
c) Sensor
d) Circuitry
Answer: b
82. Executables might be called ________
a) native code
b) executable code
c) complex code
d) machine code
Answer: a
83. Source program is compiled to an intermediate form called
___________
a) Byte Code
b) Smart code
c) Executable code
d) Machine code
Answer: a
84. _______________ is the assembly language for an imaginary
architecture.
a) Byte code
b) Machine code
c) Native code
d) Executable code
Answer: a
85. JIT stands for?
a) Just in time
b) Jump in time
c) Jump in text
d) Jump in terms
Answer: a
86. JVM stands for?
a) Java virtual machine
b) Java visual machine
c) JRE virtual machine
d) JRE visual machine
Answer: a
87. A language supported by MS. Net platform.
a) C
b) C++
c) java
d) C#
Answer: d
88. Which of the following isn’t a characteristic of High level languages?
a) machine code
b) platform independent
c) interactive execution
d) user-friendly
Answer: a
89. What is the process of defining two or more methods within same
class that have same name but different parameters declaration?
a) method overloading
b) method overriding
c) method hiding
d) none of the mentioned
Answer: a
90. Which of these can be overloaded?
a) Methods
b) Constructors
c) All of the mentioned
d) None of the mentioned
Answer: c
91. Which of these is correct about passing an argument by call-by-value
process?
a) Copy of argument is made into the formal parameter of the subroutine
b) Reference to original argument is passed to formal parameter of the
subroutine
c) Copy of argument is made into the formal parameter of the subroutine
and changes made on parameters of subroutine have effect on original
argument
d) Reference to original argument is passed to formal parameter of the
subroutine and changes made on parameters of subroutine have effect on
original argument
Answer: a
92. What is the process of defining a method in terms of itself, that is a
method that calls itself?
a) Polymorphism
b) Abstraction
c) Encapsulation
d) Recursion
Answer: d
93. What will be the output of the following Java code?
class San
{
public void m1 (int i,float f)
{
System.out.println(" int float method");
}

public void m1(float f,int i);


{
System.out.println("float int method");
}

public static void main(String[]args)


{
San s=new San();
s.m1(20,20);
}
}
a) int float method
b) float int method
c) compile time error
d) run time error
Answer: c
94. What will be the output of the following Java code?

class overload
{
int x;
int y;
void add(int a)
{
x = a + 1;
}
void add(int a, int b)
{
x = a + 2;
}
}
class Overload_methods
{
public static void main(String args[])
{
overload obj = new overload();
int a = 0;
obj.add(6);
System.out.println(obj.x);
}
}
a) 5
b) 6
c) 7
d) 8
Answer: c
95. What will be the output of the following Java code?

class overload
{
int x;
int y;
void add(int a)
{
x = a + 1;
}
void add(int a , int b)
{
x = a + 2;
}
}
class Overload_methods
{
public static void main(String args[])
{
overload obj = new overload();
int a = 0;
obj.add(6, 7);
System.out.println(obj.x);
}
}
a) 6
b) 7
c) 8
d) 9
Answer: c
96. What will be the output of the following Java code?

class overload
{
int x;
double y;
void add(int a , int b)
{
x = a + b;
}
void add(double c , double d)
{
y = c + d;
}
overload()
{
this.x = 0;
this.y = 0;
}
}
class Overload_methods
{
public static void main(String args[])
{
overload obj = new overload();
int a = 2;
double b = 3.2;
obj.add(a, a);
obj.add(b, b);
System.out.println(obj.x + " " + obj.y);
}
}
a) 6 6
b) 6.4 6.4
c) 6.4 6
d) 4 6.4
Answer: d
97. What will be the output of the following Java code?

class test
{
int a;
int b;
void meth(int i , int j)
{
i *= 2;
j /= 2;
}
}
class Output
{
public static void main(String args[])
{
test obj = new test();
int a = 10;
int b = 20;
obj.meth(a , b);
System.out.println(a + " " + b);
}
}
a) 10 20
b) 20 10
c) 20 40
d) 40 20
Answer: a
98. What will be the output of the following Java code?

class test
{
int a;
int b;
test(int i, int j)
{
a = i;
b = j;
}
void meth(test o)
{
o.a *= 2;
O.b /= 2;
}
}
class Output
{
public static void main(String args[])
{
test obj = new test(10 , 20);
obj.meth(obj);
System.out.println(obj.a + " " + obj.b);
}
}
a) 10 20
b) 20 10
c) 20 40
d) 40 20
Answer: b
99. Local variables are stored in an area called ___________
a) Heap
b) Permanent storage area
c) Free memory
d) Stack
Answer: d
100. The size of both stack and heap remains the same during run time.
a) True
b) False
Answer: b
101. Choose the statement which is incorrect with respect to dynamic
memory allocation.
a) Memory is allocated in a less structured area of memory, known as
heap
b) Used for unpredictable memory requirements
c) Execution of the program is faster than that of static memory allocation
d) Allocated memory can be changed during the run time of the program
based on the requirement of the program
Answer: c
102. Which of the following header files must necessarily be included to
use dynamic memory allocation functions?
a) stdlib.h
b) stdio.h
c) memory.h
d) dos.h
Answer: a
103. The type of linked list in which the node does not contain any
pointer or reference to the previous node is _____________
a) Circularly singly linked list
b) Singly linked list
c) Circular doubly linked list
d) Doubly linked list
Answer: b
104. Which of the following is an example for non linear data type?
a) Tree
b) Array
c) Linked list
d) Queue
Answer: a
105. Queue data structure works on the principle of ____________
a) Last In First Out (LIF0)
b) First In Last Out (FILO)
c) First In First Out (FIFO)
d) Last In Last Out (LILO)
Answer: c
106. Which of the following is an example of static memory allocation?
a) Linked list
b) Stack
c) Queue
d) Array
Answer: d
107. Array is preferred over linked list for the implementation of
________
a) Radix sort
b) Insertion sort
c) Binary search
d) Polynomial evaluation
Answer: c
108. The advantage of using linked lists over arrays is that ________
a) Linked list is an example of linear data structure
b) Insertion and deletion of an element can be done at any position in a
linked list
c) Linked list can be used to store a collection of homogenous and
heterogeneous data types
d) The size of a linked list is fixed
Answer: b
109. Which among the following best describes the Inheritance?
a) Copying the code already written
b) Using the code already written once
c) Using already defined functions in programming language
d) Using the data and functions into derived segment
Answer: d
110. How many basic types of inheritance are provided as OOP feature?
a) 4
b) 3
c) 2
d) 1
Answer: a
111. Which among the following best defines single level inheritance?
a) A class inheriting a derived class
b) A class inheriting a base class
c) A class inheriting a nested class
d) A class which gets inherited by 2 classes
Answer: b
112. Which among the following is correct for multiple inheritance?
a) class student{public: int marks;}s; class stream{int total;}; class
topper:public student, public stream{ };
b) class student{int marks;}; class stream{ }; class topper: public
student{ };
c) class student{int marks;}; class stream:public student{ };
d) class student{ }; class stream{ }; class topper{ };
Answer: a
113. Which programming language doesn’t support multiple inheritance?
a) C++ and Java
b) C and C++
c) Java and SmallTalk
d) Java
Answer: d
114. Which among the following is correct for a hierarchical inheritance?
a) Two base classes can be used to be derived into one single class
b) Two or more classes can be derived into one class
c) One base class can be derived into other two derived classes or more
d) One base class can be derived into only 2 classes
Answer: c
115. Which is the correct syntax of inheritance?
a) class derived_classname : base_classname{ /*define class body*/ };
b) class base_classname : derived_classname{ /*define class body*/ };
c) class derived_classname : access base_classname{ /*define class
body*/ };
d) class base_classname :access derived_classname{ /*define class
body*/ };
Answer: c
116. Which type of inheritance leads to diamond problem?
a) Single level
b) Multi-level
c) Multiple
d) Hierarchical
Answer: c
117. Which access type data gets derived as private member in derived
class?
a) Private
b) Public
c) Protected
d) Protected and Private
Answer: a
118. If a base class is inherited in protected access mode then which
among the following is true?
a) Public and Protected members of base class becomes protected
members of derived class
b) Only protected members become protected members of derived class
c) Private, Protected and Public all members of base, become private of
derived class
d) Only private members of base, become private of derived class
Answer: a
119. Members which are not intended to be inherited are declared as
________________
a) Public members
b) Protected members
c) Private members
d) Private or Protected members
Answer: c
120. While inheriting a class, if no access mode is specified, then which
among the following is true? (in C++)
a) It gets inherited publicly by default
b) It gets inherited protected by default
c) It gets inherited privately by default
d) It is not possible
Answer: c
121. If a derived class object is created, which constructor is called first?
a) Base class constructor
b) Derived class constructor
c) Depends on how we call the object
d) Not possible
Answer: a
122. The private members of the base class are visible in derived class but
are not accessible directly.
a) True
b) False
Answer: a
123. How can you make the private members inheritable?
a) By making their visibility mode as public only
b) By making their visibility mode as protected only
c) By making their visibility mode as private in derived class
d) It can be done both by making the visibility mode public or protected
Answer: d
124. What is an exception?
a) Problem arising during compile time
b) Problem arising during runtime
c) Problem in syntax
d) Problem in IDE
Answer: b
125. Why do we need to handle exceptions?
a) To prevent abnormal termination of program
b) To encourage exception prone program
c) To avoid syntax errors
d) To save memory
Answer: a
126. An exception may arise when _______________
a) Input is fixed
b) Input is some constant value of program
c) Input given is invalid
d) Input is valid
Answer: c
127. If a file that needs to be opened is not found in the target location
then _____________
a) Exception will be produced
b) Exceptions are not produced
c) Exception might get produced because of syntax
d) Exceptions are not produced because of logic
Answer: a
128. Which is the universal exception handler class?
a) Object
b) Math
c) Errors
d) Exceptions
Answer: d
129. What are two exception classes in hierarchy of java exceptions
class?
a) Runtime exceptions only
b) Compile time exceptions only
c) Runtime exceptions and other exceptions
d) Other exceptions
Answer: c
130. Which are the two blocks that are used to check error and handle the
error?
a) Try and catch
b) Trying and catching
c) Do and while
d) TryDo and Check
Answer: a
131. There can be a try block without catch block but vice versa is not
possible.
a) True
b) False
Answer: a
132. How many catch blocks can a single try block can have?
a) Only 1
b) Only 2
c) Maximum 127
d) As many as required
Answer: d
133. Which among the following is not a method of Throwable class?
a) public String getMessage()
b) public Throwable getCause()
c) public Char toString()
d) public void printStackTrace()
Answer: c
134. To catch the exceptions ___________________
a) An object must be created to catch the exception
b) A variable should be created to catch the exception
c) An array should be created to catch all the exceptions
d) A string have to be created to store the exception
Answer: a
135. Multiple catch blocks __________________
a) Are mandatory for each try block
b) Can be combined into a single catch block
c) Are not possible for a try block
d) Can never be associated with a single try block
Answer: b
136. Which symbol should be used to separate the type of exception
handler classes in a single catch block?
a) ?
b) ,
c) –
d) |
Answer: d
137. Which class is used to handle the input and output exceptions?
a) InputOutput
b) InputOutputExceptions
c) IOExceptions
d) ExceptionsIO
Answer: c
138. Why do we use finally block?
a) To execute the block if exception occurred
b) To execute a code when exception is not occurred
c) To execute a code whenever required
d) To execute a code with each and every run of program
Answer: d
139. Which among the following is called first, automatically, whenever
an object is created?
a) Class
b) Constructor
c) New
d) Trigger
Answer: b
140. Which among the following is not a necessary condition for
constructors?
a) Its name must be same as that of class
b) It must not have any return type
c) It must contain a definition body
d) It can contains arguments
Answer: c
141. Which among the following is correct?
a) class student{ public: int student(){} };
b) class student{ public: void student (){} };
c) class student{ public: student{}{} };
d) class student{ public: student(){} };
Answer: d
142. In which access should a constructor be defined, so that object of the
class can be created in any function?
a) Public
b) Protected
c) Private
d) Any access specifier will work
Answer: a
143. How many types of constructors are available for use in general
(with respect to parameters)?
a) 2
b) 3
c) 4
d) 5
Answer: a
144. If a programmer defines a class and defines a default value
parameterized constructor inside it. He has not defined any default
constructor. And then he try to create the object without passing
arguments, which among the following will be correct?
a) It will not create the object (as parameterized constructor is used)
b) It will create the object (as the default arguments are passed)
c) It will not create the object (as the default constructor is not defined)
d) It will create the object (as at least some constructor is defined)
Answer: b
145. Default constructor must be defined, if parameterized constructor is
defined and the object is to be created without arguments.
a) True
b) False
Answer: a
146. If class C inherits class B. And B has inherited class A. Then while
creating the object of class C, what will be the sequence of constructors
getting called?
a) Constructor of C then B, finally of A
b) Constructor of A then C, finally of B
c) Constructor of C then A, finally B
d) Constructor of A then B, finally C
Answer: d
147. In multiple inheritance, if class C inherits two classes A and B as
follows, which class constructor will be called first?
class A{ };
class B{ };
class C: public A, public B{ };
a) A()
b) B()
c) C()
d) Can’t be determined
Answer: a
148. Which among the following is true for copy constructor?
a) The argument object is passed by reference
b) It can be defined with zero arguments
c) Used when an object is passed by value to a function
d) Used when a function returns an object
Answer: b
149. If the object is passed by value to a copy constructor?
a) Only public members will be accessible to be copied
b) That will work normally
c) Compiler will give out of memory error
d) Data stored in data members won’t be accessible
Answer: c
150. Which object will be created first?

class student
{
int marks;
};
student s1, s2, s3;
a) s1 then s2 then s3
b) s3 then s2 then s1
c) s2 then s3 then s1
d) all are created at same time

Answer: a
151. Which among the following helps to create a temporary instance?
a) Implicit call to a default constructor
b) Explicit call to a copy constructor
c) Implicit call to a parameterized constructor
d) Explicit call to a constructor

Answer: d

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy