Which of these is method of ObjectOutput interface used to finalize the output state?
Show Serialization & Deserialization11 Which of these is a method of ObjectInput interface used to deserialize an object from a stream? A. int read() B. void close() C. Object readObject() D. Object WriteObject() 12 Which of these is a method of ObjectOutput interface used to finalize the output state so that any buffers are cleared? 13 Which of these interface extends DataInput interface? A. Serializable B. Externalization C. ObjectOutput D. ObjectInput 14 Which of these interface extends DataOutput interface? A. Serializable B. Externalization C. ObjectOutput D. ObjectInput 15 Which of these is an interface for control over serialization and deserialization? A. Serializable B. Externalization C. FileFilter D. ObjectInput Asked by JudgeAtom2757 Code in Java below question and MCQs also in Java Given a number A, return number of ways you can draw A chords in a circle with 2 x A points such that no 2 chords intersect. Two ways are different if there exists a chord which is present in one way and not in other. Return
the answer modulo 10^9 + 7. Input Format: The first and the only argument contains the integer A. Output Format: Return an integer answering the query as described in the problem statement. Constraints: 1 <= A <= 1000 Examples: Input 1: A = 1 Output 1: 1 1. Which of these is a process of writing the state of an object to a byte stream? a) Serialization b) Externalization c)
File Filtering d) All of the mentioned 2. Which of these process occur automatically by the java runtime system? a) Serialization b) Garbage collection c) File Filtering d) All of the mentioned 3. Which of these is an interface for control over serialization and deserialization? a) Serializable b) Externalization c) FileFilter d) ObjectInput 4. Which of these interface extends DataOutput interface? a) Serializable b) Externalization c) ObjectOutput d) ObjectInput 5. Which of these is a method of ObjectOutput interface used to finalize the output state so that any buffers are cleared? a) clear() b) flush() c) fflush() d) close() 6. Which of these is method of ObjectOutput interface used to write the object to input or output stream as required? a) write() b) Write() c) StreamWrite() d) writeObject() 7. What will be the output of the following Java program? import java.io.*; class serialization { public static void main(String[] args) { try { Myclass object1 = new Myclass("Hello", -7, 2.1e10); FileOutputStream fos = new FileOutputStream("serial"); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(object1); oos.flush(); oos.close(); } catch(Exception e) { System.out.println("Serialization" + e); System.exit(0); } try { Myclass object2; FileInputStream fis = new FileInputStream("serial"); ObjectInputStream ois = new ObjectInputStream(fis); object2 = (Myclass)ois.readObject(); ois.close(); System.out.println(object2); } catch (Exception e) { System.out.print("deserialization" + e); System.exit(0); } } } class Myclass implements Serializable { String s; int I; double d; Myclass (String s, int i, double d) { this.d = d; this.i = I; this.s = s; } } a) s=Hello; i=-7; d=2.1E10 b) Hello; -7; 2.1E10 c) s; i; 2.1E10 d) Serialization 8. What will be the output of the following Java program? import java.io.*; class serialization { public static void main(String[] args) { try { Myclass object1 = new Myclass("Hello", -7, 2.1e10); FileOutputStream fos = new FileOutputStream("serial"); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(object1); oos.flush(); oos.close(); } catch(Exception e) { System.out.println("Serialization" + e); System.exit(0); } try { int x; FileInputStream fis = new FileInputStream("serial"); ObjectInputStream ois = new ObjectInputStream(fis); x = ois.readInt(); ois.close(); System.out.println(x); } catch (Exception e) { System.out.print("deserialization"); System.exit(0); } } } class Myclass implements Serializable { String s; int I; double d; Myclass(String s, int i, double d) { this.d = d; this.i = I; this.s = s; } } a) -7 b) Hello c) 2.1E10 d) deserialization 9. What will be the output of the following Java program? import java.io.*; class Chararrayinput { public static void main(String[] args) { String obj = "abcdefgh"; int length = obj.length(); char c[] = new char[length]; obj.getChars(0, length, c, 0); CharArrayReader input1 = new CharArrayReader(c); CharArrayReader input2 = new CharArrayReader(c, 1, 4); int I; int j; try { while ((i = input1.read()) == (j = input2.read())) { System.out.print((char)i); } } catch (IOException e) { e.printStackTrace(); } } } a) abc b) abcd c) abcde d) None of the mentioned 10. What will be the output of the following Java program? import java.io.*; class streams { public static void main(String[] args) { try { FileOutputStream fos = new FileOutputStream("serial"); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeFloat(3.5); oos.flush(); oos.close(); } catch(Exception e) { System.out.println("Serialization" + e); System.exit(0); } try { float x; FileInputStream fis = new FileInputStream("serial"); ObjectInputStream ois = new ObjectInputStream(fis); x = ois.readInt(); ois.close(); System.out.println(x); } catch (Exception e) { System.out.print("deserialization"); System.exit(0); } } } a) 3 b) 3.5 c) serialization d) deserialization Answer & Explanation Solved by verified expert Answered by srinadhusaipreetham tesque dapibus efficitur laoreet. Nam risus cing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipis Unlock full access to Course Hero Explore over 16 million step-by-step answers from our library Subscribe to view answer Step-by-step explanation ongue gue s a
molestie nec facili , consectetu ce dui lectu ac, dictum m ipsum dolo ec aliquet. ac, dictum v inia
pulvina cing elit. Na gue Which of these is method of ObjectInput interface used to read the object?The readObject() method of ObjectInputStream class is used to read an object from objectinputstresm. The readUTF() method of ObjectInputStream class reads a String in modified UTF-8 format. It returns String. The readUnsignedShort() method of ObjectInputStream class reads an unsigned 16 bit short.
Which of these interface extends DataInput interface?ObjectInput extends the DataInput interface to include the reading of objects.
Which of the following method is used to deserialize an object?The ObjectOutputStream class contains writeObject() method for serializing an Object. The ObjectInputStream class contains readObject() method for deserializing an object.
Which interface is used for serialization?Serializability of a class is enabled by the class implementing the java. io. Serializable interface. Classes that do not implement this interface will not have any of their state serialized or deserialized.
|