c,c++,c# mcqs

  C C++ C# MCQs 

 

Very Important ‘C’ Language MCQs

 

Q1: Which of the following is the correct statement for the following declaration? const int *ptr.

► ptr is a constant pointer

► ptr is constant integer pointer

► ptr is a constant pointer to int

ptr is a pointer to const int

 

Q2: Consider the following code segment. What will be the output of this code segment? int arr[6] = {2, 3, 7, 4, 5, 6} ;

int *ptr1 =&arr[1] ; int *ptr2 = &arr[4] ; cout << (ptr2-ptr1) ;

► 3

► 9

► 12

2

 

 Q3:What will be the correct syntax to assign an array named arr of 5 elements to a pointer ptr?

*ptr = arr ; ptr

►= arr ; 5+5

►*ptr = arr[5] ;

►ptr = arr[5]* ;

► None

 

Q4:The variables having a name, type and size are just like empty boxes.

►False

True

 

Q5:What’s wrong with this for loop? for (int k = 2, k <=12, k++)

► the increment should always be ++k

► the variable must always be the letter i when using a for loop

► there should be a semicolon at the end of the statement

the commas should be semicolons

 

Q6:The size of int data type is

► 1 bytes

► 2 bytes

► 3 bytes

4 bytes

 

 

Q7:In Flow chart process is represented by

Rectangle

► Arrow symbol

► Oval

► Circle

 

Q8:If the break statement is missed in switch statement then,

► The compiler will give error

This may cause a logical error

► No effect on program

► Program stops its execution

 

Q9:When we are using const keyword with a variable x then initializing it at the time of declaration is,

Must

► Optional

► Not necessary

► A syntax error

 

Q10:Which of the following is the correct way to assign an integer value 5 to element of a matrix say ‘m’ at second row and third column?

m[2][3] = 5 ;

► m[3][2] = 5 ;

► m[1][2] = 5 ;

► m[2][3] = ‘5’;

 

Q11: How many total elements must be in two-dimensional array of 3 rows and 2 columns?

► 4

► 5

6

► 7

 

Q12: Most efficient method of dealing with structure variables is to define the structure globally:

► True

False

 

Q13: Syntax of union is identical to   

Structure

► Class

► Function

► None of the given options

 

Q14:Like member functions,       can also access the private data members of a class.

Non-member function

Friend Function

Any function outside class

None of the given options

 

Q15:Function created with in function called.

nested

overload

grouped

None

 

Q16:Copy constructor becomes necessary while dealing with           allocation in the class.

► Dynamic memory

   ► Static memory

Both Dynamic and Static memory

None of the given options

 

Q17:C/C++ string constant is enclosed in

Small braces

Curly braces

Double quote

Single quote

 

Q18:Unary operator takes argument

  Zero

►  One

Two

Three

 

Q19:When define array of objects

Constructor will call

Destructor will call

None

All

 

Q20:Automatic variable are created on            .

Heap

Free Store

► static storage

Stack

 

Q21: Which of the following operators cannot be overloaded?

New

Delete

► +=

sizeof

 

Q22: The reserved words public and private comes under the category

Structures

Strings

Accessibility modifiers

Types of functions

 

Q23:What is the sequence of event(s) when allocating memory using new operator?

Only block of memory is allocated for objects

Only constructor is called for objects

► Memory is allocated first before calling constructor

Constructor is called first before allocating memory

 

Q24:What is the sequence of event(s) when De allocating memory using delete operator?

Only block of memory is de allocated for objects

Only destructor is called for objects

Memory is de allocated first before calling destructor

► Destructor is called first before de allocating memory

 

Q25: new and delete operators cannot be overloaded as member functions.

True

► False

 

Q26: The operator function of << and >> operators are always the member                                   function   of a class.

True

► False

 

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

Zero

One

Two

Three

 

Q28:If we do not mention any return_value_type with a function, it will return an    value.

► int

void

double

float

 

Q29:Suppose a program contains an array declared as int arr[100]; what will be the size of array?

0

99

100

101

 

Q30:The name of an array represents address of first location of array element.

► True

False

 

Q31:Reusing the variables in program helps to save the memory

► True

False

 

Q32:Which of the following option is true about new operator to dynamically allocate memory to an object?

The new operator determines the size of an object

► Allocates memory to object and returns pointer of valid type

Creates an object and calls the constructor to initialize the object

All of the given options

 

Q33:new and delete are   whereas malloc and free are             .

Functions, operators

Classes, operators

► Operators, functions

Operators, classes

 

Q34: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

 

Q35: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 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.

 

Q36:The operator function overloaded for an Assignment operator (=) must be

Non-member function of class

► Member function of class

Friend function of class

None of the given options

 

Q37:For non-member operator function, object on left side of the operator may be

Object of operator class

Object of different class

► Built-in data type

All of the given options

 

Q38:The operator function will be implemented as    , if obj1 drive the – operator whereas  obj2 is passed as arguments to – operator in the statement given below.

      obj3   =   obj1 –   obj2;

Member function

Non-member function

► Friend function

None of the given options

 

Q39: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) ;

 

Q40:The static data members of a class are initialized       

► at file scope

within class definition

within member function

within main function

 

Q41:Class is a user defined              .

► data type

memory referee

value

none of the given options.

 

Q42:We can also define a user-defines manipulators.

True

► False

 

Q43:The prototype of friend functions must be written the class and its definition must be written        

► inside, inside the class

► inside, outside the class

► outside, inside the class

► outside, outside the class

 

Q44:Copy constructor becomes necessary while dealing with        allocation in the class.

► Dynamic memory

► Static memory

► Both Dynamic and Static memory

► None of the given options

 

Q45:Dealing with structures and functions passing by reference is the most economical method

► True

► False

 

Q46:Which of the following array is the most suitable for storing a matrix structure?

Single-dimensional array

► Two-dimensional array

Three-dimensional array

Four-dimensional array

 

Q47:How many bytes are occupied by declaring following array of characters? char str[] = “programming”;

► 10

► 11

► 12

► 13

 

Q48:The operator function for << (stream insertion) >> and stream extraction must be

► Member function of class

► Non-member function of class

Both member and non-member function

None of the given options

 

Q49:A template function must have

► One or more than one arguments

Only one argument

Zero arguments

None of the given options

 

Q:50 Truth tables are used for analyzing              .

► logical expressions

arithmetic expressions

both logical and arithmetic expressions

none of the given options.

 

Q51:Templates provide way of abstracting                     information.

► type

data

method

access

 

Q52:A pointer is a special type of variable that contain               

► Memory Address

Data values

Both Values and Memory

None of given of options

 

Q53:Which is NOT a protection level provided by classes in C++?

protected

hidden

private

► public

 

Q54:Users must not know about                                 .

Functions Name within Class

Class implementation of Functionality and Interfaces

► Methods Functionality with in Class

► None of the given options

 

Q55:What will be the output of following statement?

cout << setfill(‘0’) << setw(7) << 128

0000128

0128128

1280000

0012800

 

Q56;The static data members of a class will be         

shared by objects

created for each object

► initialized within class

initialized within main function

 

Q57:Which of the following is used for allocating space for static variables?

Heap

► Static storage area

Free store

Stack

 

Q58:Which of the following will be the correct function call for function prototype given below?

int func (int &);

func(int num);

func(&num);

► func(num);

func(*num);

 

Q59:If there is a symbol (& sign) used with the variable name followed by data type then   it refers to   and if & is being used with variable name then it refers to                                               .

► Address of variable, reference variable

Reference variable, value of variable

Reference variable, address of variable

Address of variable, value of variable

 

Q60:Which of the following operator the compiler overloads for objects by default?

+ operator

– operator

= operator

► == operator

 

Q61:What will be the output of following code segment?

main(){

int x = 5 ;

{

int x = 4 ;

cout << x << “,” ;

}

cout << x ;

}

5, 5

4, 4

► 4, 5

5, 4

 

Q62:Single line comments explaining code would be preceded like in the following example.

/*

► //

/

//*

 

Q63:The         statement interrupts the flow of control.

switch

continue

goto

► break

 

Q64:What does STL stand for?

Source template library

► Standard template library

Stream template library

Standard temporary library

 

Q65:Which of the following array is the most suitable for storing a matrix structure

Single-dimensional array

► Two-dimensional array

Three-dimensional array

Four-dimensional array

 

Q66: eof( ), bad( ), good( ), clear( ) all are manipulators.

► True

False

 

Q67: It is possible to return an object from a function through this pointer.

► True

► False

 

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

► True

False

 

Q69: The default scope for members of structures is public whereas the default visibility for class members is private.

► True

False

 

Q70:The operator function of << and >> operators are always the member function of a class.

True

► False

 

Q71: of stream is used for      

Input file system

Output file stream

Both

All of the given

 

Q72:A structure is a collection of                   under a single name.

value

►variables

data

None of the given

 

Q73:The first character of a variable name must be an alphabet or

► underscore

Digit

Special character

Comma

 

Q74:Suppose int multi[5][10]; when we are using **multi , it means,

Single byte

► Simple Boolean

► Both

Double dereferencing

 

Q75:A character is stored in the memory in           

►byte

►integer

►string

►None of the given

 

Q76: dereferencing operator is represented by     

►*

►+

►–

►None of the given

 

Q76:                     transfers the executable code from main memory to hard disk.

►Loader

►Debugger

►Compiler

►Linker

 

Q77:When the logical operator OR (||) combine two expressions exp1 and exp2 then the result will be false only,

► Both exp1 and exp2 are true

►When both exp1 and exp2 are false

►If exp1 is true and exp2 is false

►Only exp1 is false and exp2 is true

 

Q78:suppose we have int y[10]; To access the 4th element of the array we write         .

►y[4];

►y[3];

►y[2];

►none of given

 

Q79: 12 & 8 = (1000) 2 =       . & is used to AND two numbers bit-wise 4

►8

►6

►12

►none

 

Q80:From the following; which one is used as an assignment operator?

►Equal sign ‘=’

►Double equal sign ‘==’

►Both equal and double equal sign

►None of the given options

 

Q81:C++ is a                          language.

►High Level

►Low Level

►Machine

►Fourth Generation

 

Q82:          operator uses the sign ^.

►Bit-wise OR

►Exclusive OR

►AND Operator

►NOT operator

 

Q83: While developing a program; should we think about the user interface?

►Yes

► No

 

Q84:What will be the result of arithmetic expression 5+25/5*5?

►45

►6

►30

►9

 

Q85:Why we use “cin”?

►send data to printer

►To read data from keyboard

►For displaying message

►Show display output on the screen

 

Q86:At the              , we try to break up the problem into functional units

►analysis phase

►design phase

►Implementation phase

►None of the given

 

Q87:If int sum = 54; Then the value of the following statement is sum = sum – 3;

►52

►50

►51

►57

 

Q88:To get the value stored at a memory address, we use the                       

►referencing operator

►dereferencing operator

►simple operator

►None of the given

 

Q89:In C/C++; by default arguments are passed by       to a function.

►Reference

►Value

►Type

►Data

 

Q90:The string in the array is terminated by a       .

►Zero

►Nil

►null

►one

 

Q91:Structures are syntactically defined with the word                  .

►struck

►struct

►structure

►None of the given

 

Q92:C is widely known as development language of       operating system.

►Linux

►Unix

►Windows

►Mac OS

 

Q93:In order to get the right most digit of a number, we divide this number by 10 and take its

►Remainder

►Quotient

►Divisor

►None of the given options

 

Q94:               Returns true if c is a digit and false otherwise.

 

►(int) isalpha( int c )

►[int] isalnum( int c )

► {int} isxdigit( int c )

►int isdigit( int c )

 

Q95:If int a = 50; then the value of a/= 3; will be,

►15

►18

►16

►17

 

Q96:Pointers store the                                

►value of a variable

►memory address

►characters

►None of the given

 

Q97:            allow us to have a memory location and use it as int or char interchangeably

►structures

►union

►construct

►None of the given

 

Q98:In Analysis, we try to have a                   

►Determined the inputs

►Break up of problem

►Precise problem statement

►None of the given

 

Q99:A structure is a collection of                   under a single name.

►values

►variables

►data

►None of the given

 

Q100: If a function has not been declared before its definition, this error is

 

►logical error

►syntax error run

►time error

►None of these

 

 

 

 

 

Share Story On Your Favorite Platform !

By Admin