JavaRush /Java Blog /Random EN /Level 33. Answers to interview questions on the level top...
Afli
Level 41
Санкт-Петербург

Level 33. Answers to interview questions on the level topic

Published in the Random EN group
Questions/additions/criticism are welcome. Level 33. Answers to interview questions on the topic of level - 1
  1. What is JSON?

    JSON (JavaScript Object Notation) is a simple data interchange format based on a subset of the JavaScript programming language.

  2. What are the differences between Java and JavaScript?

    These are 2 different programming languages, despite the similarity of their names. Both of them have C-like syntax. The differences are as follows:

    • Java implements an OOP approach based on classes, JavaScript - on prototypes;
    • Java has static typing, JavaScript has dynamic typing;
    • Java is loaded from compiled bytecode; JavaScript is interpreted directly from the file.

    Your text to link...

  3. What are the differences between JSON and XML?

    JSON is a data exchange format.

    XML is a markup language (in which you can specify syntax, structure, data types, and their model in general).

    Both of them can be used to transfer data. Naturally, to work with both standards, different frameworks are used and the syntax is different.

  4. What frameworks for working with JSON do you know?

    Level 33 introduced us to the jackson framework. In addition, I will give 3 more, and a link to an article in which they are compared:

    1. Jackson by FasterXML
    2. JSON.simple by Yidong Fang
    3. GSON from Google
    4. JSONP from Oracle

    Comparing Java libraries for working with JSON: JSON.simple, GSON, Jackson and JSONP

  5. What frameworks for working with XML do you know?

    Since XML is a data representation format, there are more diverse technologies for working with it. I will give the technologies used to serialize Java objects into XML:

    1. JAXB (included in J in the JDK)
    2. Xstream

    Link with a brief overview of various frameworks for working with xml: JAVA + XML

  6. What Jackson annotations do you know?

    Let's look at those that were used in the lectures:

    • @JsonAutoDetect - placed in front of the class. Tells Jackson to use the fields of this class when writing or reading. In parentheses, you can set a parameter (fieldVisibility = JsonAutoDetect.Visibility.ANY) to configure the visibility of the fields that will be used (by default, only public fields are used).
    • @JsonIgnore - placed before the field. Tells Jackson to ignore this field when reading/writing.
    • @JsonProperty - Placed before the field, getter or setter. Allows you to specify a different field name during serialization.
    • @JsonWriteNullProperties - Placed in front of the class. Object fields that are null will not be ignored.
    • @JsonPropertyOrder - Placed in front of the class. allows you to define the order in which the fields of a java object will be serialized to JSON.
    • @JsonDeserialize - Placed before the field. Allows you to define the class into which the JSON object is deserialized. For example, in java, arrays and lists are serialized into arrays, and during deserialization, we can choose what exactly we want to receive.

    Here is a link to a site with some annotations: Jackson Annotations

  7. What JAXB annotations do you know?

    I will also analyze only those that were used in the lecture:

    • @XmlRootElement - Placed before the class. Indicates that this object can be a top-level element, i.e. all other elements lie within it.
    • @XmlType - Placed before the class. Adds additional information to the XML schema. You can specify some attributes, such as the order of elements, name, etc.
    • @XmlElement - Placed before the field. Allows you to set the xml element name, default value, etc.
    • @XmlAttribute - Placed before the field. The field will be represented as an XML attribute.
    • @XmlElementWrapper - Placed before the field or getter. Allows you to create a border tag for a group of elements.
    • @XmlJavaTypeAdapter - Placed before the class. The auxiliary adapter class required for marshaling/unmarshalling this class is indicated in parentheses.
    • @XmlEnum - Placed before enum. In parentheses you can specify the type in which the enum values ​​will be represented.
    • @XmlEnumValue — Placed before the enum value. Allows you to specify a special value for a given enum value.

    Here is a link to a site with some annotations (I apologize for not being able to create a correct translation for the annotations, the information is understandable, but I have absolutely no idea how to say it correctly in Russian): https://jaxb.java.net/tutorial/index .html

  8. What is the difference between serialization and deserialization in JSON?

    I didn't understand the essence of the question. I don’t see any point in comparing 2 reciprocal processes. Perhaps this was meant to compare JSON and XML; a link to this topic is provided in the next question.

  9. Which is better JSON or XML? Why?

    Here's a great article that compares JSON and XML: JSON and XML. What's better?

    Perhaps it is impossible to say that something is better. When choosing, you should look at the task itself and what will be more effective in use. Plus, the choice may depend on the personal preferences of the developer.

  10. What is DTO?

    DTO (Data Transfer Object) is a design pattern containing data without any logic for working with it. DTOs are typically used to transfer data between different applications, or between layers within the same application. They can be viewed as a repository of information whose sole purpose is to convey that information to the recipient.

Level 33. Answers to interview questions on the topic of level - 2
Updated 11/10/2016 at 15.50

questions No. 2, No. 3 corrected, according to the comment

Comments
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION