forum_image

Discussion Forum

Interative Forum for discussing any query literally to UGC-NET Computer Science, GATE Computer Science and Computer Sciene and Technology in general.

ugc_net image

UGC-NET Computer Science

Correspondence Courses and Test Series to prepare for UGC-NET computer science and applications

GATE image

GATE

MCQs, Lecture Notes, Ebooks for GATE preparation

freestuff image
jobs image

Jobs Newsfeed

Timely information of various Recruitments.

NextPrev

MCQs C++ |UGC-NET|GATE|Computer Science

71.What is the output of the code #include class blah { public: static int a; int b; blah(int x) { b=x; a=b+1; } }; int blah::a = 0; int main(void) { blah b1(5); blah b2(12); cout << "b1.a is " << b1.a << endl; cout << "b1.b is " << b1.b << endl; cout << "b2.a is " << b2.a << endl; cout << "b2.b is " << b2.b << endl; }
A.b1.a is 12 b1.b is 5 b2.a is 12 b2.b is 12
B.b1.a is 13 b1.b is 5 b2.a is 13 b2.b is 12
C.b1.a is 13 b1.b is 4 b2.a is 13 b2.b is 13
D.b1.a is 13 b1.b is 5 b2.a is 13 b2.b is 13
View/Hide Ans
Explanation
72.Sample { public: int *ptr; Sample(int i) { ptr = new int(i); } ~Sample() { delete ptr; } void PrintVal() { cout « "The value is " « *ptr; } }; void SomeFunc(Sample x) { cout « "Say i am in someFunc " « endl; } int main() { Sample s1= 10; SomeFunc(s1); s1.PrintVal(); }
A.Say i am in someFunc The value is 10
B.Say i am in someFunc Say i am in someFunc
C.Say i am in someFunc Null pointer assignment(Run-time error)
D.Nothing will be printed
View/Hide Ans
Explanation
73.class base { public: int bval; base(){ bval=0;} }; class deri:public base { public: int dval; deri(){ dval=1;} }; void SomeFunc(base *arr,int size) { for(int i=0; i‹size; i++,arr++) cout«arr-›bval; cout«endl; } int main() { base BaseArr[5]; SomeFunc(BaseArr,5); deri DeriArr[5]; SomeFunc(DeriArr,5); }
A.00000 11111
B.11111 00000
C.00000 01010
D.01010 01010
View/Hide Ans
Explanation
74.Which of the following declares a pointer to a function g, which takes two ints and returns nothing?
A.from base from derived
B.from base from base
C.from derived from derived
D.from derived from base
View/Hide Ans
Explanation
75.class some { public: ~some() { cout«"some's destructor"«endl; } }; void main() { some s; s.~some(); }
A.Empty string
B.some's destructor
C.some's destructor some's destructor
D.Compile Error
View/Hide Ans
Explanation
76.class opOverload { public: int operator==(opOverload temp); }; int opOverload::operator==(opOverload temp) { if(*this == temp ) { cout«"both are same objects\n"; return 1;} Else { cout«"both are different\n"; return 0; } } void main() { opOverload a1, a2; a1==a2; }
A.both are same objects
B.Runtime Error: Stack Overflow
C.both are different
D.Empty String
View/Hide Ans
Explanation
77.class complex { double re; double im; public: complex() : re(1),im(0.5) {} int operator==(complex &rhs); operator int(){} }; int complex::operator == (complex &rhs) { if((this->re == rhs.re) && (this->im == rhs.im)) return 1; else return 0; } int main() { complex c1; cout« c1; }
A.10,5
B.garbage value
C.Compile error
D.empty screen
View/Hide Ans
Explanation
78.What is wrong with this class declaration? class something { char *str; public: something() { str = new char[10]; } ~something() { delete str; } };
A.something() wrongly declared
B.No error
C.Compile Error
D.~something() wrongly declared
View/Hide Ans
Explanation
79.class base { public : out() { cout«"base "; } }; class deri { public : out() { cout«"deri "; } }; void main() { deri dp[3]; base *bp = (base*)dp; for (int i=0; i<3;i++) (bp++)->out(); }
A.base base base
B.base deri base
C.deri base base
D.deri deri deri
View/Hide Ans
Explanation
80.class test { public : friend void fun ( sample, test ) ; } ; class sample { public : friend void fun ( sample, test ) ; } ; void fun ( sample s, test t ) { // code } void main( ) { sample s ; test t ; fun ( s, t ) ; }
A.compile error
B.some string
C.empty string
D.runtime error
View/Hide Ans
Explanation


Author Does Not claim of any answer these answers are as per expert opinion


Pages: 1 2 3 4 5 6 7 8 9