Back-End Programming Exam  >  Back-End Programming Tests  >  Test: Pointers - 2 - Back-End Programming MCQ

Test: Pointers - 2 - Back-End Programming MCQ


Test Description

15 Questions MCQ Test - Test: Pointers - 2

Test: Pointers - 2 for Back-End Programming 2024 is part of Back-End Programming preparation. The Test: Pointers - 2 questions and answers have been prepared according to the Back-End Programming exam syllabus.The Test: Pointers - 2 MCQs are made for Back-End Programming 2024 Exam. Find important definitions, questions, notes, meanings, examples, exercises, MCQs and online tests for Test: Pointers - 2 below.
Solutions of Test: Pointers - 2 questions in English are available as part of our course for Back-End Programming & Test: Pointers - 2 solutions in Hindi for Back-End Programming course. Download more important topics, notes, lectures and mock test series for Back-End Programming Exam by signing up for free. Attempt Test: Pointers - 2 | 15 questions in 30 minutes | Mock test for Back-End Programming preparation | Free important questions MCQ to study for Back-End Programming Exam | Download free PDF with solutions
Test: Pointers - 2 - Question 1

What is meaning of following declaration?
int(*p[5])();

Detailed Solution for Test: Pointers - 2 - Question 1

In the above declaration the variable p is array not pointer.

Test: Pointers - 2 - Question 2

What is the output of the following question?
#include<stdio.h>
int main() 

          char *p; 
          p = "C Programming"; 
          printf("%c",*&*p); 
    return 0;
}

Detailed Solution for Test: Pointers - 2 - Question 2

* is a dereference operator & is a reference operator. They can be applied any number of times provided it is meaningful. Here p points to the first character in the string “C Programming”. *p dereferences it and so its value is C. Again & references it to an address and * dereferences it to the value C.

1 Crore+ students have signed up on EduRev. Have you? Download the App
Test: Pointers - 2 - Question 3

What is the use of this pointer?

Detailed Solution for Test: Pointers - 2 - Question 3

/* local variable is same as a member's name */
class Test
{
private:
   int x;
public:
   void setX (int x)
   {
       // The 'this' pointer is used to retrieve the object's x
       // hidden by the local variable 'x'
       this->x = x;
   }
   void print() { cout << "x = " << x << endl; }
};

And following example for second and third point.
#include
using namespace std;
 
class Test
{
private:
  int x;
  int y;
public:
  Test(int x = 0, int y = 0) { this->x = x; this->y = y; }
  Test &setX(int a) { x = a; return *this; }
  Test &setY(int b) { y = b; return *this; }
  void print() { cout << "x = " << x << " y = " << y << endl; }
};
 
int main()
{
  Test obj1(5, 5);
 
  // Chained function calls.  All calls modify the same object
  // as the same object is returned by reference
  obj1.setX(10).setY(20);
 
  obj1.print();
  return 0;
}

Test: Pointers - 2 - Question 4

When does the void pointer can be dereferenced?

Detailed Solution for Test: Pointers - 2 - Question 4

By casting the pointer to another data type, it can dereferenced from void pointer.

Test: Pointers - 2 - Question 5

A pointer is

Test: Pointers - 2 - Question 6

Predict the output of following C++ program
#include<iostream>
using namespace std;
 
class Test
{
private:
  int x;
  int y;
public:
  Test(int x = 0, int y = 0) { this->x = x; this->y = y; }
  static void fun1() { cout << "Inside fun1()"; }
  static void fun2() { cout << "Inside fun2()"; this->fun1(); }
};
 
int main()
{
  Test obj;
  obj.fun2();
  return 0;
}

Detailed Solution for Test: Pointers - 2 - Question 6

There is error in fun2(). It is a static function and tries to access this pointer. this pointer is not available to static member functions as static member function can be called without any object.

Test: Pointers - 2 - Question 7

 What we can’t do on a void pointer?

Detailed Solution for Test: Pointers - 2 - Question 7

Because void pointer is used to cast the variables only, So pointer arithemetic can’t be done in a void pointer.

Test: Pointers - 2 - Question 8

What is (void*)0?

Test: Pointers - 2 - Question 9

The operator used for dereferencing or indirection is ____

Test: Pointers - 2 - Question 10

What is the output of following program?
#include<stdio.h>
int main()
{
          int *ptr, a=5;
          ptr = &a;
          *ptr += 1;
          printf("%d, %d", *ptr, a);
    return 0;
}

Detailed Solution for Test: Pointers - 2 - Question 10

Address of variable a is assigned to the integer pointer ptr.
Due to the statement;
*ptr += 1;
value at address pointing by ptr incremented by 1.
As the value at address is changed so variable a also get the updated value.

Test: Pointers - 2 - Question 11

Choose the right option

     string* x, y;

Detailed Solution for Test: Pointers - 2 - Question 11

* is to be grouped with the variables not the data types.

Test: Pointers - 2 - Question 12

What will be the output of the following program?
#include<stdio.h>
int main()
{
          int i = 10;
          void *p = &i;
          printf("%d\n", (int)*p);
    return 0;
}

Detailed Solution for Test: Pointers - 2 - Question 12

p is pointer of type void

Test: Pointers - 2 - Question 13

Which of the following is illegal?

Detailed Solution for Test: Pointers - 2 - Question 13

dp is initialized int value of i.

Test: Pointers - 2 - Question 14

The declaration
int (*p) [5];
means

Test: Pointers - 2 - Question 15

What is the output of this program?

#include < iostream >
using namespace std;
int main()
{
char arr[20];
int i;
for(i = 0; i < 10; i++)
*(arr + i) = 65 + i;
*(arr + i) = '\0';
cout << arr;
return(0);
}

Detailed Solution for Test: Pointers - 2 - Question 15

Each time we are assigning 65 + i. In first iteration i = 0 and 65 is assigned. So it will print from A to J.

Information about Test: Pointers - 2 Page
In this test you can find the Exam questions for Test: Pointers - 2 solved & explained in the simplest way possible. Besides giving Questions and answers for Test: Pointers - 2, EduRev gives you an ample number of Online tests for practice
Download as PDF