Results 1 to 6 of 6
Thread: question on ObjectOutputStream
- 07-26-2007, 10:42 AM #1
Member
- Join Date
- Jul 2007
- Posts
- 11
- Rep Power
- 0
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.
- 07-26-2007, 10:51 AM #2
Member
- Join Date
- Jul 2007
- Location
- England, Bath
- Posts
- 47
- Rep Power
- 0
Choice 1 is needed to write an object out to an object stream.
- 07-26-2007, 11:04 AM #3
Member
- Join Date
- Jul 2007
- Posts
- 11
- Rep Power
- 0
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:
- 07-26-2007, 11:08 AM #4
Member
- Join Date
- Jul 2007
- Location
- England, Bath
- Posts
- 47
- Rep Power
- 0
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?
- 07-27-2007, 06:59 AM #5
Member
- Join Date
- Jul 2007
- Posts
- 11
- Rep Power
- 0
yes..i think Option 1 is correct...
thanks for clarification....:)
- 07-27-2007, 10:31 AM #6
Member
- Join Date
- Jul 2007
- Location
- England, Bath
- Posts
- 47
- Rep Power
- 0
Correct and no worries glad to help.
Similar Threads
-
Question mark colon operator question
By orchid in forum Advanced JavaReplies: 9Last Post: 12-19-2010, 08:49 AM -
ObjectOutputStream Example
By Java Tip in forum Java TipReplies: 0Last Post: 03-20-2008, 09:21 AM -
Need help on this question
By Deon in forum New To JavaReplies: 3Last Post: 01-27-2008, 03:58 PM -
JNI question
By javaplus in forum New To JavaReplies: 0Last Post: 12-24-2007, 10:18 AM -
question about rmi
By leonard in forum New To JavaReplies: 1Last Post: 08-06-2007, 04:19 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks