What’s correct and what’s not correct about the Java deserialization process?You are working to enhance a legacy application, in particular to add serialization support and add more constraints to new business objects. The legacy application class looks like this.public class Person { private String name = null; public...
Friday, September 29, 2023
Wednesday, September 27, 2023
Quiz yourself: Serializing a primitive with ObjectOutputStream
Primitives? Objects? What should you do?You need to serialize a long primitive value, and you have been given the following code:long l = 5L;try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(filename))) { ... //}Which statement is true? Choose one.A. The code must box the primitive using oos.writeObject(Long.valueOf(l)). B. The primitive...
Friday, September 15, 2023
Quiz yourself: Deserializing objects with readObject
You should know how the readObject method works—and when it won’t compile.Given the following Person recordrecord Person(String name) implements Serializable {}and the following method fragmenttry (ObjectInputStream in = new ObjectInputStream(new FileInputStream(filename))) { ... // code here System.out.println(person.name());}Assume that the try block is completed with necessary catch...
Monday, September 11, 2023
Java Card 3.1: Security Services
A key goal of version 3.1 is to ensure the availability of security services on a large range of secure hardware, including smartcards, embedded chips, secure enclaves within microprocessor units (MPUs) and microcontroller units (MCUs), and removable SIMs. It was designed to support the growth of existing Java...
Friday, September 8, 2023
Quiz yourself: Collectors, comparators, and type inferencing in Java
You need to find the most-frequently used word in a stream. Where do you start?Your colleague is working on an application that must find a most-frequently used word in a Stream<String>, and each element of that stream is a single word. The stream is provided by the reference...