exam questions

Exam 1z0-819 All Questions

View all questions & answers for the 1z0-819 exam

Exam 1z0-819 topic 1 question 32 discussion

Actual exam question from Oracle's 1z0-819
Question #: 32
Topic #: 1
[All 1z0-819 Questions]

Given the code fragment:

Which fields are serialized in a Student object?

  • A. studentNo and classes
  • B. studentNo and name
  • C. studentNo, classes and name
  • D. studentNo, classes, name, and address
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
ASPushkin
5 months ago
answer: A Any inherited fields are serializable only if the superclass is also declared with the interface Serializable. So, fields from the Person class are not not serializable. When an object has a reference to another object, these objects must implement the Serializable interface separately, or else a NotSerializableException will be thrown. So, field id from Classes is serializable.
upvoted 1 times
...
Omnisumem
9 months, 1 week ago
Selected Answer: C
In the Student class, the fields that will be serialized are: name (inherited from the Person class) studentNo classes The name field is inherited from the Person class, and since Person is not marked as transient and does not implement Serializable, its name field will be serialized. The studentNo field is directly declared in the Student class and since Student implements Serializable, it will be serialized. The classes field is of type Classes, which also implements Serializable. Therefore, it will be serialized as well. However, the address field from the Person class is marked as transient, which means it will not be serialized.
upvoted 1 times
...
d7bb0b2
1 year ago
Selected Answer: C
C is correct, Person is extended by Student so inherit his field an name are marked as seriaziable too
upvoted 1 times
...
d7bb0b2
1 year ago
C, cause even Person is not seriazable, Student inherith the field name and then is marked as seriazable, and class and student nro. Note Person class mark transient adress so even Studen inherit thhe fields this is no seriazable.
upvoted 1 times
...
d7bb0b2
1 year, 1 month ago
When a Student object is serialized, the following fields will be included in the serialized form: school from the Student class classes from the Student class, which includes the id field from the Classes class name from the Persona class The address field in the Persona class is marked as transient, which means it will be ignored during serialization and will not be included in the serialized form of a Student object.
upvoted 1 times
...
[Removed]
1 year, 4 months ago
Tested it and answer seems to be D?! Not sure if I did anything wrong but when i made the Person-class implement serielizable as well, then the transient keyword was working as expected but whit no Serializable in the super-class -> the whole class and it's it's members where written down to memory/file reglardless of transient or not.
upvoted 1 times
...
[Removed]
1 year, 5 months ago
Selected Answer: A
Answer is A. Explanation below. Source geeksforgeeks Serialization: At the time of serialization, if any instance variable inherits from the non-serializable superclass, then JVM ignores the original value of that instance variable and saves the default value to the file. De- Serialization: At the time of de-serialization, if any non-serializable superclass is present, then JVM will execute instance control flow in the superclass. To execute instance control flow in a class, JVM will always invoke the default(no-arg) constructor of that class. So every non-serializable superclass must necessarily contain a default constructor. Otherwise, we will get a runtime exception.
upvoted 1 times
...
Stavok
1 year, 6 months ago
Selected Answer: C
When an object is serialized, all of its non-transient and non-static fields are serialized, including fields inherited from its superclass. In this case, the Student class extends the Person class and implements the Serializable interface. This means that when a Student object is serialized, all of its non-transient and non-static fields, as well as those of its superclass Person, are serialized. The Student class has two non-transient and non-static fields: studentNo and classes. The classes field is an instance of the Classes class, which also implements the Serializable interface, so it will be serialized along with the Student object. The Person class has one non-transient and non-static field: name. This field is also serialized when a Student object is serialized. The address field in the Person class is marked as transient, so it will not be serialized when a Student object is serialized.
upvoted 1 times
...
aruni_mishra
1 year, 7 months ago
Ans: A When a superclass does not implement Serializable, its attributes are not serialized.
upvoted 1 times
...
trickeryoyo
1 year, 7 months ago
name field should be serialized, too.
upvoted 1 times
...
Mukes877
1 year, 8 months ago
Selected Answer: A
A is right
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago