| 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. How to overcome diamond problem ?

Correct Answer is : Using virtual keyword with same name function

2. When multiple inheritance is used, which class object should be used in order to access all the available members of parent and derived class ?

Correct Answer is : Derived class object

3. If all the members of all the base classes are private then,

Correct Answer is : There won’t be any use of multiple inheritance

4. Is it compulsory to have constructor for all the classes involved in multiple inheritance?

Correct Answer is : Yes, only if no abstract class is involved

5. If a class contains 2 nested class and is being inherited by another class, will there be any multiple inheritance?

Correct Answer is : No, only single level inheritance is used

6. Which members can’t be accessed in derived class in multiple inheritance ?

Correct Answer is : Private members of base

7. Can the derived class be made abstract if multiple inheritance is used ?

Correct Answer is : No, since constructors won’t be there

8. Which among the following best describes a nested class?

Correct Answer is : Class inside a class

9. Which feature of OOP reduces the use of nested classes?

Correct Answer is : Inheritance

10. How many categories are nested classes divided into?

Correct Answer is : 2

11. Non-static nested classes have access to _____________ from enclosing class.

Correct Answer is : All the members

12. Static nested classes doesn’t have access to _________________ from enclosing class.

Correct Answer is : Any other members

13. The nested class can be declared ___________________

Correct Answer is : Public, Protected, Private or Package private

14. Use of nested class ____________ encapsulation.

Correct Answer is : Increases

15. Which among the following is correct advantage/disadvantage of nested classes?

Correct Answer is : Makes the code efficient and readable

16. How to access static nested classes?

Correct Answer is : OuterClass.StaticNestedClass

17. A nested class can have its own static members.

Correct Answer is : FALSE

18. How to create object of the inner class?

Correct Answer is : OuterClass.InnerClass innerObject = outerObject.new InnerClass();

19. What will be the output of the following code? public class Test { public int a=0; class innerClass { public int a=1; void innermethod(int x) { System.out.println(“value of x = ” + x); System.out.println(“value of this.x = ” + this.x); System.out.println(“value of Test.this.x = ” + Test.T=this.x); } } } public static void main( String args[] ) { Test t=new Test(); Test.innerClass im=t.new innerClass(); im.innermethod(55); }

Correct Answer is : value of x = 55

20. Instance of inner class can exist only _______________ enclosing class.

Correct Answer is : Within