What will be output of following program?
#include int main(){
int i = 100;
printf("value of i : %d addresss of i : %u",i,&i);
i++;
printf("\nvalue of i : %d addresss of i : %u",i,&i);
return 0;
}
A. value of i : 100 addresss of i : Address value of i : 101 addresss of i : Address
value of i : 100 addresss of i : Address value of i : 100 addresss of i : Address
value of i : 101 addresss of i : Address value of i : 101 addresss of i : Address
Compilation error
Answer: Option A.
Within the scope of any variable, value of variable may change but its address will never change in any modification of variable.
What is meaning of following declaration? int(*ptr[5])();
ptr is pointer to function.
ptr is pointer to array of function.
ptr is pointer to such function which return type is array.
ptr is pointer to array of function.
Answer: Option B.
Here ptr is array not pointer.
What will be output if you will compile and execute the following c code? #include
int main(){
const int x=25;
int * const p=&x;
*p=2*x;
printf("%d",x);
return 0;
}
25
50
0
Compiler error
Answer: Option B.
Analyse the following code snippet and choose the answer:-
#include Class Temp { private:
int m_ival;
public:
Temp()
{
Cout<<"OBJECT CREATED\n"< }
~Temp()
{
Cout<<"OBJECT DESTROYED\n"< }
};
void fnRead()
{
Temp oTempObj;
}
int main()
{
fnRead();
cout<<"IN MAIN \n"< return 0;
}
OBJECT CREATED OBJECT DESTROYED
OBJECT CREATED OBJECT DESTROYED IN MAIN
OBJECT CREATED IN MAIN
Compilation Error
Answer: Option B.
Observe the following code and chose the correct statement(s)
class Name
{
const char *s ;.
};
class Table
{
Name *p; size_t sz ; public :
Table(size_ts = 15) {p = new Name [sz = s]; }
~Table() {delete [ ]p ;}
Name * lookup(const char *);
bool insert(Name *);
};
Which of the following are essential features of object-oriented programming languages?
Abstraction and encapsulation
Strictly-typedness
Type-safe property coupled with sub-type rule
Polymorphism in the presence of inheritance
1. 1 and 2 only
1 and 4 only
1,2 and 4 only
1,3 and 4 only
Answer: Option B.
Object oriented programming language is Object based PL+Abstraction + Inheritance. The last two (abstraction and inheritance) are must for any L to be OOPL.