Question

1. Which of the following statements is true? I. When an object is serialized, all of...

1. Which of the following statements is true?

I. When an object is serialized, all of its data attributes are always serialized.

II. When an object is serialized, its methods are not serialized.

III. The Serializable interface does not declare any abstract methods.

Select one:

A. I only

B. II only

C. III only

D. I and II only

E. II and III only

2.

For the code below, and assuming widget.dat exists, which of the following statements are false? (select all that apply)

// assume all appropriate packages have been imported

public class Widget implements Serializable
{
private int x;
public void setX( int d ) { x = d; }
public int getX() { return x; }
}

public class MyProgram
{
public static void main( String [] args ) throws Exception
{
ObjectInputStream in = new ObjectInputStream( new FileInputStream( "widget.dat" ) );
Widget w = (Widget) in.readObject();

System.out.println( w.getX() );
}
}

Select one or more:

A. The program output is 0.

B. The program will not compile.

C. The program will compile, but a runtime error will occur because readObject returns an instance of Object.

D. The program will compile and run, but no output will be produced.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Question 1:
E. II and III only

Question 2:
Options A, B, D
Add a comment
Know the answer?
Add Answer to:
1. Which of the following statements is true? I. When an object is serialized, all of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • It's been too long since I have done any Java programming. Can anyone help me with...

    It's been too long since I have done any Java programming. Can anyone help me with this one? Thank you 6.5 Write the declaration for a class named C that declares: (1) a private int instance variable named mX; (2) a private int class variable named mY initialized to 0; (3) a private int class constant named A which is equivalent to 100; (4) a public int class constant named B which is equivalent to 200; (5) public accessor and...

  • Need help with a multiple inheritance work Question Compile and run the file. If you find...

    Need help with a multiple inheritance work Question Compile and run the file. If you find any compilation errors,explain their reason as comments in the code. Then fix the errors such that the program compiles and runs. Explain the motivation of your modifications in the code and their effects on the execution inheritance.cpp file #include<iostream> using namespace std; class A { int x; public: void setX(int i) {x = i;} void print() { cout << x; } }; class B:...

  • 12 - Which of the following does not indicate a javadocs comment? I. // II. /*...

    12 - Which of the following does not indicate a javadocs comment? I. // II. /* III. /** Question 12 options: 1) Statement I only. 2) Statement II only. 3) Statement III only. 4) Statements I and II only. 5) Statements I and III only. 13 - Assume that the following numbers belonged to an ArrayList called values. 5, 23, 45, -3, 17, 18, 100 Which of the following would determine how many elements are in values? Question 13 options:...

  • Java homework Imagine that you have a Point class, like the one that we used in...

    Java homework Imagine that you have a Point class, like the one that we used in the improved Circle class. It has the following constructors:    Point(double x, double y)    Point(Point p) And the following methods:    public double getX()    public double getY()    public void setX(double xValue)    public void setY(double yValue)    public double distance(Point p) For this question, write statements that create an array of three Point references. Then initialize each element with a Point object that has with x and...

  • 1) Consider the following Java program: 1 public class HelloWorld { 2     // My first program!...

    1) Consider the following Java program: 1 public class HelloWorld { 2     // My first program! 3     public static void main(String[] args) { 4         System.out.println("Hello, World!"); 5     } 6 } What is on line 1? a. a variable declaration b. a statement c. a method (subroutine) definition d. a comment e. a class definition 2) Which one of the following does NOT describe an array? a. It can be used in a for-each loop. b. It has a numbered sequence...

  • Which of the following is true about interfaces: An interface can have only non abstract methods....

    Which of the following is true about interfaces: An interface can have only non abstract methods. All methods in an interface must be abstract. A class can only implement one interface. None of the items listed. Can not contain constants but can have variables. What is the rule for a super reference in a constructor? It must be in the parent class' constructor. You cannot use super in a constructor. It must be the last line of the constructor in...

  • Hello. I need help writing the following Java Program. Thank you Develop a class encapsulating the...

    Hello. I need help writing the following Java Program. Thank you Develop a class encapsulating the concept of a college course, assuming that a course has following attributers: code (for instance COSC1337), a description, and a number of credits (for instance 3). Include a constructor, the accessors, mutators and methods ‘toString’, ‘equals’, and ‘finalize’. Write a client class to test the behavior of the class and its methods. The outline of the class is given as follows: public class Course...

  • I need help with my IM (instant messaging) java program, I created the Server, Client, and...

    I need help with my IM (instant messaging) java program, I created the Server, Client, and Message class. I somehow can't get both the server and client to message to each other. I am at a roadblock. Here is the question below. Create an IM (instant messaging) java program so that client and server communicate via serialized objects (e.g. of type Message). Each Message object encapsulates the name of the sender and the response typed by the sender. You may...

  • 1. (TCO 7) Which of the following statements are true? (Points : 5)        Interfaces contain...

    1. (TCO 7) Which of the following statements are true? (Points : 5)        Interfaces contain one and only one implemented method, a constructor.        Interfaces are defined inside an abstract class.        All methods defined in an interface must be implemented when used by another class.        A true object-oriented design must contain as least one interface. Question 2. 2. (TCO 7) In an object-oriented program, methods with no implementation might be found in an _____ and/or a(n) ______....

  • C++ 1. The copy constructor is used for one the following scenarios: I. Initialize one object...

    C++ 1. The copy constructor is used for one the following scenarios: I. Initialize one object from another of the same type. II. Copy an object to pass it as argument to a function. III. Copy an object to return it from a function. Read the following program and answer questions (20 points) #include <iostream> using namespace std; class Line public: int getLength( void); Line( int len // simple constructor Line( const Line &obj) 1/ copy constructor Line (); //...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT