Which of the following is true in Java?

Loading

Practice OOPS Concepts –

Which of the following is true in Java?

What is the output of following program?


			  		

Loading

Practice OOPS Concepts –

What is the output of following program?

#include <iostream>
using namespace std;

class Player
{
private:
int id;
static int next_id;
public:
int getID() { return id; }
Player() { id = next_id++; }
};
int Player::next_id = 1;

int main()
{
Player p1;
Player p2;
Player p3;
cout << p1.getID() << " ";
cout << p2.getID() << " ";
cout << p3.getID();
return 0;
}

RunTime Polymorphism is achieved by ___________. 

 

Loading

Practice OOPS Concepts –

RunTime Polymorphism is achieved by ___________. 

 

What is the output of the following code


			  		

Loading

Practice OOPS Concepts –

What is the output of the following code

char symbol[3]={‘a’,‘b’,‘c’};
for (int index=0; index<3; index++)
cout << symbol [index];

 

When would a structure variable get destroyed?

Loading

Practice OOPS Concepts –

When would a structure variable get destroyed?

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();