Back-End Programming Exam  >  Back-End Programming Tests  >  Learn to Program with C++: Beginner to Expert  >  Test: Pointers - 1 - Back-End Programming MCQ

Test: Pointers - 1 - Back-End Programming MCQ


Test Description

10 Questions MCQ Test Learn to Program with C++: Beginner to Expert - Test: Pointers - 1

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

What does the following statement mean?

     int (*fp)(char*)

Detailed Solution for Test: Pointers - 1 - Question 1

Pointer to function taking a char* argument and returns an int

Test: Pointers - 1 - Question 2

If a variable is a pointer to a structure, then which of the following operator is used to access data members of the structure through the pointer variable?

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

Predict the output of following C++ program.
#include<iostream>
using namespace std;
 
class Test
{
private:
  int x;
public:
  Test(int x = 0) { this->x = x; }
  void change(Test *t) { this = t; }
  void print() { cout << "x = " << x << endl; }
};
 
int main()
{
  Test obj(5);
  Test *ptr = new Test (10);
  obj.change(ptr);
  obj.print();
  return 0;
}

Detailed Solution for Test: Pointers - 1 - Question 3

this is a const pointer, so there is an error in line "this = t;"

Test: Pointers - 1 - Question 4

Which one of the following is not a possible state for a pointer?

Detailed Solution for Test: Pointers - 1 - Question 4

A pointer can be in only 3 states a,b and c.

Test: Pointers - 1 - Question 5

What the following, instruction tells?
const int *ptr;

Test: Pointers - 1 - Question 6

Which of the following is true about this pointer?

Detailed Solution for Test: Pointers - 1 - Question 6

The ‘this’ pointer is passed as a hidden argument to all non-static member function calls and is available as a local variable within the body of all non-static functions. ‘this’ pointer is a constant pointer that holds the memory address of the current object. ‘this’ pointer is not available in static member functions as static member functions can be called without any object (with class name).

Test: Pointers - 1 - Question 7

What is the output of this program?

#include < iostream >
using namespace std;
int main()
{
int a = 5, b = 10, c = 15;
int *arr[ ] = {&a, &b, &c};
cout << arr[1];
return 0;
}

Detailed Solution for Test: Pointers - 1 - Question 7

Array element cannot be address of auto variable. It can be address of static or extern variables.

Test: Pointers - 1 - Question 8

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

Test: Pointers - 1 - Question 9

Predict the output of following C++ program?
#include<iostream>
using namespace std;
 
class Test
{
private:
  int x;
public:
  Test() {x = 0;}
  void destroy()  { delete this; }
  void print() { cout << "x = " << x; }
};
 
int main()
{
  Test obj;
  obj.destroy();
  obj.print();
  return 0;
}

Detailed Solution for Test: Pointers - 1 - Question 9

delete operator works only for objects allocated using operator new. If the object is created using new, then we can do delete this, otherwise behavior is undefined. See “delete this” in C++ for more examples.

Test: Pointers - 1 - Question 10

What is the output of this program?

#include < iostream >

using namespace std;

int main()

{

char *ptr;

char Str[] = "abcdefg";

ptr = Str;

ptr += 5;

cout << ptr;

return 0;

}

Detailed Solution for Test: Pointers - 1 - Question 10

Pointer ptr points to string ‘fg’. So it prints fg.

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