Home Tuitions

CUET CS Chapter-Pointers 

Board CBSE
Textbook NCERT
Class Class 12
Subject Computer Science
Chapter CUET CS Chapter-Pointers 
Chapter Name Pointers
Category CUET (Common University Entrance Test) UG

MCQ-Based Questions for CUET Computer Science Chapter-Pointers 

This page is prepared by HT experts and consists of MCQ-Based Questions for CUET Computer Science chapter-Pointers with a detailed explanation of all the questions asked from Pointers. To find the solution to the MCQ questions click on the answer tab. Check out chapter-wise CUET computer science Practice MCQ Based Questions. 

Practice Questions for CUET Computer Science chapter-Pointers SET-1

Computer Science - MCQ on Pointers

Class XII

Q.1 The pointers that can cause a system to crash are

a) initialized pointers.

b) wild or uninitialized pointers.

c) virus pointers.

d) referenced pointers.

Answer:

(b)

Explanation: It is easy to use pointers incorrectly, causing bugs that are difficult to find, and which can crash a computer.

Q.2 In the conceptual memory map of a C++ program the area used for function calls’, return addresses, arguments and local variables is

a) stack.

b) heap.

c) reserved area.

d) dynamic memory allocated area.

Answer:

a) Explanation: While a program executes, the stack region is used for many things.

Q.3 The area used for dynamic allocation of memory is called

a) stack.

b) heap.

c) reserved area.

d) free store.

Answer:

(b)

Explanation: The heap memory area is a region of free memory, from which chunks of memory are allocated via C++’s dynamic memory allocation functions.

Q.4 When the memory is allocated during compilation, it is

a) dynamic memory allocation.

b) free store.

c) static memory allocation.

d) automatic memory allocation.

Answer:

c)

Explanation: The amount of memory to be allocated is known beforehand, and allocated during compile time, then it is static memory allocation.

Q5 When we declare a variable, int c; in a C++ program, the allocation of memory here is

a) dynamic memory allocation.

b) free store.

c) automatic memory allocation

d) static memory allocation.

Answer:

(d)

Explanation: Here the computer knows the length of an integer variable, which is 2 bytes. So 2 bytes internal memory will be allocated to the variable c during compilation itself.

Q.6 When the memory allocation takes place at run time, it is called

a) dynamic memory allocation.

b) static memory allocation.

c) free store.

d) dereferencing memory.

Answer:

a)

Explanation: The amount of memory required is not known beforehand. When the program executes, i.e., during run time only memory is allocated, then it is dynamic memory allocation.

Q.7 When we want to use data structures where, we may only know the maximum needed memory, but actual usage may be far less than that then we use

a) dynamic memory allocation.

b) static memory allocation.

c) free store.

d) dereferencing memory.

Answer:

a)

Explanation: The amount of memory needed is not known beforehand. When the program executes, i.e., during run time only memory is allocated, then it is dynamic memory allocation.

Q.8 The two operators for dynamic memory allocation in C++ are

a) malloc() and calloc().

b) new() and delete().

c) malloc and delete().

d) new() and calloc().

Answer:

b) Explanation: new() is used for memory allocation, whereas delete() is for memory deallocation.

Q.9 The variable that holds the address of another variable, function or data is called

a) null pointer.

b) address variable.

c) pointer variable.

d) function pointer.

Answer:

(c)

Explanation: It is the variable that stores the reference to another variable.

Q.10 The correct declaration of a pointer to an int is

a) int &p.

b) int*p.

c) int p.

d) int p*.

Answer:

(b)

Explanation: Here p is a pointer variable, which holds the address of integer data.

Q.11 The pointer which has a special value that indicates that it is not pointing to any valid reference or memory address is called

a) reference pointer.

b) function pointer.

c) null pointer.

d) empty pointer.

Answer:

(c)

Explanation: A null pointer has a reserved value, often but not necessarily the value 0, indicating that it refers to no object.

Q.12 If we try to dereference a null pointer, then it will result in

a) compile time error.

b) deallocation of memory from null pointer.

c) run time error.

d) no error.

Answer:

c)

Explanation: If this error is left unhandled, it can cause termination of the program immediately.

Q.13 The pointers that can’t be modified with addition and subtraction are

a) reference pointer.

b) function pointer.

c) empty pointer.

d) address pointer.

Answer:

a)

Explanation: Removing this capability makes references much safer to use than pointers.

Q.14 The pointer which points to only public members of the class is called

a) reference pointer.

b) function pointer.

c) empty pointer.

d) an object pointer.

Answer:

(d)

Explanation: We can increment and decrement an object pointer.

Q.15 The output of the given code is

void main ()

{

char *a =”easy”;

char b;

b=++ *a ++;

printf ( “%b”, b);

}

Q.16 If a pointer to double precision quantity is declared, then the appropriate declaration is

a) double *p;

b) double p;

c) double p*;

d) double p;

Answer:

a)

Explanation: Here p is a pointer, which holds the memory address of a float value.

Q.17 If a two dimensional array of integers is declared, with 5 rows and 5 columns, then the appropriate declaration is

a) *int []

b) int [5]

c) int ** [5]

d) Int * p[5]

Answer:

(d)

Explanation: It is an array of 5 int pointers.

Q.18 If a pointer to a function is declared, which accepts 3 integer parameters and return a float value, then the appropriate declaration is

a) double p (int, int, int );

b) double * p (int, int, int ):

c) int * p (double, double, double);

d) double * p (int, int, int );

Answer:

d) Explanation: Here, p is a pointer to a function.

Q.19 If I want to declare a function that accepts three integer arguments and return a pointer to a float, then the appropriate declaration is

a) float p (int *a, int *b, int *c);

b) float * p (int *a, int *b, int *c);

c) float * p (int a, int b, int c);

d) float * p *(int a, int b, int c);

Answer:

(b)

Explanation: It cannot take integer arguments.

Q.20 The character which stands for the address operator is

a) *.

b) ->.

c) &.

d) <<.

Answer:

c)

Explanation: It is also called as the reference operator or address of operator.

Q.21 The character which, stands for the value at address operator is called

a) *.

b) ->.

c) &.

d) <<.

Answer:

a)

Explanation: Using a pointer, we can directly access the value stored in the variable, which it points to.

Q.22 The null pointer is defined in the header file

a) <stdio.h>.

b) <iostream.h>.

c) <stddef.h>.

d) <conio.h>.

Answer:

c)

Explanation: A null pointer has a reserved value, often but not necessarily the value 0, indicating that it refers to no object.

Q.23 The arithmetic operations that may be performed on pointers are

a) multiplication and division.

b) addition and subtraction.

c) multiplication only.

d) addition and division.

Answer:

(b)

Explanation: In pointer arithmetic, all pointers increase and decrease by the length of the data.

Q.24 A proper declaration of pointer is

a) int x;

b) int &x;

c) ptr x;

d) int *x;

Answer:

(d)

Explanation: In order to define pointer variables, the programmer must use the operator denoted as * in C++. The symbol * when placed before a pointer, variable means that it as a pointer to.

Q.25 The statement that is valid or legal in C++ is

a) A reference can be used without proper initialization.

b) Array of references is legal in C++.

c) Char, int pointers can refer to null pointers but null pointers cannot refer to other pointers.

d) Array of pointers is not legal in C++.

Answer:

c)

Explanation: A reference has to be properly initialized, otherwise it will result in an error. In C++ special care is taken for assignment of void pointers to other pointer types. While we can assign a pointer of any type to a void pointer the reverse is not true until we do explicit typecasting.

Q. 26 The correct statement according to the code below is

void *a;

char *b;

a=b;

b=a;

a) This is correct.

b) It would give an error as ‘a’ cannot be assigned to ‘b’.

c) It would give an error as ‘b’ cannot be assigned to ‘a’.

d) Error in statement 3 and 4.

Answer:

(b)

Explanation: In C++, void pointer cannot be assigned to the pointer of any type. This would give an error of type mismatch. It can be made true when we explicitly typecast it, b=(char*) a;

Q. 27 The proper keyword to deallocate memory is

a) free.

b) delete.

c) clear.

d) remove.

Answer:

(b)

Explanation: The delete operator deallocates a block of memory. The argument must be a pointer to a block of memory previously allocated for an object created with the new operator. The delete operator has a result of type void and therefore does not return a value.

Q 28 The C++ statement to display the memory address of a variable is

a) *a;

b) .a;

c) &a;

d) address(a);

Answer:

(c)

Explanation: The operator & is used to find the address associated with a variable. The syntax of the reference operator is as follows: &variablename

Q. 29 The C++ statement a& denotes

a) address of a.

b) reference operator.

c) pointer.

d) scanning the value of a.

Answer:

(b)

Explanation: The programmer must note that the address operator placed before a variable is not the same as operator & placed after the variable. For example, &x is not same as x&. Variable &x refers to address operator whereas x& refer to reference operator&.

Q. 30 The C++ statement that gives the value stored in pointer a is

a) a;

b) val(a);

c) *a;

d) &a;

Answer:

(c)

Explanation: * is value at address operator thus it displays the value pointed by pointer a.

Q. 31 The keyword used to allocate memory is

a) new.

b) malloc.

c) create.

d) value.

Answer:

(a)

Explanation: The new keyword allocates memory for an object or array of objects of type-name from the free store and returns a suitably typed, nonzero pointer to the object.

Q.32 Improper use of new() and delete() operators may lead to

a) memory allocatin.

b) memory deallocation.

c) memory use.

d) memory leaks.

Answer:

(d)

Explanation: The memory allocated through new() must be properly deleted through delete().

Q.33 The name of an array is actually a pointer pointing to

a) the first element of the array.

b) the last element of the array.

c) any arbitrary element of the array.

d) the second element of the array.

Answer:

a)

Explanation: C++ treats the name of an array, as if it were a pointer i.e., memory address of some element.

Q.34 To print the data of the tenth element of array names, we can give

a) cout << names (9

b) cout << * (names + 9;

c) cout << names [10];

d) cout << * (names + 10;

Answer:

(b)

Explanation: Since, arrays are very closely relate to pointers, we can use either of the two statements: cout << * (names + 9; or cout << names [9]; .It is because arrays are started from array [0] element.

Q.35 In the declaration: int * p [10]; for 10 pointer that point to integers, the

a) array elements are always allocated first 10 memory locations.

b) array elements are always allocated last 10 memory locations.

c) array elements are always allocated randomly 10 memory locations.

d) array elements are always allocated contiguous 10 memory locations.

Answer:

(d)

Explanation: This declaration is for an array of 10 int pointers; so contiguous memory would be allocated for 10 int type pointers.

Q.36 While scanning arrays, it is faster to use

a) an index rather than an element pointer.

b) an element pointer rather than an index.

c) an index rather than using data structure trees.

d) trees rather than queues.

Answer:

(b)

Explanation: Using pointers, for accessing array elements fastens the process.

Q.37 C++ treats a string as

a) an array of integers terminated by a null (‘\0’).

b) an array of characters started by a null (‘\0’).

c) an array of characters terminated by a null (‘\0’).

d) an array of characters and integers.

Answer:

c) Explanation: A string is a one-dimensional array of characters, and is terminated by null (‘\ 0’).

Q.38 The correct output of the following program is

#include<iostream.h>

void main()

{

char *p=”abc”;

char *q=p;

cout<<p<<endl<<q ;

q=”xyz”;

cout<<p<<endl<<q ;

}

a) abc xyz abc xyz.

b) abc abc abc xyz.

c) abc abc xyz xyz.

d) abc abc abc abc.

Answer:

(b)

Explanation: Value of p is assigned to pointer q . So initially *p and * q will have same value.

Q.39 The correct output of the following program is

#include<iostream.h>

void main()

{

int i=5;

int &j=i;

int p=10;

j=p;

cout<<endl<<i<<endl<<j;

p=20;

cout<<endl<<i<<endl<<j;

}

a) 10 10 10 10.

b) 10 5 20 20.

c) 5 10 10 10.

d) 10 10 20 20.

Answer:

(a)

Explanation: j is a reference to i. If, we assign value of p to j, then value of i also changes.

Q.40 Error in the code below is

main()

{

int i, j;

int *ip;

i=j=ip=0;

}

a) Pointer cannot be used in assignment statement.

b) ip is a pointer and cannot be used as integer.

c) Pointer should not be initialized.

d) Pointer cannot be equal to zero.

Answer:

(b)

Explanation: A pointer points to the address of a variable. It cannot be used as integers.

Q.41 The method, in which the value of each argument in the calling function is copied on to the corresponding formal arguments of the called-function is called

a) call by value.

b) call by reference.

c) call by address.

d) call by name.

Answer:

a) Explanation: In this method, the called function works with, and manipulates its own copy of arguments.

Q.42 The alias name for a variable is called as

a) pointer.

b) Typedef.

c) reference.

d) identification.

Answer:

c)

Explanation: No separate memory is allocated for references.

Q.43 When parameters are passed to the functions by reference, then the

a) formal parameters become aliases to the actual parameters.

b) actual parameters become aliases to the formal parameters.

c) formal parameters and actual parameters are same.

d) formal parameters and actual parameters are different.

Answer:

a)

Explanation: The called function does not create its own copy of original values.

Q.44 A structure having a member element that refers to the structure itself, is called

a) self structure

b) base structure.

c) self-referential structure.

d) recursive structure.

Answer:

c)

Explanation: Self-reference occurs when a system loops back on itself and describes some aspect of its own form or structure.

Q.45 When accessing members of a class using an object pointer, the

a) (.) operator is used.

b) (->) operator is used.

c) (*) operator is used.

d) (&) operator is used.

Answer:

(b)

Explanation: C++ allows us to have pointers to objects. The arrow operator (->) is used to access members of class using object pointer.

Q.46 The arrow (->) operator is used to access the

a) private members of the class with a pointer to an object.

b) protected members of the class with a pointer to an object.

c) public members of the class with a pointer to an object.

d) both private and public members of the class with a pointer to an object.

Answer:

c)

Explanation: A pointer can point to only public members of the class.

Q.47 The data type of the pointer

a) must be the same as that of the data member it points to.

b) should be different than that of the data member it points to.

c) may or may not be same as that of the data member it points to.

d) is always float type.

Answer:

a)

Explanation: A pointer points to a data member of an object and its data type is always same as that of data member.

Q.48 A special pointer, which stores the address of the object that is currently invoking a member function is

a) object pointer.

b) current pointer.

c) function pointer.

d) this pointer.

Answer:

(d)

Explanation: this pointer refers to the current object we are working on.

Q.49 Whenever the member functions of a class are invoked, this pointer is

a) explicitly passed to the member functions.

b) implicitly passed to the member functions.

c) referred to the member functions.

d) called by the class data types.

Answer:

(b)

Explanation: When a member function is called, this pointer is automatically passed as an implicit argument (in built).

Q.50 this pointer cannot be passed to

a) the static member functions only.

b) the friend functions only.

c) both the static member functions and friend functions.

d) virtual function, and friend functions but can be passed to static member functions.

Answer:

c)

Explanation: The friend functions are not the members of a class, and therefore, are not passed as this pointer. Similarly, the static member functions do not have this pointer.

Computer Science - MCQ on Pointers

Practice Questions for CUET Computer Science chapter-Pointers SET-2

Q.1 Object pointers are useful in creating objects at

a) compile time.

b) run time.

c) early binding.

d) starting of program.

Answer:

(b)

Explanation: Pointers point to an object created by class. Object pointers point to object at run time, also called late binding.

Q.2 Object pointers are used to access

a) public members of an object.

b) private members of an object.

c) protected members of an object.

d) global members of an object.

Answer:

a)

Explanation: Only public members are available to object members as they can be accessed by the code outside the class.

Q.3 Object pointers are used to access public members of an object using

a) dot operator.

b) brackets.

c) access specifier.

d) arrow operator.

Answer:

(d)

Explanation: This is an arrow operator -> used to access public members of objects.

Q.4 The pointer that refers to an object, which currently invokes a member function, is called

a) object pointer.

b) member function pointer.

c) address pointer.

d) this pointer.

Answer:

(d)

Explanation: this pointer refers to the object on which we are currently working.

Q.5 Pointers to objects of base class type

a) may be compatible with pointers to objects of a derived class.

b) may not be compatible with pointers to objects of a derived class.

c) should always be compatible with pointers to objects of a derived class.

d) should never be compatible with pointers to objects of a derived class.

Answer:

c)

Explanation: This is the reason we use a single pointer variable to point to objects of base class as well as derived classes.

Q.6 To point to objects of base class as well as derived classes, we use

a) two pointers.(one for base class and one for derived class)

b) a single pointer.

c) many pointers.

d) four pointers ?(two for base class, two for derived class)

Answer:

(b)

Explanation: Pointers to objects of base class type are compatible with pointers to objects of a derived class.

Q.7 A virtual function is called pure function, when it is equated to

a) zero.

b) one.

c) two.

d) many.

Answer:

a)

Explanation: In C++, declaring pure virtual functions creates pure interfaces. A pure virtual function is declared as follows:

virtual void Activate() = 0;

The “= 0” on the end of the declaration is supposed to represent the fact that the function has no implementation.

Q.8 A class containing pure virtual function is called

a) virtual class.

b) abstract class.

c) pure class.

d) derived class.

Answer:

(b)

Explanation: It is the pure interfaces within an abstract class, which define the common features encapsulated within it. They are the basis for the polymorphic behavior of abstract classes. In C++, declaring pure virtual functions creates pure interfaces.

Q.9 We can use pointers with

a) arrays and structures only.

b) arrays and functions only.

c) functions and structures only.

d) arrays, structures and functions.

Answer:

(d)

Explanation: We can use pointers explicitly with all these 3: structures, functions and arrays.

Q.10 Consider the sample code:

int a[]=(1,4,8,5,1,4

int*ptr, x;

ptr=a+4;

x= ptr-a;

The x in the sample code above is equal to

a) –3.

b) 0.

c) 4.

d) 4*sizeof (int).

Answer:

c)

Explanation: Here, ptr=5 , x= ptr-a =5-1 =4.

Q.11 The first element of an array num can be represented as

a) *num;

b) #

c) *num[I];

d) num;

Answer:

(a)

Explanation: Elements of an array can be accessed by *(num+i);

But, when *num is written, by default it returns the first element as

i=0, for the expression *(num + i).