Agilent Interview questions
1]. What are the default member functions included in the class definition ?
2]. Does default destructor provided by the compiler?
3]. How to make a class to restrict its number of instances to 5?
4]. What is singleton class? Design it.
5]. What will happen?
main(){
A a1;
a1=a1;
/* Some other code */
}
6]. main(){
int x=5;
printf("%d%d%d",x,++x,x++);
}
7]. main(){
int x=5;
printf("%d%d%d",x,x<<1,x>>1);
}
8]. What are the various storage classes ?
A. Extern, Static, Auto, Register
9]. Is this right ? Why or Why not?
static extern int x;
Ans: No, It will give compilation error. "more than one storage class specified", Reason is obvious.
10]. What is the need of writing our own copy constructor when it is by default provided by the compiler?
11]. What is object slicing?
12]. What is stack unwinding?
13]. Can we use references as class member variables?
Ans: Yes, we can. But then it must be initialized in constructor base/member initializer list. e.g.
class A{
int x;
int &y;
public:
A():x(1),y(x){
cout<<"A x="<<<" y="<<
}
};
No comments:
Post a Comment