Wednesday 11 February 2015

Experienced Core Java Interview Questions and Answers (Page 6)

Below are some important Core Java interview questions which are asked in most MNC company interviews for beginners or professionals.

26. Can a class be declared as protected?
A class can't be declared as protected. only methods can be declared as protected.

27. What is the access scope of a protected method?
A protected method can be accessed by the classes within the same package or by the subclasses of the class in any package.

28. What is the purpose of declaring a variable as final?
A final variable's value can't be changed. final variables should be initialized before using them.

29. What is the impact of declaring a method as final?
A method declared as final can't be overridden. A sub-class can't have the same method signature with a different implementation.

30. I don't want my class to be inherited by any other class. What should i do?
You should declared your class as final. But you can't define your class as final, if it is an abstract class. A class declared as final can't be extended by any other class.
More Questions & Answers :-
Page1  Page2  Page3  Page4  Page5  Page6  Page7  Page8

No comments:

Post a Comment