|
Home ► Placements ► Interview Questions ► Java Interview Questions And Answers ►Java Interview Questions On Flow Control and Exception Handling ▼
Java Interview Questions On Flow Control and Exception Handling |
9. Explain About friendly modifier?
Answer:
IT IS NOT A KEYWORD.
- If you don't specify an access modifier, then compiler assigns default access modifier, which is not a keyword.
- Java run time environment consider all the class files in a current working directory as a package. If any class, method, member variable or an inner class does not have any modifier considered as friendly.
- These features are available to the same class or in a same package, or sub classes of a same package.
- l If a method is declared in base class as private, it can be overridden by private, friendly,
- protected and public method.
|
10. Explain about java access modifiers overridden hierarchy?
Answer
- l private features are overridden by private, friendly, protected, public features.
- l friendly features are overridden by friendly, protected, public features.
- l protected features are overridden by protected and public features.
- l public features are overridden by only public features.
- A less access modifier can be overridden by with higher access modifier.
- You cannot have two access modifiers to a class, method, variable, or to an inner class.
|
11. Explain About static key word in java?
Answer:
Given to
- l Methods
- l Variables
- l Inner classes
- l Block of code
For example the main() method is public and is a static method. So the method which is declared as static has no this reference. Static features can be called through class name. So from a static method you cannot access non static features.Without object reference the static features are accessed.
|
|
|