In the name of ALLAH, the most beneficient, the most merciful

Introduction to Programming (CS201)

Multiple Choice Questions (MCQs)

 

Objective Questions

Question

For binary member operators, operands on the ___________ drives (calls) the operation.

  1. Left
  2. Right
  3. Both left and right
  4. None of the given

Answer: 1 Chapter No. 31 

Question

We cannot increment ____________.

  1. pointers
  2. arrays
  3. references
  4. variables

Answer: 3 Chapter No. 30 

Question

We can ___________ pointer.

  1. increment
  2. decrement
  3. reassign
  4. all of the given

Answer: 4 Chapter No. 30 

Question

We can _____________references.

  1. increment
  2. decrement
  3. reassign
  4. None of the given

Answer: 4 Chapter No. 30 

Question

What will be the correct syntax for the following function call? float add (int &);

  1. add(int x);
  2. add(&x);
  3. add(x);
  4. add(*x);

Answer: 3 Chapter No. 30 

Question

An instance of a class is called __________.

  1. structure
  2. data type
  3. object
  4. member function

Answer: 3 Chapter No. 27 

Question

The ________ is called automatically when an object destroys

  1. destructor
  2. constructor
  3. main program
  4. default constructor

Answer: 1 Chapter No. 27 

Question

The destructor is used to ____________.

  1. allocate memory
  2. deallocate memory
  3. create objects
  4. allocate static memory

Answer: 2 Chapter No. 27 

Question

___________data isn't accessible by non-member functions or outside classes.

  1. Public
  2. private
  3. Static
  4. Globally declared

Answer: 2 Chapter No. 26 

Question

Member functions of the class ________ main program.

  1. are not accessible
  2. are accessible from
  3. are defined within the
  4. are private to

Answer: 2 Chapter No. 26 

Question

Overloading means :

  1. Using the same name to perform multiple tasks or different tasks depending on the situation.
  2. Using the different name to perform multiple tasks or different tasks depending on the situation
  3. Using the same name to perform multiple tasks or same tasks depending on the situation
  4. Using the same name to perform difficult tasks or complex tasks and it does not depend on the situation

Answer: 1 Chapter No. 25 

Question

The main advantage of function overloading is ____________.

  1. The program becomes portable
  2. The program becomes complex
  3. The function becomes inline
  4. The program becomes more readable

Answer: 4 Chapter No. 25 

Question

You cannot overload the _____________ operator

  1. ? :
  2. *
  3. /
  4. ++

Answer: 1 Chapter No. 25 

Question

Memory allocated from heap or free store ______________.

  1. can be returned back to the system automatically
  2. can be allocated to classes only
  3. cannot be returned back unless freed explicitly using malloc and realloc
  4. cannot be returned back unless freed explicitly using free and delete operators

Answer: 4 Chapter No. 24 

Question

We cannot use ________ pointer for storing and reading data from it.

  1. integer
  2. double
  3. zero

Answer: 1 Chapter No. 24 

Question

The dynamic memory allocation uses _________ whereas static memory allocation uses _________.

  1. heap , stack
  2. stack , lists
  3. array , stack
  4. classes , array

Answer: 1 Chapter No. 24 

Question

What will be the output of the given code? #include #define MAX( A, B ) ((A) > (B) ? (A) : (B)) void main() { int i, x, y; x = 23; y = 45; i = MAX( x++, y++ ); // Side-effect: // larger value incremented twice cout << "x = " << x << " y = " << y << '\n'; }

  1. x=23 y=45
  2. x=24 y=46
  3. x=24 y=47
  4. x=22 y=47

Answer: 3 Chapter No. 23 

Question

getche() is a ________ function and defined in ___________ header file.

  1. user-define function , conio.h
  2. built-in function , conio.h
  3. built-in function, stlib.h
  4. built -in function, iostream.h

Answer: 2 Chapter No. 23 

Question

Symbolic constant PI can be defined as:

  1. #define PI 3.14 ;
  2. #define PI 3.14
  3. #define PI=3.14
  4. # include pi= 3.14

Answer: 2 Chapter No. 23 

Question

The parameter passed to isdigit() function is ____________variable.

  1. Character
  2. Boolean
  3. Integer
  4. Float

Answer: 3 Chapter No. 17 

Question

char **argv can be read as__________________.

  1. pointer to pointer
  2. pointer to char
  3. pointer to pointer to char
  4. None of the given

Answer: 3 Chapter No. 16 

Question

To read command-line arguments, the main() function itself must be given ___________ arguments.

  1. 1
  2. 2
  3. 3
  4. 4

Answer: 2 Chapter No. 16 

Question

The increment of a pointer depends on its___________.

  1. variable
  2. value
  3. data type
  4. None of the given

Answer: 3 Chapter No. 15 

Question

How many bytes an integer type pointer intPtr will jump in memory if the statement below is executed? intPtr += 2 ;

  1. 2
  2. 4
  3. 8
  4. 12

Answer: 3 Chapter No. 15 

Question

The statement cout << yptr will show the __________the yptr points to.

  1. Value
  2. memory address
  3. Variable
  4. None of the given

Answer: 2 Chapter No. 15 

Question

_________ is used as a dereferencing operator.

  1. *
  2. +
  3. -
  4. None of the above

Answer: 1 Chapter No. 14 

Question

Transpose of a matrix means that when we interchange rows and columns___________.

  1. the first row becomes the Last column
  2. the first row becomes the first column
  3. the Last row becomes the first column
  4. the first column becomes the first row

Answer: 2 Chapter No. 13 

Question

Individual characters in a string stored in an array can be accessed directly using array _______.

  1. superscript
  2. script
  3. subscript
  4. value

Answer: 3 Chapter No. 12 

Question

We can define a matrix as__________ array.

  1. Sorted
  2. Unsorted
  3. Single dimensional
  4. Multi dimensional

Answer: 4 Chapter No. 12 

Question

A ________is an array of characters that can store number of character specified.

  1. Char
  2. String
  3. Multidimensional array
  4. Data type

Answer: 2 Chapter No. 12 

Question

Given a two dimensional array of integers, what would be the correct way of assigning the value 6 to the element at third row and fourth column?

  1. array[3][4] = 6 ;
  2. array[2][4] = 6 ;
  3. array[4][3] = 6 ;
  4. array[2][3] = 6 ;

Answer: 4 Chapter No. 12 

Question

________ of a variable means the locations within a program from where it can be accessed.

  1. Data type
  2. Visibility
  3. Value
  4. Reference

Answer: 2 Chapter No. 10 

Question

Which of the following function call is "call by reference" for the following function prototype? int add (int *);

  1. add(&x);
  2. add(int x);
  3. add(x);
  4. add(*x);

Answer: 1 Chapter No. 10 

Question

Which of the following function call is "call by reference" for the following function prototype? float add (float *);

  1. add(&x);
  2. add(float x);
  3. add(x);
  4. add(*x);

Answer: 1 Chapter No. 10 

Question

Which of the function call is call by value for the following function prototype? float add(float);

  1. add(&x);
  2. add(x);
  3. add(float x);
  4. add(*x);

Answer: 2 Chapter No. 9 

Question

Which of the function call is "call by value" for the following function prototype? float add(int);

  1. add(&x);
  2. add(x);
  3. add(int x);
  4. add(*x);

Answer: 2 Chapter No. 9 

Question

Return type of a function that does not return any value must be _______.

  1. char
  2. int
  3. void
  4. double

Answer: 3 Chapter No. 9 

Question

______ will be used for enclosing function statements into a block.

  1. " "
  2. ()
  3. []
  4. {}

Answer: 4 Chapter No. 9 

Question

What is the output of the following code if the 2nd case is true switch (var) { case 'a':cout<<"apple"<

  • banana
  • banana
    any fruit
  • banana
    mango
    any fruit
  • None of the given
  • Answer: 3 Chapter No. 8 

    Question

    When the break statement is encountered in a loop's body, it transfers the control ________ from the current loop.

    1. Inside
    2. Outside
    3. To break statement
    4. To continue statement

    Answer: 2 Chapter No. 8 

    Question

    What is the output of the following code, if the first case is true switch (var) { case 'a':cout<<"apple"<<endl; case 'b':cout<<"banana"<<endl; case 'm':cout<<"mango"<<endl; default: cout<<"any fruit"<<endl; }

    1. apple
    2. apple
      any fruit
    3. apple
      banana
      mango
      any fruit
    4. none of above

    Answer: 3 Chapter No. 8 

    Question

    What will be the output of following code segment? for (int i = 2; i<10; i++){ if ( i == 5) continue; cout << i << "," ; }

    1. 2,3,7,8,9
    2. 2,3,4,6,7,8,9
    3. 2,3,4
    4. 4,6,7,8,9

    Answer: 2 Chapter No. 8 

    Question

    _________statement is used to terminate the processing of a particular case and exit from switch structure.

    1. if
    2. goto
    3. break
    4. continue

    Answer: 3 Chapter No. 8 

    Question

    What will be the result of the expression k = ++m; if initially k = 0 and m = 5?

    1. 0
    2. 5
    3. 6
    4. 4

    Answer: 3 Chapter No. 7 

    Question

    What will be the result of the expression j = i++; if initially j = 0 and i = 5?

    1. 0
    2. 5
    3. 6
    4. 4

    Answer: 2 Chapter No. 7 

    Question

    What will be the result of the expression k = ++m; if initially k = 0 and m = 4?

    1. 0
    2. 5
    3. 6
    4. 4

    Answer: 2 Chapter No. 7 

    Question

    What will be the result of the expression k = ++m; if initially k = 0 and m = 5?

    1. 0
    2. 5
    3. 6
    4. 4

    Answer: 3 Chapter No. 7 

    Question

    How many times the following do-while loop will execute? int k = 10; do { cout << "Statements" << endl; k -= 2; } while(k>0);

    1. 4
    2. 5
    3. 6
    4. 7

    Answer: 3 Chapter No. 7 

    Question

    Which of the following loops checks the test condition at the end of the loop?

    1. While
    2. Do-While
    3. For
    4. Nested Loop

    Answer: 2 Chapter No. 7 

    Question

    The operators ++ and -- are used to increment or decrement the value of a variable by ________.

    1. 1
    2. 2
    3. 3
    4. 4

    Answer: 1 Chapter No. 7 

    Question

    How many times the following loop will execute? int j = 3; while(j > 0) { cout << "Statements" << endl; j -= 2; }

    1. 0
    2. 1
    3. 2
    4. 3

    Answer: 3 Chapter No. 6 

    Question

    A ___________ structure specifies that an action is to be repeated while some condition remains true.

    1. Control
    2. Logical
    3. Repetition
    4. Relational

    Answer: 1 Chapter No. 6 

    Question

    !( x > 3) means in C++ that

    1. x is greater than 3
    2. x is less than or equal to 3
    3. x is less than 3
    4. x is equal to 3

    Answer: 2 Chapter No. 5 

    Question

    When the logical operator && combines two expressions then the result will be true only when the both expressions are ____________

    1. Logical
    2. Arithmetic
    3. true
    4. false

    Answer: 3 Chapter No. 5 

    Question

    < and > both are _________ operators.

    1. Arithmetic
    2. Relational
    3. Logical
    4. Mathematical

    Answer: 2 Chapter No. 5 

    Question

    What will be the value of variable “input” if the initial value of input is 67? if(input >= 50) input = input + 1; if(input <= 75) input = input + 2; else input = input - 1;

    1. 68
    2. 69
    3. 70
    4. 66

    Answer: 3 Chapter No. 5 

    Question

    !( x < 3) means in C++ that

    1. x is less than 3
    2. x is greater than or equal to 3
    3. x is greater than 3
    4. x is equal to 3

    Answer: 2 Chapter No. 5 

    Question

    != operator is used to check whether the operand on the left-hand-side is __________ to the operand on the right-hand-side.

    1. Less than or equal
    2. Greater than or equal
    3. Not equal
    4. Approximately equal to

    Answer: 3 Chapter No. 5 

    Question

    When the if statement consists more than one statement then enclosing these statement in curly braces is,

    1. Not required
    2. Good programming
    3. Relevant
    4. Must

    Answer: 4 Chapter No. 5 

    Question

    The most suitable data type for number 325.25 is ______.

    1. char
    2. int
    3. short
    4. float

    Answer: 4 Chapter No. 3 

    Question

    What will be the result of arithmetic expression 6+48/4*3?

    1. 10
    2. 40.5
    3. 42
    4. 41

    Answer: 3 Chapter No. 3 

    Question

    Which of the following will be the most appropriate data type to store the value 63.547?

    1. Integer
    2. Character
    3. Short
    4. Float

    Answer: 4 Chapter No. 3 

    Question

    In the given expression which operator will be evaluated first? 10 + (6 / 2) - 2 * 3?

    1. +
    2. -
    3. /
    4. *

    Answer: 3 Chapter No. 3 

    Question

    What will be the value of the variable output in the given piece of code? double output = 0; output = (2 + 2) * 4 + 2 / (4 - 2);

    1. 15
    2. 17
    3. 12
    4. 11

    Answer: 2 Chapter No. 3 

    Question

    ____________ operators are the ones that require two operands on both sides of the operator.

    1. Double
    2. Tow sided
    3. Binary
    4. None of the given

    Answer: 3 Chapter No. 3 

    Question

    It is the job of __________ to transfer the executable code from hard disk to main memory.

    1. Interpreter
    2. Debugger
    3. Linker
    4. Loader

    Answer: 4 Chapter No. 2 

    Question

    In computer systems there are mainly ___________ type of softwares.

    1. 1
    2. 2
    3. 3
    4. 4

    Answer: 2 Chapter No. 2 

    Question

    _________ will explain the function of a program.

    1. Comments
    2. Debugger
    3. Compiler
    4. Linker

    Answer: 1 Chapter No. 1