corejava_11

51. Can a transiant variable be static?
Transient variables may not be final  or static . Compilers does not  give any errors as static variables  are anyway not serialized.

52. What is the rule regarding overriding methods throwing exceptions?
Overriding method can not throw more generic exception than base method.

53. If an overridden method calls super class method which access class member variable, which variable will be used base class or super class?
Methods access  variables only in the context  of the class they belong to. If subclass calls super class method, it will access super class variable.

54. Can we override variables?
Yes but variables when overridden shadows the super class variable.

55. Nested classes can extend only the enclosing class and can not implement any interface? True/False
False. Nested class can extend any class or implement any interface.

No comments:

Post a Comment