Java Questions 29
Java Questions 21 - 30  «Prev  Next»

Java Questions 29

  1. Are all Java objects polymorphic?
    Answer:
    All Java objects are polymorphic in that they pass the IS-A test
    1. for their own type and
    2. for class object.
  2. How can one access an object?
    Answer:
    The only way to access an object is through a reference variable.
  3. What is the difference between object and reference variables?
    Answer:
    A reference variable is used to refer to an object. An object is what is instantiated from a class. An object has memory associated with it and a refrence variable is like a pointer.
  4. How can polymorphism be described with reference variables?
    Answer:
    A reference variable can refer to any object of the same type as the declared reference and also refer to any subtype of the declared type.
  5. Which two types can a reference variable assume?
    Answer:
    A reference variable can be declared as a class type or an interface type.
  6. What does it mean that Java implements single inheritance?
    Answer:
    A class can have only one immediate superclass.

  7. How many direct parent classes can a child class have in Java ?
    Answer:
    Any given class can have multiple classes up the inheritance tree. This is not the same as saying a class directly extends 2 classes which Java cannot.
  8. How do you get around the single inheritance challenge in Java?
    Answer:
    A Java class can have a single parent and implement multiple interfaces.
  9. What is information hiding or encapsulation?
    Answer:
    A well designed module hides all of its implementation details, cleanly separating its API from its implementation.
    [P67 Effective Java - 2nd Edition]
  10. What is a Java Resource Bundle?
    Answer:
    java.util.ResourceBundle 
    

    Resource bundles contain locale-specific objects. When your program needs a locale-specific resource, a String for example, your program can load it from the resource bundle that is appropriate for the current user's locale. This enables you to write program code that is largely independent of the user's locale isolating most of the locale-specific information in resource bundles.
    This allows you to write programs that can:
    1. be easily localized, or translated, into different languages
    2. handle multiple locales at once
    3. be easily modified later to support even more locales