Results 1 to 6 of 6
  1. #1
    money123 is offline Member
    Join Date
    Jul 2007
    Posts
    11
    Rep Power
    0

    Default question on ObjectOutputStream

    Which one of the following requirements must a class meet in order to be written to a stream using ObjectOutputStream?

    Choice 1

    The class must implement the Serializable interface.
    Choice 2

    The class cannot have any fields declared as transient.
    Choice 3

    The class cannot contain any static fields or methods.
    Choice 4

    The class must provide a SerialPersistentFields array.
    Choice 5

    All fields and methods in the class must be declared public.

  2. #2
    shanePreater is offline Member
    Join Date
    Jul 2007
    Location
    England, Bath
    Posts
    47
    Rep Power
    0

    Default

    Choice 1 is needed to write an object out to an object stream.

  3. #3
    money123 is offline Member
    Join Date
    Jul 2007
    Posts
    11
    Rep Power
    0

    Default

    thankyou so much......:) ....one more question is there..........

    synchronized void move() throws java.io.IOException {

    Additional code here

    }

    Referring to the sample code above, how can a method in the same class invoke move()?

    Choice 1

    By enclosing the call inside a "try" block followed by a "catch (java.io.IOException e)" block.
    Choice 2

    By enclosing the call inside a "try" block.
    Choice 3

    By calling wait() to obtain the object's monitor before calling move().
    Choice 4

    By following the call with a "catch (java.io.IOException e)" block.
    Choice 5

    By enclosing the call inside a "catch (java.io.IOException e)" block.

    I think answer is choice 1....am i correct:cool:

  4. #4
    shanePreater is offline Member
    Join Date
    Jul 2007
    Location
    England, Bath
    Posts
    47
    Rep Power
    0

    Default

    The method is defining throws IOException so anything calling the method will need to either define the same throws clause or call the method with in a try / catch block where IOException is caught.

    Which of the options conforms to one of the above?

  5. #5
    money123 is offline Member
    Join Date
    Jul 2007
    Posts
    11
    Rep Power
    0

    Default

    yes..i think Option 1 is correct...
    thanks for clarification....:)

  6. #6
    shanePreater is offline Member
    Join Date
    Jul 2007
    Location
    England, Bath
    Posts
    47
    Rep Power
    0

Similar Threads

  1. Question mark colon operator question
    By orchid in forum Advanced Java
    Replies: 9
    Last Post: 12-19-2010, 08:49 AM
  2. ObjectOutputStream Example
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-20-2008, 09:21 AM
  3. Need help on this question
    By Deon in forum New To Java
    Replies: 3
    Last Post: 01-27-2008, 03:58 PM
  4. JNI question
    By javaplus in forum New To Java
    Replies: 0
    Last Post: 12-24-2007, 10:18 AM
  5. question about rmi
    By leonard in forum New To Java
    Replies: 1
    Last Post: 08-06-2007, 04:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •