When would a structure variable get destroyed?

Loading

Practice OOPS Concepts –

When would a structure variable get destroyed?

Which of the following statements are correct?

Loading

Practice References –

Which of the following statements are correct?

  1. A struct can contain properties.
  2. A struct can contain constructors.
  3. A struct can contain protected data members.
  4. A struct cannot contain methods.
  5. A struct cannot contain constants.

How many bytes will the structure variable samp occupy in

Loading

Practice OOPS Concepts –

How many bytes will the structure variable samp occupy in memory if it is defined as shown below?

class Trial {
int i;
Decimal d;
}
struct Sample {
private int x;
private Single y;
private Trial z;
}
Sample samp = new Sample();

Which of the following is the correct way to define a variable of t

Loading

Practice OOPS Concepts –

Which of the following is the correct way to define a variable of the type struct Emp declared below?

struct Emp {
private String name;
private int age;
private Single sal;
}
  1. Emp e(); e = new Emp();
  2. Emp e = new Emp;
  3. Emp e; e = new Emp;
  4. Emp e = new Emp();
  5. Emp e;

Which of the following is the correct way of setting values into th

Loading

Practice OOPS Concepts –

Which of the following is the correct way of setting values into the structure variable e defined below?

struct Emp { 
public String name;
public int age;
public Single sal;
}
Emp e = new Emp();

In C++, dynamic memory allocation is accomplished with the operator

Loading

Practice Memory Management –

In C++, dynamic memory allocation is accomplished with the operator ____________.

Find the output of the following program for n=5

Loading

Practice OOPS Concepts –

Find the output of the following program for n=5

int foo(int n) {
if(n == 0)
return 1;
else {
int sum = 0;
for(int i=foo(n-1); i<n; i++)
sum += foo(i);
}
return sum;
}

 

Which of the following statements are true in c++?

Loading

Practice OOPS Concepts –

Which of the following statements are true in c++?

Which of the following expressions is illegal? 

Loading

Practice Templates –

Which of the following expressions is illegal? 

What will be the output of the following program?

Loading

Practice File Handling –

What will be the output of the following program?

#include<iostream.h>  
int main() {
int x = 10, y = 20;
int *ptr = &x;
int &ref = y;
*ptr++;
ref++;
cout<< x << " " << y;
return 0;
}