| Snaprecruit.com

| Snaprecruit.com

Interview question based on skill :

Take as many assements as you can to improve your validate your skill rating

Total Questions: 20

1. For the following code, choose the correct option: class A { int marks; protected : A() { marks=100; } public : A( int x) { marks=x; } };

Correct Answer is : Event

2. If the protected members are to be made accessible only to the nearest subclass and no further subclasses, which access specifier should be used in inheritance?

Correct Answer is : TRUE

3. What will be the output of following code (all header files and required things are included)? class A { int marks; protected : A(int x) { marks=x; } public : A() { marks=100; } } class B { A a; A b=100; }; main() { A a, b=100; B c; }

Correct Answer is : event_scheduler = ON

4. Which among the following is true for the given code below. class A { protected : int marks; public : A() { marks=100; } disp() { cout<<”marks=”<<marks; } }; class B: protected A { }; B b; b.disp();

Correct Answer is : SHOW VARIABLES LIKE ‘event_scheduler’

5. Protected members differ from default members as_______

Correct Answer is : DISABLED

6. If all the members are defined in protected specifier then ( Constructors not considered ):

Correct Answer is : TRUE

7. Which among the following is correct for the code given. class A { private: int marks; A() { } Public : disp() { cout<< marks; } }; class B: public A { } B b;

Correct Answer is : error

8. If protected inheritance is used then _____

Correct Answer is : EVERY

9. If protected members are to be accessed from outside the class then__________

Correct Answer is : EVENT

10. Which among the following can use protected access specifier?

Correct Answer is : created the event

11. Protected access is same as default access that is given implicitly in java if no specifier is mentioned.

Correct Answer is : 2

12. If a class have default constructor defined in private access, and one parameter constructor in protected mode, how will it be possible to create instance of object?

Correct Answer is : 0

13. What will be the output of the program given below: class A { Public : A(int a=0) { cout<<”new A”; } }; A a; A b; A c;

Correct Answer is : abcxyz

14. Which among the following is true for the code given below: class A { int marks; public : disp() { cout<<marks; } } class B: protected A { char name[20]; } A a; a.disp(); B b; b.disp();

Correct Answer is : TRUE

15. If the members have to be accessed from anywhere in program and other packages also, which access specifier should be used?

Correct Answer is : FALSE

16. Which among the following have least security according to the access permissions allowed?

Correct Answer is :

17. Which among the following can be used for outermost class access specifier in java?

Correct Answer is : TRUE

18. We can reduce the visibility of inherited methods.

Correct Answer is : 4

19. If members of a super class are public, then________

Correct Answer is : !, ^, <<, XOR

20. How many public class(s) (outermost) can be there in a java program?

Correct Answer is : 97