Java Programming Questions
13. |
What are access modifiers? |
|
Access modifiers decide whether a method or a data variable can be accessed by another method in another class or subclass.
Java provides four types of access modifiers.-
Public: can be accessed by any other class anywhere.
-
Protected: can be accessed by class inside the package or by subclass ( that means classes who inherit from this class).
-
Private: can be accessed only within the class. Even methods in subclasses in the same package do not have access.
-
Default: accessible to classes in the same package but not by classes in other packages, even if these are sub classes.
Abstract class myAbstractGraphics
{
Abstract void draw ();
}
|
14. |
What modifiers may be used with an interface declaration? |
|
An interface may be declared as public or abstract. |
15. |
Why is multiple inheritances not possible in Java? |
|
It depends on how you understand "inheritance". Java can only "extends" one super class, but can "implements" many interfaces; that doesn't mean the multiple inheritance is not possible. You may use interfaces to make inheritance work for you. Or you may need to work around.
|
16. |
What is the difference amongst JVM Spec, JVM Implementation, and JVM Runtime? |
|
- The JVM spec is the blueprint for the JVM generated and owned by Sun.
-
The JVM implementation is the actual implementation of the spec by a vendor and the JVM runtime is the actual running instance of a JVM implementation.
|