CS201 – Introduction To Programming Mcqs Pdf with Answers Part 01

Print/Downlaod pdf

MCQsFoundry.com brings to you 500+ Introduction to Programming Mcqs which are new and latest. These Mcqs are never published on internet so far. For full information about all PPSC / FPSC / CSS / PMS latest jobs visit theiteducation.com

Introduction to Programming Top 500 + MCQS Download Pdf
Top Introduction to Programming Subject Mcqs Pdf Download
01Introduction to Programming Mcqs Chapter 0102Introduction to ProgrammingMcqs Chapter 02
03Introduction to Programming Mcqs Chapter 0304Introduction to Programming Chapter 04
05Introduction to Programming Chapter 0506Introduction to Programming Chapter 06
Top 500+ New Introduction to Programming MCQs with Answers | Download PDF

1          A template function must have at least ———- generic data type

► Zero

One

►Two

► three


 2         Which of the following statement is best regarding declaration of friend function?

► Friend function must be declared after public keyword .

► Friend function must be declared after a private keyword.

► Friend function must be declared at the top within class definition.

It can be declared anywhere in class as these are not affected by the public and private keywords.


3          Which one of the following is the declaration of overloaded pre-increment operator implemented as member function?

► Class-name operator +() ;

► Class-name operator +(int) ;

Class-name operator ++() ;

► Class-name operator ++(int) ;


 4         Class is a user defined___________.

► data type

► memory referee

► value

► none of the given options.


 5         How many bytes will the pointer intPtr of type int move in the following statement? intPtr += 3 ; 

► 3 bytes

► 6 bytes

► 12 bytes

► 24 bytes


 6         Which of the following is the correct C++ syntax to allocate space dynamically for an array of 10 int?

► new int(10) ;

► new int[10] ;

► int new(10) ;

► int new[10];


 7         A Pointer is a special variable that contain

► Data values

Memory Address  

► Both data and values

► None of the given option


 8         Reference Value Type Data The code is written to __________ the program.

implement

► design

► analysis

► none of the given options 


9          Operator overloading can be performed through__________________.

► Classes

► Function  

► Operators

► Reference


10        When a value is referred by a normal variable then it is known as,

► Direct Reference  

►Indirect Reference.

► Partial Reference

► Proper Reference


11        Which of the following function is used to increase the size of already allocated memory chunk?

► malloc

► calloc

► realloc

► free


12        Which of the following is NOT a preprocessor directive?

► #error

► #define

► #line

► #ndefine 


13         The stream objects cin and cout are included in which header file?

iostream.h 

► fstream.h

► istream.h

► ostream.h


14          Overloaded delete operator function takes the same parameter as an argument returned by new operator function.

True

► False


15        The same pointer that is returned by the new operator, is passed as an argument to the delete operator. These rules apply to both, if operators (new and delete) are overloaded as member or non-member operators (as global operators).


16         When an array of object is created dynamically then there is no way to provide parameterized constructors for array of objects.

True  

► False


17        3 C is widely known as development language of _______ operating system.

► Linux

► Windows

► Unix  

► Mac OS In the start C became widely known as the development language of the UNIX operating system, and the UNIX operating system was written by using this C language. The C language is so powerful that the compiler of C and other various operating systems are written in C.


18           Computer can understand only machine language code.

True

► False


19           We can not define a function as a friend of a Template class.

► True

False 

Class templates can have friends. A class or class template, function, or function template can be a friend to a template class. Friends can also be specializations of a class template or function template, but not partial specializations.


20          What will be the value of ‘a’ and ‘b’ after executing the following statements? A = 3; b = a++;

► 3, 4

► 4, 4

► 3, 3

4, 3


21          Consider the following code segment. What will be the output of following code? Int addValue (int *a){ int b = (*a) + 2; return b ; } main () { int x =6 ; cout << x << “,” ; cout << addValue(&x) << “,” ; cout << x ; } 

6,8,6

► 6,6,8

► 6,8,8

► 6,6,6


22        _______ is used to trace the logic of the program and correct the logical errors.

► Compiler

► Editor

► Linker

Debugger


23        new and delete are _____ whereas malloc and free are _____.

► Functions, operators

► Classes, operators

Operators, functions  

► Operators, classes

Hence, we can call new and delete operators, P# 342 we have allocated a memory space for our use by malloc function. P# 285


24           Like member functions, ______ can also access the private data members of a class.

► Non-member functions

Friend functions  

► Any function outside class

► None of the given options


25          Which situation would require the use of a non-member overloaded operator?

► The overloaded operator is an Assignment operator.

The left most operand is an object of a class.

► The left operand is built-in data type.

► The operator returns a reference.

When an operator function is implemented as a non-member function, the left-most operand may be an object of the operator’s class, an object of a different class, or a built-in type


26           The stream insertion and stream extraction operators are already overloaded for ______.

► User-defined data types

► Built-in data types http://www.sstutor.com/cpp/stream1.htm

► User-defined and built-in data types

► None of the given options


27        If we define an identifier with the statement #define PI 3.1415926 then during the execution of the program the value of PI __________.

► can not be replaced

► None of the given options

► Remain constant.

► can be changed by some operation


28        Assignment operator is ————————-associative.

right

► left

► binary

► unary


 29       When ever dynamic memory allocation is made in C/C++, it is freed_____________.

Explicitly

► Implicitly

► Both explicitly and implicitly

► None of the given options


30        The appropriate data type to store the number of rows and colums of the matrix is____________.

► float

int (Not sure)

► char

► none of the given options.


 31       Which of the following function do NOT initialize the chunk of memory to all zero?

► calloc() function

► Both malloc() and calloc()

► None of the above

malloc() function 

The malloc function differs from calloc in the way that the space allocated by malloc is not initialized and contains any values initially.


32        The function free() returns back the allocated memory got thorough calloc and malloc to _____ .

► stack

heap

► stack and heap

► None of the given options


33        width() is member function of _____________

► cin object

► cout object

► Both cin and cout object  

► None of the given option


 34       Templates are not type safe.

► true

► false

Templates are type-safe. This is because the types that templates act upon are known at compile time, so the compiler can perform type checking before errors occur.


35        A Matrix can be composed of ints, floats or doubles as their elements. Best way is to handle this , _______________

► Write a separate class to handle each

Use templates  

► Use strings to store all types

► None of the given options


36        In if structure the block of statements is executed only,

► When the condition is false

► When it contain arithmetic operators

► When it contain logical operators

► When the condition is true 


 37       Header file: fstream.h includes the definition of the stream classes __________.

► ifstream, fstream, cout

► ifstream, fstream, ofstream

► fstream, cin, cout

► None of the above


38        To access the data members of structure _______ is used.

► dot operator (.)

► * operator

► operator

► None of given.


40        eof( ), bad( ), good( ), clear( ) all are manipulators.

► True

► False


41        Which kind of functions can access private member variables of a class?

Friend functions of the class  

► Private member functions of the class

► Public member functions of the class

► Friend, private and public functions


42        The return type of operator function must always be void.

► True

► False


43        Friend function of a class is ______________ .

► Member function

► Non-member function  

► Private function

► Public function


44        Function implementation of friend function must be defined outside the class.

► True

► False


45        The normal source of cin object is,

► File

► Disk

► Keyboard 

► RAM


46        Which of the following is correct way to initialize a variable x of int type with value 10?

► int x ; x = 10;

► int x = 10;

► int x, x = 10;

► x = 10;


47        Consider the following code segment. What will be the output of the following program?

int func(int) ; int num = 10 ;

int main(){ int num ; num = 5 ; cout << num ; cout << func(num) ; } int func(int x){ return num ; }

► 5, 5

► 10, 5

► 5, 10

► 10, 10


48        With template function, the compiler automatically detects the passed data and generates a new copy of function using passed data.

► True  

► False


49        What will be the correct syntax to declare two-dimensional array of float data type?

► float arr{2}{2} ;

► float arr[2][2] ;

► float arr[2,2] ;

► float[2][2] arr ;


50        The first parameter of operator function for << operator,

► Must be passed by value

► Must be passed by reference  

► Can be passed by value or reference

► Must be object of class