A variable that is declared private Is visible only m the su

A variable that is declared private: Is visible only m the subclasses (and no, in the Cass R b declared in). Is variable only in the class it is declared in. Is visible m the class it is declared in, and all of its subclasses. Is visible in the class it is declared in, and all of its superclasses. Which of the following statements is true? A reference is a constant, while a pointer is a variable. Both pointer and reference store the physical address of a memory location. When a variable is passed to a function by value, a new memory containing the same value is created All of above. Which of the following is not a valid identifier? double double2 sum_of_double double What is the output of the following code fragment? 6 5 6 7 5 4 5 6 int n, k = 6; n = {(50 k) == 2) 7 k - 1; k + 1; cout

Solution

2) All of the above is the correct option:

As by defintion Pointer is a variable which hold direct/physical memory location of another variable (this definition itself makes the first and second option true) and by definition Reference are constants which holds the memory location. Also when we pass by value that means a copy in memory of actual parameter\'s value that is passed in.

3) sum_of_double is the option

By definition a valid identifier could be following:

A valid identifier can have letters (both uppercase and lowercase letters), digits and it can start with underscore or letter.

5) arr = [0,5,10,15,20,25,30]

int x, *ptr1=arr+2, *ptr2 = &arr[5];

x=*(ptr2-2) + *(ptr1+3);

cout<<x;

Here *ptr1 = arr+2 which means we are setting ptr1 as pointer to the array index 2 i.e to element at index location arr[2] and *ptr2 = &arr[5] points to the arr[5] element.

x = *(ptr2-2) + *(ptr1+3)

ptr2 was refering to 5th index we are refering it as base location so we are just two index back hence basicaly we are refering to value at arr[3] which is 15 and ptr1+3 where prt1 was point to second index hence this equation points to 5th index value which is 25

x= 15+25

x= 40

Output is 40

 A variable that is declared private: Is visible only m the subclasses (and no, in the Cass R b declared in). Is variable only in the class it is declared in. I

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site