Java Questions 11 - 20  «Prev Next»

Java Stubs and Skeletons (Interview Questions)

  1. What does a stub class consist of?

    Answer:
    Stubs and Skeletons are used in the context of CORBA and RMI.

  2. What are the advantages of using references as attributes?

    Answer:
    We avoid data redundancy and the potential loss of data integrity.

  3. What is another advantage of using object references?

    Answer:
    Storing a reference of an object only requires 4 bytes, instead of the number of bytes of storage the referenced object as a whole occupies in memory.

  4. What are 3 distinguishing features of an object oriented language?

    Answer:
    1. User defined (reference) types,
    2. Inheritance,
    3. Polymorphism

  5. What does a class define?

    Answer:
    a) The data that an object will encapsulate, known as the object's attributes b)The behaviors/services that an object will be able to perform, known as methods


  6. How many constructors can you call with the "this" keyword?

    Answer:
    One. Within the constructor, "this" is a reference to the current object, the object whose method or constructor is being invoked.
  7. What is the inverse relationship between static and non-static methods in Java?
    Answer:
    You cannot call non-static methods from inside static methods. You can call static methods for the class itself.
  8. What does the static method allow?
    Answer:
    Putting a static method inside a class allows it access to other static methods.
  9. Describe synchronization with respect to multithreading?
    Answer:
    With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources. Without synchronization, it is possible for one thread to modify a shared variable while another thread is in the process of using or updating same shared variable. This usually leads to significant errors.
  10. What are 2 different ways of using threads?
    Answer:
    The thread could be implemented by using the "runnable interface" or by inheriting from the Thread class. The former option (implementing the runnable interface) is more advantageous, since you can only achieve multiple inheritance through the use of interfaces.