Questions et réponses d'entretien les plus demandées et tests en ligne
Plateforme d'apprentissage pour la preparation aux entretiens, les tests en ligne, les tutoriels et la pratique en direct

Developpez vos competences grace a des parcours cibles, des tests blancs et un contenu pret pour l'entretien.

WithoutBook rassemble des questions d'entretien par sujet, des tests pratiques en ligne, des tutoriels et des guides de comparaison dans un espace d'apprentissage reactif.

Preparation a l'entretien

Tests blancs

Definir comme page d'accueil

Ajouter cette page aux favoris

S'abonner avec une adresse e-mail

Java 17 Questions et reponses d'entretien

Differences associees

Java 16 vs Java 17Java 17 vs Java 18

Question 16. What is Switch Pattern Matching in Java 17?

It makes switch statements and expressions more flexible and expressive by letting patterns appear in case labels. It also makes it possible to relax the switch's null-hostility when needed.

There are two main patterns, which are as follows:

  • Guarded pattern: Uses pattern && boolean expression to refine further.
  • Pattern between parentheses

static record Human (String name, int age, String profession) {}

public String checkValue(Object obj) {
    return switch (obj) {
        case Human h -> "Name: %s, age: %s and profession: %s".formatted(h.name(), h.age(), h.profession());
        case Circle c -> "This is a circle";
        case Shape s -> "It is just a shape";
        case null -> "It is null";
        default -> "It is an empty";
    };
}

public String checkShape(Shape shape) {
    return switch (shape) {
        case Triangle t && (t.getNumberOfSides() != 3) -> "This is a weird triangle";
        case Circle c && (c.getNumberOfSides() != 0) -> "This is a weird circle";
        default -> "Just a normal shape";
    };
}

Est-ce utile ? Ajouter un commentaire Voir les commentaires
 

Question 17. What is Generate sealed Classes in Java 17?

Adds sealed classes and interfaces to the Java language to make it better. Sealed classes and interfaces limit other classes, and interfaces can extend and implement them, respectively.

Showing some other progress to pattern matching along with the JEP 406 will make it possible to check the type, cast, and act code pattern more sophisticatedly and cleanly.

public abstract sealed class Subjects  

permits English, Maths, Science {...}  

Est-ce utile ? Ajouter un commentaire Voir les commentaires
 

Question 18. Where can we download Java 17?

You can download Java 17 from the Oracle website: https://www.oracle.com/java/technologies/downloads/#java17

Est-ce utile ? Ajouter un commentaire Voir les commentaires
 

Question 19. Provide an example of Vector API update in Java 17.

The example is as follows:

public void newVectorComputation(float[] a, float[] b, float[] c) {
    for (var i = 0; i < a.length; i += SPECIES.length()) {
        var m = SPECIES.indexInRange(i, a.length);
        var va = FloatVector.fromArray(SPECIES, a, i, m);
        var vb = FloatVector.fromArray(SPECIES, b, i, m);
        var vc = va.mul(vb);
        vc.intoArray(c, i, m);
    }
}

public void commonVectorComputation(float[] a, float[] b, float[] c) {
    for (var i = 0; i < a.length; i ++) {
        c[i] = a[i] * b[i];
    }
}

Est-ce utile ? Ajouter un commentaire Voir les commentaires
 

Question 20. What is the next LTS version after Java 17?

The next LTS (Long Time Support) version is Java 21 and is released in September 2023.

Est-ce utile ? Ajouter un commentaire Voir les commentaires
 

Les plus utiles selon les utilisateurs :

Copyright © 2026, WithoutBook.